]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/copydir.c: error_acl(): Preserve errno
authorAlejandro Colomar <alx@kernel.org>
Wed, 24 Dec 2025 10:19:37 +0000 (11:19 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 17 Jul 2026 13:48:04 +0000 (08:48 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/copydir.c

index 3976bf8e342983ef83dfb244813bd9a2c9e1dab3..47ea9f2810de7a49a05f2db1b29c61f4d33ff684 100644 (file)
@@ -33,7 +33,6 @@
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -93,7 +92,8 @@ format_attr(printf, 2, 3)
 static void
 error_acl(MAYBE_UNUSED struct error_context *_1, const char *fmt, ...)
 {
-       va_list ap;
+       int      e;
+       va_list  ap;
 
        /* ignore the case when destination does not support ACLs
         * or extended attributes */
@@ -102,13 +102,17 @@ error_acl(MAYBE_UNUSED struct error_context *_1, const char *fmt, ...)
                return;
        }
 
+       e = errno;
+
        va_start (ap, fmt);
        (void) fprintf (log_get_logfd(), _("%s: "), log_get_progname());
        if (vfprintf (log_get_logfd(), fmt, ap) != 0) {
                (void) fputs (_(": "), log_get_logfd());
        }
-       (void) fprintf(log_get_logfd(), "%s\n", strerrno());
+       (void) fprintf(log_get_logfd(), "%s\n", strerror(e));
        va_end (ap);
+
+       errno = e;
 }
 
 static struct error_context ctx = {