From: Michael Tremer Date: Thu, 27 Mar 2025 18:07:27 +0000 (+0000) Subject: pwd: Don't permit any UID/GID lookups in stub mode X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=88f5d4d6a1246cd9c2a2ca2781364785badae367;p=pakfire.git pwd: Don't permit any UID/GID lookups in stub mode This is simply not supported because we don't have a file system. Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/pwd.c b/src/pakfire/pwd.c index 90ef47ed..ed58d859 100644 --- a/src/pakfire/pwd.c +++ b/src/pakfire/pwd.c @@ -45,9 +45,13 @@ static struct passwd* pakfire_getpwent(struct pakfire* pakfire, char path[PATH_MAX]; int r; + // This cannot be performed in stub mode + if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_STUB)) + return NULL; + // Get path to /etc/passwd r = pakfire_path(pakfire, path, "%s", "/etc/passwd"); - if (r) + if (r < 0) return NULL; FILE* f = fopen(path, "r"); @@ -106,9 +110,13 @@ static struct group* pakfire_getgrent(struct pakfire* pakfire, char path[PATH_MAX]; int r; + // This cannot be performed in stub mode + if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_STUB)) + return NULL; + // Get path to /etc/group r = pakfire_path(pakfire, path, "%s", "/etc/group"); - if (r) + if (r < 0) return NULL; FILE* f = fopen(path, "r");