]> git.ipfire.org Git - pakfire.git/commitdiff
pwd: Don't permit any UID/GID lookups in stub mode
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Mar 2025 18:07:27 +0000 (18:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 27 Mar 2025 18:07:27 +0000 (18:07 +0000)
This is simply not supported because we don't have a file system.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/pwd.c

index 90ef47edce308b35e81d3b8e772dfb06bdf5f285..ed58d859bd995333726bf5a4356ec834585c5abf 100644 (file)
@@ -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");