Some minor optmizations

This commit is contained in:
topjohnwu 2019-02-24 14:14:03 -05:00
parent 621fd0ee29
commit bd4e5bfc1a
2 changed files with 4 additions and 8 deletions

View File

@ -28,9 +28,7 @@ int main(int argc, char *argv[]) {
cmdline_logging(); cmdline_logging();
init_argv0(argc, argv); init_argv0(argc, argv);
if (strcmp(basename(argv[0]), "magisk.bin") == 0 || if ((strcmp(basename(argv[0]), "magisk") == 0 && argc > 1 && argv[1][0] != '-')) {
(strcmp(basename(argv[0]), "magisk") == 0
&& argc > 1 && argv[1][0] != '-')) {
--argc; --argc;
++argv; ++argv;
} }

View File

@ -79,18 +79,16 @@ void selinux_builtin_impl() {
getfilecon = __getfilecon; getfilecon = __getfilecon;
lgetfilecon = __lgetfilecon; lgetfilecon = __lgetfilecon;
setfilecon = __setfilecon; setfilecon = __setfilecon;
setfilecon = __lsetfilecon; lsetfilecon = __lsetfilecon;
} }
void dload_selinux() { void dload_selinux() {
void *handle = dlopen("libselinux.so", RTLD_LAZY); if (access("/system/lib/libselinux.so", F_OK))
if (handle == nullptr)
return; return;
/* We only use dlopen to know whether libselinux.so exists. /* We only check whether libselinux.so exists but don't dlopen.
* For some reason calling symbols returned from dlsym * For some reason calling symbols returned from dlsym
* will result to SEGV_ACCERR on some devices. * will result to SEGV_ACCERR on some devices.
* Always use builtin implementations for SELinux stuffs. */ * Always use builtin implementations for SELinux stuffs. */
dlclose(handle);
selinux_builtin_impl(); selinux_builtin_impl();
} }