From f64f9fd1be8dbc5c14d7a6e817f192db2614844a Mon Sep 17 00:00:00 2001 From: Matthew Hughes Date: Tue, 29 Apr 2025 17:56:59 +0100 Subject: [PATCH] newuidmap: better error logging on failure 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 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/newuidmap.c b/src/newuidmap.c index 8deb06f0b..d489de8b3 100644 --- a/src/newuidmap.c +++ b/src/newuidmap.c @@ -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; } -- 2.47.2