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();
init_argv0(argc, argv);
if (strcmp(basename(argv[0]), "magisk.bin") == 0 ||
(strcmp(basename(argv[0]), "magisk") == 0
&& argc > 1 && argv[1][0] != '-')) {
if ((strcmp(basename(argv[0]), "magisk") == 0 && argc > 1 && argv[1][0] != '-')) {
--argc;
++argv;
}

View File

@ -79,18 +79,16 @@ void selinux_builtin_impl() {
getfilecon = __getfilecon;
lgetfilecon = __lgetfilecon;
setfilecon = __setfilecon;
setfilecon = __lsetfilecon;
lsetfilecon = __lsetfilecon;
}
void dload_selinux() {
void *handle = dlopen("libselinux.so", RTLD_LAZY);
if (handle == nullptr)
if (access("/system/lib/libselinux.so", F_OK))
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
* will result to SEGV_ACCERR on some devices.
* Always use builtin implementations for SELinux stuffs. */
dlclose(handle);
selinux_builtin_impl();
}