]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
newuidmap: better error logging on failure
authorMatthew Hughes <matthewhughes934@gmail.com>
Tue, 29 Apr 2025 16:56:59 +0000 (17:56 +0100)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 2 May 2025 13:49:25 +0000 (15:49 +0200)
The handling for `sub_uid_open` relies on `commonio_open` preserving
`errno`, which it appears to make an effort do, but doesn't explicitly
document.

Closes: https://github.com/shadow-maint/shadow/issues/1253
src/newuidmap.c

index 8deb06f0b556a2859163f5d30497492ca1a575dc..d489de8b31c86b934f0db7e8b41e9534fecc8fe7 100644 (file)
@@ -119,7 +119,9 @@ int main(int argc, char **argv)
 
        /* Get the effective uid and effective gid of the target process */
        if (fstat(proc_dir_fd, &st) < 0) {
-               fprintf(stderr, _("%s: Could not stat directory for target process\n"), Prog);
+               fprintf(stderr,
+                       _("%s: Could not stat directory for target process: %s\n"),
+                       Prog, strerror (errno));
                return EXIT_FAILURE;
        }
 
@@ -139,6 +141,9 @@ int main(int argc, char **argv)
        }
 
        if (!sub_uid_open(O_RDONLY)) {
+               fprintf (stderr,
+                        _("%s: cannot open %s: %s\n"),
+                        Prog, sub_uid_dbname (), strerror (errno));
                return EXIT_FAILURE;
        }