From 4cd285dc74c0d94259509e403acb3449f8ac3fa1 Mon Sep 17 00:00:00 2001 From: Andrew Hyatt Date: Fri, 17 Feb 2017 21:39:15 -0800 Subject: [PATCH] Check two possible paths for darling-mach.ko This is necessary because Ubuntu overrides `DEST_MODULE_LOCATION[0]` in `dkms.conf` to be `/updates/dkms`. --- src/dyld/darling.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dyld/darling.c b/src/dyld/darling.c index 9accc45ea..3712f2a3e 100644 --- a/src/dyld/darling.c +++ b/src/dyld/darling.c @@ -801,19 +801,33 @@ int isModuleLoaded() int loadKernelModule() { int fd; - char path[128]; + // We need to check two paths due to DKMS + // Ubuntu overrides our dkms.conf and forces the modules into the updates folder + char miscpath[128], updatespath[128]; + char* path; struct utsname name; if (isModuleLoaded()) return 0; uname(&name); - snprintf(path, sizeof(path), "/lib/modules/%s/kernel/misc/darling-mach.ko", name.release); - if (access(path, F_OK)) + snprintf(miscpath, sizeof(miscpath), "/lib/modules/%s/kernel/misc/darling-mach.ko", name.release); + snprintf(updatespath, sizeof(updatespath), "/lib/modules/%s/updates/dkms/darling-mach.ko", name.release); + + // Since miscpath is the normal location we check for it last + if(access(updatespath, F_OK) == 0) + { + path = updatespath; + } + else if (access(miscpath, F_OK)) { fprintf(stderr, "Cannot find kernel module at %s: %s\n", path, strerror(errno)); return 1; } + else + { + path = miscpath; + } fd = open(path, O_RDONLY|O_CLOEXEC); if (fd < 0) -- 2.51.2