diff --git a/CMakeLists.txt b/CMakeLists.txt index eb1611c23..27588b31a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1249,6 +1249,7 @@ elseif(GNU) src/detection/opengl/opengl_linux.c src/detection/os/os_linux.c src/detection/packages/packages_linux.c + src/detection/packages/packages_nix.c src/detection/poweradapter/poweradapter_nosupport.c src/detection/processes/processes_linux.c src/detection/gtk_qt/qt.c diff --git a/src/detection/displayserver/linux/wmde.c b/src/detection/displayserver/linux/wmde.c index f735bd40c..8310c4bc9 100644 --- a/src/detection/displayserver/linux/wmde.c +++ b/src/detection/displayserver/linux/wmde.c @@ -351,7 +351,7 @@ static const char* getFromProcesses(FFDisplayServerResult* result) break; } } -#elif __linux__ +#elif __linux__ || __GNU__ FF_AUTO_CLOSE_DIR DIR* procdir = opendir("/proc"); if(procdir == NULL) return "opendir(\"/proc\") failed"; diff --git a/src/detection/localip/localip_linux.c b/src/detection/localip/localip_linux.c index f1aaf7874..2f9d29fea 100644 --- a/src/detection/localip/localip_linux.c +++ b/src/detection/localip/localip_linux.c @@ -29,8 +29,7 @@ #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__NetBSD__) || defined(__HAIKU__) #include #include -#elif defined(__GNU__) -#else +#elif !defined(__GNU__) #include #endif #if defined(__sun) || defined(__HAIKU__) diff --git a/src/detection/packages/packages.h b/src/detection/packages/packages.h index 21e5ba544..7464a30c1 100644 --- a/src/detection/packages/packages.h +++ b/src/detection/packages/packages.h @@ -55,7 +55,7 @@ const char* ffDetectPackages(FFPackagesResult* result, FFPackagesOptions* option bool ffPackagesReadCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, const char* filePath, const char* packageId, uint32_t* result); bool ffPackagesWriteCache(FFstrbuf* cacheDir, FFstrbuf* cacheContent, uint32_t num_elements); -#if defined(__linux__) || defined(__APPLE__) +#if defined(__linux__) || defined(__APPLE__) || defined(__GNU__) uint32_t ffPackagesGetNix(FFstrbuf* baseDir, const char* dirname); #endif #ifndef _WIN32 diff --git a/src/detection/packages/packages_linux.c b/src/detection/packages/packages_linux.c index 62cc27f80..95e117548 100644 --- a/src/detection/packages/packages_linux.c +++ b/src/detection/packages/packages_linux.c @@ -418,13 +418,11 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts, if (!(options->disabled & FF_PACKAGES_FLAG_EMERGE_BIT)) packageCounts->emerge += countFilesRecursive(baseDir, "/var/db/pkg", "SIZE"); if (!(options->disabled & FF_PACKAGES_FLAG_EOPKG_BIT)) packageCounts->eopkg += getNumElements(baseDir, "/var/lib/eopkg/package", true); if (!(options->disabled & FF_PACKAGES_FLAG_FLATPAK_BIT)) packageCounts->flatpakSystem += getFlatpakPackages(baseDir, "/var/lib"); - #if defined(__linux__) || defined(__APPLE__) if (!(options->disabled & FF_PACKAGES_FLAG_NIX_BIT)) { packageCounts->nixDefault += ffPackagesGetNix(baseDir, "/nix/var/nix/profiles/default"); packageCounts->nixSystem += ffPackagesGetNix(baseDir, "/run/current-system"); } - #endif if (!(options->disabled & FF_PACKAGES_FLAG_PACMAN_BIT)) packageCounts->pacman += getNumElements(baseDir, "/var/lib/pacman/local", true); if (!(options->disabled & FF_PACKAGES_FLAG_LPKGBUILD_BIT)) packageCounts->lpkgbuild += getNumElements(baseDir, "/opt/Loc-OS-LPKG/lpkgbuild/remove", false); if (!(options->disabled & FF_PACKAGES_FLAG_PKGTOOL_BIT)) packageCounts->pkgtool += getNumElements(baseDir, "/var/log/packages", false); @@ -519,7 +517,6 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) #endif ffStrbufSet(&baseDir, &instance.state.platform.homeDir); - #if defined(__linux__) || defined(__APPLE__) if (!(options->disabled & FF_PACKAGES_FLAG_NIX_BIT)) { // Count packages from $HOME/.nix-profile @@ -544,7 +541,6 @@ void ffDetectPackagesImpl(FFPackagesResult* result, FFPackagesOptions* options) FF_STRBUF_AUTO_DESTROY userPkgsDir = ffStrbufCreateStatic("/etc/profiles/per-user/"); result->nixUser += ffPackagesGetNix(&userPkgsDir, instance.state.platform.userName.chars); } - #endif if (!(options->disabled & FF_PACKAGES_FLAG_GUIX_BIT)) { diff --git a/src/detection/uptime/uptime_linux.c b/src/detection/uptime/uptime_linux.c index c1786a89b..1007374ce 100644 --- a/src/detection/uptime/uptime_linux.c +++ b/src/detection/uptime/uptime_linux.c @@ -33,6 +33,8 @@ const char* ffDetectUptime(FFUptimeResult* result) result->uptime = (uint64_t) uptime.tv_sec * 1000 + (uint64_t) uptime.tv_nsec / 1000000; result->bootTime = ffTimeGetNow() - result->uptime; - #endif return NULL; + #else + return "read(/proc/uptime) failed"; + #endif }