]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, src/: Use strerrno() instead of its pattern master
authorAlejandro Colomar <alx@kernel.org>
Tue, 22 Jul 2025 21:18:48 +0000 (23:18 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Tue, 4 Nov 2025 09:11:16 +0000 (10:11 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
32 files changed:
lib/addgrps.c
lib/commonio.c
lib/copydir.c
lib/exit_if_null.h
lib/find_new_gid.c
lib/find_new_uid.c
lib/get_pid.c
lib/gettime.c
lib/idmapping.c
lib/prefix_flag.c
lib/root_flag.c
lib/run_part.c
lib/selinux.c
lib/spawn.c
lib/tcbfuncs.c
src/chage.c
src/chgpasswd.c
src/chpasswd.c
src/faillog.c
src/gpasswd.c
src/groupadd.c
src/lastlog.c
src/login.c
src/newgidmap.c
src/newgrp.c
src/newuidmap.c
src/newusers.c
src/passwd.c
src/useradd.c
src/userdel.c
src/usermod.c
src/vipw.c

index bdc4cf2f12766de9f0f39f8b4f3e3d580f986127..b79203205231d6e7f52425efee7f0e91983a2db8 100644 (file)
@@ -24,6 +24,7 @@
 #include "shadow/grp/agetgroups.h"
 #include "shadowlog.h"
 #include "string/strchr/strchrscnt.h"
+#include "string/strerrno.h"
 
 
 /*
@@ -65,7 +66,7 @@ add_groups(const char *list)
        free(dup);
 
        if (setgroups(n, gids) == -1) {
-               fprintf(shadow_logfd, "setgroups: %s\n", strerror(errno));
+               fprintf(shadow_logfd, "setgroups: %s\n", strerrno());
                goto free_gids;
        }
 
index 039b01ea0001d885e79d4e5c2b8eaf0cff0bb46c..73afa6098d8bd5872cd09ebd9428d31c4abad421 100644 (file)
@@ -39,6 +39,7 @@
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -102,7 +103,7 @@ static int check_link_count (const char *file, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: %s file stat error: %s\n",
-                                       shadow_progname, file, strerror (errno));
+                                       shadow_progname, file, strerrno());
                }
                return 0;
        }
@@ -133,7 +134,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: %s: %s\n",
-                                       shadow_progname, file, strerror (errno));
+                                       shadow_progname, file, strerrno());
                }
                return 0;
        }
@@ -145,7 +146,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: %s file write error: %s\n",
-                                       shadow_progname, file, strerror (errno));
+                                       shadow_progname, file, strerrno());
                }
                (void) close (fd);
                unlink (file);
@@ -155,7 +156,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: %s file sync error: %s\n",
-                                       shadow_progname, file, strerror (errno));
+                                       shadow_progname, file, strerrno());
                }
                (void) close (fd);
                unlink (file);
@@ -174,7 +175,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: %s: %s\n",
-                                       shadow_progname, lock, strerror (errno));
+                                       shadow_progname, lock, strerrno());
                }
                unlink (file);
                errno = EINVAL;
@@ -217,7 +218,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: cannot get lock %s: %s\n",
-                                       shadow_progname, lock, strerror (errno));
+                                       shadow_progname, lock, strerrno());
                }
                unlink (file);
                return 0;
@@ -230,7 +231,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                if (log) {
                        (void) fprintf (shadow_logfd,
                                        "%s: cannot get lock %s: %s\n",
-                                       shadow_progname, lock, strerror (errno));
+                                       shadow_progname, lock, strerrno());
                }
        }
 
index 018d3be75700077897c9e05c482e3c120f640137..1933381ce37d537a6326cd068dee192fc8e10152 100644 (file)
@@ -41,6 +41,7 @@
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 
 
 static /*@null@*/const char *src_orig;
@@ -117,7 +118,7 @@ static void error_acl (MAYBE_UNUSED struct error_context *ctx, const char *fmt,
        if (vfprintf (shadow_logfd, fmt, ap) != 0) {
                (void) fputs (_(": "), shadow_logfd);
        }
-       (void) fprintf (shadow_logfd, "%s\n", strerror (errno));
+       (void) fprintf(shadow_logfd, "%s\n", strerrno());
        va_end (ap);
 }
 
index 93b6e4756073753c8b3d77c7c6fd7037399ea5dd..708908b5b4814a28f85c4e3d21a5c00461e70000 100644 (file)
@@ -8,13 +8,12 @@
 
 #include "config.h"
 
-#include <errno.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "shadowlog.h"
+#include "string/strerrno.h"
 
 
 /*
@@ -40,8 +39,7 @@ inline void
 exit_if_null_(void *p)
 {
        if (p == NULL) {
-               fprintf(log_get_logfd(), "%s: %s\n",
-                       log_get_progname(), strerror(errno));
+               fprintf(log_get_logfd(), "%s: %s\n", log_get_progname(), strerrno());
                exit(13);
        }
 }
index 5ee077abde073969f4ef48c9cdda72a97cd8d9b6..0d74945c106fb2f170600ac0ac59fb29de118223 100644 (file)
@@ -18,6 +18,8 @@
 #include "groupio.h"
 #include "getdef.h"
 #include "shadowlog.h"
+#include "string/strerrno.h"
+
 
 /*
  * get_ranges - Get the minimum and maximum ID ranges for the search
@@ -237,7 +239,7 @@ int find_new_gid (bool sys_group,
        if (NULL == used_gids) {
                fprintf (log_get_logfd(),
                         _("%s: failed to allocate memory: %s\n"),
-                        log_get_progname(), strerror (errno));
+                        log_get_progname(), strerrno());
                return -1;
        }
 
index c9a460b028b32797b2992c44d6034e6bb2617d20..4cce681316bf9e72eede36bdff3aa795ed677818 100644 (file)
@@ -18,6 +18,7 @@
 #include "pwio.h"
 #include "getdef.h"
 #include "shadowlog.h"
+#include "string/strerrno.h"
 
 /*
  * get_ranges - Get the minimum and maximum ID ranges for the search
@@ -237,7 +238,7 @@ int find_new_uid(bool sys_user,
        if (NULL == used_uids) {
                fprintf (log_get_logfd(),
                         _("%s: failed to allocate memory: %s\n"),
-                        log_get_progname(), strerror (errno));
+                        log_get_progname(), strerrno());
                return -1;
        }
 
index eca73a9b7196086fefe49827ab24d96bf9d9d988..7f80b16459fe4020191ae7df13492ecf9d82b1a7 100644 (file)
@@ -15,6 +15,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "string/sprintf/snprintf.h"
+#include "string/strerrno.h"
 
 
 /*
@@ -60,14 +61,14 @@ int open_pidfd(const char *pidstr)
 
        if (SNPRINTF(proc_dir_name, "/proc/%d/", target) == -1) {
                fprintf(stderr, "snprintf of proc path failed for %d: %s\n",
-                       target, strerror(errno));
+                       target, strerrno());
                return -EINVAL;
        }
 
        proc_dir_fd = open(proc_dir_name, O_DIRECTORY);
        if (proc_dir_fd < 0) {
                fprintf(stderr, _("Could not open proc directory for target %d: %s\n"),
-                       target, strerror(errno));
+                       target, strerrno());
                return -EINVAL;
        }
        return proc_dir_fd;
index 8b6b6ddf6f9c1bd3d4cc3f2d42042c005b06b8c4..0de0e7f78cb2d98a809ca7fa21e936b8f0e945d7 100644 (file)
@@ -15,6 +15,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "shadowlog.h"
+#include "string/strerrno.h"
 
 
 /*
@@ -40,7 +41,7 @@ gettime(void)
        if (a2i(time_t, &epoch, source_date_epoch, NULL, 10, 0, fallback) == -1) {
                fprintf(shadow_logfd,
                        _("Environment variable $SOURCE_DATE_EPOCH: a2i(\"%s\"): %s"),
-                       source_date_epoch, strerror(errno));
+                       source_date_epoch, strerrno());
                return fallback;
        }
        return epoch;
index 6f32c45e947a91e19abb00c739c6330effaf80ad..bd9dbd8a7a4a5e4ec4f10eff150d6aaeae492a1f 100644 (file)
@@ -28,6 +28,7 @@
 #include "sizeof.h"
 #include "string/sprintf/stpeprintf.h"
 #include "string/strcmp/streq.h"
+#include "string/strerrno.h"
 
 
 struct map_range *
@@ -196,17 +197,17 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
        fd = openat(proc_dir_fd, map_file, O_WRONLY);
        if (fd < 0) {
                fprintf(log_get_logfd(), _("%s: open of %s failed: %s\n"),
-                       log_get_progname(), map_file, strerror(errno));
+                       log_get_progname(), map_file, strerrno());
                exit(EXIT_FAILURE);
        }
        if (write_full(fd, buf, pos - buf) == -1) {
                fprintf(log_get_logfd(), _("%s: write to %s failed: %s\n"),
-                       log_get_progname(), map_file, strerror(errno));
+                       log_get_progname(), map_file, strerrno());
                exit(EXIT_FAILURE);
        }
        if (close(fd) != 0 && errno != EINTR) {
                fprintf(log_get_logfd(), _("%s: closing %s failed: %s\n"),
-                       log_get_progname(), map_file, strerror(errno));
+                       log_get_progname(), map_file, strerrno());
                exit(EXIT_FAILURE);
        }
        free(buf);
index d452d4c3114873976c1b3c2055c1993abbe33bdc..1f824a46ead497baaf23f42670d05b4ce9cde881 100644 (file)
@@ -34,6 +34,7 @@
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 
 
 static char *passwd_db_file = NULL;
@@ -96,7 +97,7 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                    || (setreuid (getuid (), getuid ()) != 0)) {
                        fprintf (log_get_logfd(),
                                 _("%s: failed to drop privileges (%s)\n"),
-                                log_get_progname(), strerror (errno));
+                                log_get_progname(), strerrno());
                        exit (EXIT_FAILURE);
                }
 
index 09b466ad4c9a7d72e74682f2f8784063b2eb7625..74ee98dd3b1be08cda9a46d5133c5ea827ab551e 100644 (file)
@@ -18,6 +18,7 @@
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 
 #include <assert.h>
 
@@ -77,7 +78,7 @@ static void change_root (const char* newroot)
        if (   (setregid (getgid (), getgid ()) != 0)
            || (setreuid (getuid (), getuid ()) != 0)) {
                fprintf (log_get_logfd(), _("%s: failed to drop privileges (%s)\n"),
-                        log_get_progname(), strerror (errno));
+                        log_get_progname(), strerrno());
                exit (EXIT_FAILURE);
        }
 
@@ -91,21 +92,21 @@ static void change_root (const char* newroot)
        if (access (newroot, F_OK) != 0) {
                fprintf(log_get_logfd(),
                        _("%s: cannot access chroot directory %s: %s\n"),
-                       log_get_progname(), newroot, strerror (errno));
+                       log_get_progname(), newroot, strerrno());
                exit (E_BAD_ARG);
        }
 
        if (chroot (newroot) != 0) {
                fprintf(log_get_logfd(),
                                _("%s: unable to chroot to directory %s: %s\n"),
-                               log_get_progname(), newroot, strerror (errno));
+                               log_get_progname(), newroot, strerrno());
                exit (E_BAD_ARG);
        }
 
        if (chdir ("/") != 0) {
                fprintf(log_get_logfd(),
                        _("%s: cannot chdir in chroot directory %s: %s\n"),
-                       log_get_progname(), newroot, strerror (errno));
+                       log_get_progname(), newroot, strerrno());
                exit (E_BAD_ARG);
        }
 }
index 9969109473c351f0f6b0804a6fb23a8a7a31c595..fb32825b908adfd9aff7129e3c2eec01d2b41db0 100644 (file)
@@ -14,6 +14,7 @@
 #include "run_part.h"
 #include "shadowlog_internal.h"
 #include "string/sprintf/aprintf.h"
+#include "string/strerrno.h"
 
 
 static int run_part(char *script_path, const char *name, const char *action)
@@ -25,14 +26,14 @@ static int run_part(char *script_path, const char *name, const char *action)
 
        pid=fork();
        if (pid==-1) {
-               fprintf(shadow_logfd, "fork: %s\n", strerror(errno));
+               fprintf(shadow_logfd, "fork: %s\n", strerrno());
                return 1;
        }
        if (pid==0) {
                setenv("ACTION",action,1);
                setenv("SUBJECT",name,1);
                execv(script_path,args);
-               fprintf(shadow_logfd, "execv: %s\n", strerror(errno));
+               fprintf(shadow_logfd, "execv: %s\n", strerrno());
                _exit(1);
        }
 
@@ -41,7 +42,7 @@ static int run_part(char *script_path, const char *name, const char *action)
                return (wait_status);
        }
 
-       fprintf(shadow_logfd, "waitpid: %s\n", strerror(errno));
+       fprintf(shadow_logfd, "waitpid: %s\n", strerrno());
        return (1);
 }
 
@@ -63,7 +64,7 @@ int run_parts(const char *directory, const char *name, const char *action)
 
                s = aprintf("%s/%s", directory, namelist[n]->d_name);
                if (s == NULL) {
-                       fprintf(shadow_logfd, "aprintf: %s\n", strerror(errno));
+                       fprintf(shadow_logfd, "aprintf: %s\n", strerrno());
                        for (; n<scanlist; n++) {
                                free(namelist[n]);
                        }
@@ -73,7 +74,7 @@ int run_parts(const char *directory, const char *name, const char *action)
 
                execute_result = 0;
                if (stat(s, &sb) == -1) {
-                       fprintf(shadow_logfd, "stat: %s\n", strerror(errno));
+                       fprintf(shadow_logfd, "stat: %s\n", strerrno());
                        free(s);
                        for (; n<scanlist; n++) {
                                free(namelist[n]);
index 741b5d5428d4e8caeaefbb212e7b7da1febe2af1..0f6ffaf721536e58b7df5c4995218151ebce5a44 100644 (file)
@@ -17,6 +17,7 @@
 #include "prototypes.h"
 #include "shadowlog_internal.h"
 #include "string/sprintf/aprintf.h"
+#include "string/strerrno.h"
 
 
 static bool selinux_checked = false;
@@ -192,10 +193,10 @@ int check_selinux_permit (const char *perm_name)
        if (getprevcon_raw (&user_context_raw) != 0) {
                fprintf (shadow_logfd,
                    _("%s: can not get previous SELinux process context: %s\n"),
-                   shadow_progname, strerror (errno));
+                   shadow_progname, strerrno());
                SYSLOG ((LOG_WARN,
                    "can not get previous SELinux process context: %s",
-                   strerror (errno)));
+                   strerrno()));
                return (security_getenforce () != 0);
        }
 
index 5138412ece7c5dbe014771a46512266ec45dac5c..2bcbc4451f0b59266e7cd55cfd8c7c570ff22e26 100644 (file)
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
+
 #include "exitcodes.h"
 #include "prototypes.h"
-
 #include "shadowlog_internal.h"
+#include "string/strerrno.h"
+
 
 int
 run_command(const char *cmd, const char *argv[],
@@ -38,11 +40,11 @@ run_command(const char *cmd, const char *argv[],
                        _exit (E_CMD_NOTFOUND);
                }
                fprintf (shadow_logfd, "%s: cannot execute %s: %s\n",
-                        shadow_progname, cmd, strerror (errno));
+                        shadow_progname, cmd, strerrno());
                _exit (E_CMD_NOEXEC);
        } else if ((pid_t)-1 == pid) {
                fprintf (shadow_logfd, "%s: cannot execute %s: %s\n",
-                        shadow_progname, cmd, strerror (errno));
+                        shadow_progname, cmd, strerrno());
                return -1;
        }
 
@@ -55,7 +57,7 @@ run_command(const char *cmd, const char *argv[],
 
        if ((pid_t)-1 == wpid) {
                fprintf (shadow_logfd, "%s: waitpid (status: %d): %s\n",
-                        shadow_progname, *status, strerror (errno));
+                        shadow_progname, *status, strerrno());
                return -1;
        }
 
index 2041d66a4da4ea5916be43d33d49915f081317e6..7a99a60ca6f8c8971bdf35a29f09df53e3becccb 100644 (file)
@@ -26,6 +26,7 @@
 #include "shadowlog_internal.h"
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
+#include "string/strerrno.h"
 
 
 #define SHADOWTCB_HASH_BY 1000
@@ -102,7 +103,7 @@ static /*@null@*/ char *shadowtcb_path_rel_existing (const char *name)
        if (lstat (path, &st) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot stat %s: %s\n"),
-                        shadow_progname, path, strerror (errno));
+                        shadow_progname, path, strerrno());
                free (path);
                return NULL;
        }
@@ -125,7 +126,7 @@ static /*@null@*/ char *shadowtcb_path_rel_existing (const char *name)
        if (READLINKNUL(path, link) == -1) {
                fprintf (shadow_logfd,
                         _("%s: Cannot read symbolic link %s: %s\n"),
-                        shadow_progname, path, strerror (errno));
+                        shadow_progname, path, strerrno());
                free (path);
                return NULL;
        }
@@ -186,7 +187,7 @@ static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
        if (stat (TCB_DIR, &st) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot stat %s: %s\n"),
-                        shadow_progname, TCB_DIR, strerror (errno));
+                        shadow_progname, TCB_DIR, strerrno());
                goto out_free_path;
        }
        while (NULL != (ind = strchr(ptr, '/'))) {
@@ -199,19 +200,19 @@ static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
                if ((mkdir (dir, 0700) != 0) && (errno != EEXIST)) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot create directory %s: %s\n"),
-                                shadow_progname, dir, strerror (errno));
+                                shadow_progname, dir, strerrno());
                        goto out_free_dir;
                }
                if (chown (dir, 0, st.st_gid) != 0) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot change owner of %s: %s\n"),
-                                shadow_progname, dir, strerror (errno));
+                                shadow_progname, dir, strerrno());
                        goto out_free_dir;
                }
                if (chmod (dir, 0711) != 0) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot change mode of %s: %s\n"),
-                                shadow_progname, dir, strerror (errno));
+                                shadow_progname, dir, strerrno());
                        goto out_free_dir;
                }
                free (dir);
@@ -242,7 +243,7 @@ static shadowtcb_status unlink_suffs (const char *user)
                if ((unlink (tmp) != 0) && (errno != ENOENT)) {
                        fprintf (shadow_logfd,
                                 _("%s: unlink: %s: %s\n"),
-                                shadow_progname, tmp, strerror (errno));
+                                shadow_progname, tmp, strerrno());
                        free (tmp);
                        return SHADOWTCB_FAILURE;
                }
@@ -268,7 +269,7 @@ static shadowtcb_status rmdir_leading (char *path)
                        if (errno != ENOTEMPTY) {
                                fprintf (shadow_logfd,
                                         _("%s: Cannot remove directory %s: %s\n"),
-                                        shadow_progname, dir, strerror (errno));
+                                        shadow_progname, dir, strerrno());
                                ret = SHADOWTCB_FAILURE;
                        }
                        free (dir);
@@ -298,7 +299,7 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
        if (stat (olddir, &oldmode) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot stat %s: %s\n"),
-                        shadow_progname, olddir, strerror (errno));
+                        shadow_progname, olddir, strerrno());
                goto out_free;
        }
        old_uid = oldmode.st_uid;
@@ -325,7 +326,7 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
        if (rename (real_old_dir, real_new_dir) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot rename %s to %s: %s\n"),
-                        shadow_progname, real_old_dir, real_new_dir, strerror (errno));
+                        shadow_progname, real_old_dir, real_new_dir, strerrno());
                goto out_free;
        }
        if (rmdir_leading (real_old_dir_rel) == SHADOWTCB_FAILURE) {
@@ -334,7 +335,7 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
        if ((unlink (olddir) != 0) && (errno != ENOENT)) {
                fprintf (shadow_logfd,
                         _("%s: Cannot remove %s: %s\n"),
-                        shadow_progname, olddir, strerror (errno));
+                        shadow_progname, olddir, strerrno());
                goto out_free;
        }
        newdir = aprintf(TCB_DIR "/%s", user_newname);
@@ -349,7 +350,7 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
            && (symlink (real_new_dir_rel, newdir) != 0)) {
                fprintf (shadow_logfd,
                         _("%s: Cannot create symbolic link %s: %s\n"),
-                        shadow_progname, real_new_dir_rel, strerror (errno));
+                        shadow_progname, real_new_dir_rel, strerrno());
                goto out_free;
        }
        ret = SHADOWTCB_SUCCESS;
@@ -453,26 +454,26 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
        if (stat (tcbdir, &dirmode) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot stat %s: %s\n"),
-                        shadow_progname, tcbdir, strerror (errno));
+                        shadow_progname, tcbdir, strerrno());
                goto out_free;
        }
        if (chown (tcbdir, 0, 0) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change owners of %s: %s\n"),
-                        shadow_progname, tcbdir, strerror (errno));
+                        shadow_progname, tcbdir, strerrno());
                goto out_free;
        }
        if (chmod (tcbdir, 0700) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change mode of %s: %s\n"),
-                        shadow_progname, tcbdir, strerror (errno));
+                        shadow_progname, tcbdir, strerrno());
                goto out_free;
        }
        if (lstat (shadow, &filemode) != 0) {
                if (errno != ENOENT) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot lstat %s: %s\n"),
-                                shadow_progname, shadow, strerror (errno));
+                                shadow_progname, shadow, strerrno());
                        goto out_free;
                }
                fprintf (shadow_logfd,
@@ -491,13 +492,13 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
                if (chown (shadow, user_newid, filemode.st_gid) != 0) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot change owner of %s: %s\n"),
-                                shadow_progname, shadow, strerror (errno));
+                                shadow_progname, shadow, strerrno());
                        goto out_free;
                }
                if (chmod (shadow, filemode.st_mode & 07777) != 0) {
                        fprintf (shadow_logfd,
                                 _("%s: Cannot change mode of %s: %s\n"),
-                                shadow_progname, shadow, strerror (errno));
+                                shadow_progname, shadow, strerrno());
                        goto out_free;
                }
        }
@@ -507,13 +508,13 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
        if (chown (tcbdir, user_newid, dirmode.st_gid) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change owner of %s: %s\n"),
-                        shadow_progname, tcbdir, strerror (errno));
+                        shadow_progname, tcbdir, strerrno());
                goto out_free;
        }
        if (chmod (tcbdir, dirmode.st_mode & 07777) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change mode of %s: %s\n"),
-                        shadow_progname, tcbdir, strerror (errno));
+                        shadow_progname, tcbdir, strerrno());
                goto out_free;
        }
        ret = SHADOWTCB_SUCCESS;
@@ -538,7 +539,7 @@ shadowtcb_status shadowtcb_create (const char *name, uid_t uid)
        if (stat (TCB_DIR, &tcbdir_stat) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot stat %s: %s\n"),
-                        shadow_progname, TCB_DIR, strerror (errno));
+                        shadow_progname, TCB_DIR, strerrno());
                return SHADOWTCB_FAILURE;
        }
        shadowgid = tcbdir_stat.st_gid;
@@ -562,39 +563,38 @@ shadowtcb_status shadowtcb_create (const char *name, uid_t uid)
        }
        if (mkdir (dir, 0700) != 0) {
                fprintf (shadow_logfd,
-                        _("%s: mkdir: %s: %s\n"),
-                        shadow_progname, dir, strerror (errno));
+                        _("%s: mkdir: %s: %s\n"), shadow_progname, dir, strerrno());
                goto out_free;
        }
        fd = open (shadow, O_RDWR | O_CREAT | O_TRUNC, 0600);
        if (fd < 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot open %s: %s\n"),
-                        shadow_progname, shadow, strerror (errno));
+                        shadow_progname, shadow, strerrno());
                goto out_free;
        }
        if (fchown (fd, 0, authgid) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change owner of %s: %s\n"),
-                        shadow_progname, shadow, strerror (errno));
+                        shadow_progname, shadow, strerrno());
                goto out_free;
        }
        if (fchmod (fd, (mode_t) ((authgid == shadowgid) ? 0600 : 0640)) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change mode of %s: %s\n"),
-                        shadow_progname, shadow, strerror (errno));
+                        shadow_progname, shadow, strerrno());
                goto out_free;
        }
        if (chown (dir, 0, authgid) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change owner of %s: %s\n"),
-                        shadow_progname, dir, strerror (errno));
+                        shadow_progname, dir, strerrno());
                goto out_free;
        }
        if (chmod (dir, (mode_t) ((authgid == shadowgid) ? 02700 : 02710)) != 0) {
                fprintf (shadow_logfd,
                         _("%s: Cannot change mode of %s: %s\n"),
-                        shadow_progname, dir, strerror (errno));
+                        shadow_progname, dir, strerrno());
                goto out_free;
        }
        if (   (shadowtcb_set_user (name) == SHADOWTCB_FAILURE)
index 693bad86ce6073c2054ac4bff5198817bc3789e4..1cc0c68246d07553d19fc4f63df4f5eae7eee50d 100644 (file)
@@ -33,6 +33,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "string/strftime.h"
 #include "time/day_to_str.h"
 /*@-exitarg@*/
@@ -780,7 +781,7 @@ int main (int argc, char **argv)
        if (lflg && (   (setregid (rgid, rgid) != 0)
                     || (setreuid (ruid, ruid) != 0))) {
                fprintf (stderr, _("%s: failed to drop privileges (%s)\n"),
-                        Prog, strerror (errno));
+                        Prog, strerrno());
                fail_exit (E_NOPERM, process_selinux);
        }
 
index 52345d39c5a7d812481a54337b49b24cd5d070b4..577ae8b750d2ca89f00baa36c6efdf1df26c4e2a 100644 (file)
@@ -37,6 +37,7 @@
 #include "shadow/gshadow/sgrp.h"
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 /*
@@ -536,7 +537,7 @@ int main (int argc, char **argv)
                        if (NULL == cp) {
                                fprintf (stderr,
                                         _("%s: failed to crypt password with salt '%s': %s\n"),
-                                        Prog, salt, strerror (errno));
+                                       Prog, salt, strerrno());
                                fail_exit (1, process_selinux);
                        }
                }
index 91da42d0abd8170245a0e80a8a1720dd6a641e11..e1805e3297ada2a2809bcfc4ebccdeb6282752d9 100644 (file)
@@ -35,6 +35,7 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -597,7 +598,7 @@ int main (int argc, char **argv)
                        if (NULL == cp) {
                                fprintf (stderr,
                                         _("%s: failed to crypt password with salt '%s': %s\n"),
-                                        Prog, salt, strerror (errno));
+                                       Prog, salt, strerrno());
                                fail_exit (1, process_selinux);
                        }
                }
index 47ee2614947d91fe60efb4022da762675f4ee7e8..2800e93e3594ec9b08fa8c2c8a2d78dbe4fb600f 100644 (file)
@@ -27,6 +27,7 @@
 #include "exitcodes.h"
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
+#include "string/strerrno.h"
 #include "string/strftime.h"
 
 
@@ -638,7 +639,7 @@ int main (int argc, char **argv)
        if (NULL == fail) {
                fprintf (stderr,
                         _("%s: Cannot open %s: %s\n"),
-                        Prog, FAILLOG_FILE, strerror (errno));
+                       Prog, FAILLOG_FILE, strerrno());
                exit (E_NOPERM);
        }
 
@@ -646,7 +647,7 @@ int main (int argc, char **argv)
        if (fstat (fileno (fail), &statbuf) != 0) {
                fprintf (stderr,
                         _("%s: Cannot get the size of %s: %s\n"),
-                        Prog, FAILLOG_FILE, strerror (errno));
+                       Prog, FAILLOG_FILE, strerrno());
                exit (E_NOPERM);
        }
 
@@ -673,7 +674,7 @@ int main (int argc, char **argv)
                    || (fclose (fail) != 0)) {
                        fprintf (stderr,
                                 _("%s: Failed to write %s: %s\n"),
-                                Prog, FAILLOG_FILE, strerror (errno));
+                               Prog, FAILLOG_FILE, strerrno());
                        (void) fclose (fail);
                        errors = true;
                }
index 4baa9a3aae03fd8e241a19e8a1ba4c194bff3b7e..42ac0ff3976af65df6cac39eb3bf1aa0b925fbe4 100644 (file)
@@ -40,6 +40,8 @@
 #include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
+
 
 struct option_flags {
        bool chroot;
@@ -852,7 +854,7 @@ static void change_passwd (struct group *gr)
        if (NULL == cp) {
                fprintf (stderr,
                         _("%s: failed to crypt password with salt '%s': %s\n"),
-                        Prog, salt, strerror (errno));
+                       Prog, salt, strerrno());
                exit (1);
        }
 #ifdef SHADOWGRP
index 0fe28ded353de2e284acb070a7cbf883b1951191..af8109dffaa062f5deb49bc96cc8278a75f121f3 100644 (file)
@@ -40,6 +40,7 @@
 #include "shadow/gshadow/sgrp.h"
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -374,8 +375,8 @@ static void open_files (struct option_flags *flags)
 
        /* And now open the databases */
        if (gr_open (O_CREAT | O_RDWR) == 0) {
-               fprintf (stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname (), strerror(errno));
-               SYSLOG ((LOG_WARN, "cannot open %s: %s", gr_dbname (), strerror(errno)));
+               fprintf(stderr, _("%s: cannot open %s: %s\n"), Prog, gr_dbname(), strerrno());
+               SYSLOG((LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno()));
                fail_exit (E_GRP_UPDATE);
        }
 
@@ -384,8 +385,8 @@ static void open_files (struct option_flags *flags)
                if (sgr_open (O_CREAT | O_RDWR) == 0) {
                        fprintf (stderr,
                                 _("%s: cannot open %s: %s\n"),
-                                Prog, sgr_dbname (), strerror(errno));
-                       SYSLOG ((LOG_WARN, "cannot open %s: %s", sgr_dbname (), strerror(errno)));
+                                Prog, sgr_dbname(), strerrno());
+                       SYSLOG((LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno()));
                        fail_exit (E_GRP_UPDATE);
                }
        }
index 0f8793c521b7d3a4b2cd3e9c1cdddaee849e50b4..e513936c745acbbdb230e078a82bd1f0009d1629 100644 (file)
@@ -33,6 +33,7 @@
 #include "shadowlog.h"
 #include "sizeof.h"
 #include "string/memset/memzero.h"
+#include "string/strerrno.h"
 #include "string/strftime.h"
 
 
@@ -436,7 +437,7 @@ int main (int argc, char **argv)
        if (fstat (fileno (lastlogfile), &statbuf) != 0) {
                fprintf (stderr,
                         _("%s: Cannot get the size of %s: %s\n"),
-                        Prog, _PATH_LASTLOG, strerror(errno));
+                       Prog, _PATH_LASTLOG, strerrno());
                exit (EXIT_FAILURE);
        }
 
index 8b531534635223f183b8b94922b4b2bd48276b78..9f193b0044290f69f5f531a0a381ae896836d29f 100644 (file)
@@ -46,6 +46,7 @@
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "string/strftime.h"
 
 
@@ -1088,8 +1089,7 @@ int main (int argc, char **argv)
        child = fork ();
        if (child < 0) {
                /* error in fork() */
-               fprintf (stderr, _("%s: failure forking: %s"),
-                        Prog, strerror (errno));
+               fprintf(stderr, _("%s: failure forking: %s"), Prog, strerrno());
                PAM_END;
                exit (0);
        } else if (child != 0) {
index a8fb630c3609f72adc96d7e837f409a15ebc2eae..9d130a7d3efeff8a8f5867cff87b4f4868c504ac 100644 (file)
@@ -20,6 +20,7 @@
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 #include "subordinateio.h"
 
 
@@ -103,8 +104,7 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
                        goto out;
                }
                fprintf(stderr, _("%s: couldn't open process setgroups: %s\n"),
-                       Prog,
-                       strerror(errno));
+                       Prog, strerrno());
                exit(EXIT_FAILURE);
        }
 
@@ -115,8 +115,7 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
         */
        if (read(setgroups_fd, policy_buffer, sizeof(policy_buffer)) < 0) {
                fprintf(stderr, _("%s: failed to read setgroups: %s\n"),
-                       Prog,
-                       strerror(errno));
+                       Prog, strerrno());
                exit(EXIT_FAILURE);
        }
        if (strprefix(policy_buffer, policy))
@@ -125,15 +124,12 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
        /* Write the policy. */
        if (lseek(setgroups_fd, 0, SEEK_SET) < 0) {
                fprintf(stderr, _("%s: failed to seek setgroups: %s\n"),
-                       Prog,
-                       strerror(errno));
+                       Prog, strerrno());
                exit(EXIT_FAILURE);
        }
        if (dprintf(setgroups_fd, "%s", policy) < 0) {
                fprintf(stderr, _("%s: failed to setgroups %s policy: %s\n"),
-                       Prog,
-                       policy,
-                       strerror(errno));
+                       Prog, policy, strerrno());
                exit(EXIT_FAILURE);
        }
 
@@ -195,7 +191,7 @@ int main(int argc, char **argv)
        if (fstat(proc_dir_fd, &st) < 0) {
                fprintf(stderr,
                        _("%s: Could not stat directory for target process: %s\n"),
-                       Prog, strerror (errno));
+                       Prog, strerrno());
                return EXIT_FAILURE;
        }
 
@@ -217,7 +213,7 @@ int main(int argc, char **argv)
        if (want_subgid_file() && !sub_gid_open(O_RDONLY)) {
                fprintf (stderr,
                         _("%s: cannot open %s: %s\n"),
-                        Prog, sub_gid_dbname (), strerror (errno));
+                        Prog, sub_gid_dbname(), strerrno());
                return EXIT_FAILURE;
        }
 
index 123f1b285057a3f6a8e8b8e7125fd2f3325659f9..66f4e9cbaf5799fb5f0b0629e8aef4c27ea485ba 100644 (file)
@@ -36,6 +36,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 
 #include <assert.h>
 
@@ -188,7 +189,7 @@ static void check_perms (const struct group *grp,
                if (NULL == cpasswd) {
                        fprintf (stderr,
                                 _("%s: failed to crypt password with previous salt: %s\n"),
-                                Prog, strerror (errno));
+                               Prog, strerrno());
                        SYSLOG ((LOG_INFO,
                                 "Failed to crypt password with previous salt of group '%s'",
                                 groupname));
@@ -295,7 +296,7 @@ static void syslog_sg (const char *name, const char *group)
                if ((pid_t)-1 == child) {
                        /* error in fork() */
                        fprintf (stderr, _("%s: failure forking: %s\n"),
-                                is_newgrp ? "newgrp" : "sg", strerror (errno));
+                               is_newgrp ? "newgrp" : "sg", strerrno());
 #ifdef WITH_AUDIT
                        if (group) {
                                audit_logger_with_group(AUDIT_CHGRP_ID, "changing", NULL,
index d9c3b4bafcc17e6d1fb1e7210244d923ec12ca0c..43826b1d00573a122ac7c368f172004a083fcfa7 100644 (file)
@@ -20,6 +20,7 @@
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/strcmp/strprefix.h"
+#include "string/strerrno.h"
 #include "subordinateio.h"
 
 
@@ -124,7 +125,7 @@ int main(int argc, char **argv)
        if (fstat(proc_dir_fd, &st) < 0) {
                fprintf(stderr,
                        _("%s: Could not stat directory for target process: %s\n"),
-                       Prog, strerror (errno));
+                       Prog, strerrno());
                return EXIT_FAILURE;
        }
 
@@ -146,7 +147,7 @@ int main(int argc, char **argv)
        if (want_subuid_file() && !sub_uid_open(O_RDONLY)) {
                fprintf (stderr,
                         _("%s: cannot open %s: %s\n"),
-                        Prog, sub_uid_dbname (), strerror (errno));
+                       Prog, sub_uid_dbname(), strerrno());
                return EXIT_FAILURE;
        }
 
index a7ab4a981e7eca6af280281c7c1442eb0e38269d..3f260584d99d60f9bcaeadb738fa7ca0d37ed772 100644 (file)
@@ -58,6 +58,7 @@
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 #include "string/strtok/strsep2arr.h"
 
@@ -467,7 +468,7 @@ static int update_passwd (struct passwd *pwd, const char *password)
                if (NULL == cp) {
                        fprintf (stderr,
                                 _("%s: failed to crypt password with salt '%s': %s\n"),
-                                Prog, salt, strerror (errno));
+                               Prog, salt, strerrno());
                        return 1;
                }
                pwd->pw_passwd = cp;
@@ -545,7 +546,7 @@ static int add_passwd (struct passwd *pwd, const char *password)
                        if (NULL == cp) {
                                fprintf (stderr,
                                         _("%s: failed to crypt password with salt '%s': %s\n"),
-                                        Prog, salt, strerror (errno));
+                                       Prog, salt, strerrno());
                                return 1;
                        }
                        spent.sp_pwdp = cp;
@@ -595,7 +596,7 @@ static int add_passwd (struct passwd *pwd, const char *password)
                if (NULL == cp) {
                        fprintf (stderr,
                                 _("%s: failed to crypt password with salt '%s': %s\n"),
-                                Prog, salt, strerror (errno));
+                               Prog, salt, strerrno());
                        return 1;
                }
                spent.sp_pwdp = cp;
@@ -1196,9 +1197,7 @@ int main (int argc, char **argv)
                usernames = REALLOCF(usernames, nusers, char *);
                passwords = REALLOCF(passwords, nusers, char *);
                if (lines == NULL || usernames == NULL || passwords == NULL) {
-                       fprintf (stderr,
-                                _("%s: line %jd: %s\n"),
-                                Prog, line, strerror(errno));
+                       fprintf(stderr, _("%s: line %jd: %s\n"), Prog, line, strerrno());
                        fail_exit (EXIT_FAILURE, process_selinux);
                }
                lines[nusers-1]     = line;
@@ -1237,8 +1236,7 @@ int main (int argc, char **argv)
                        if (mkdir (newpw.pw_dir, mode) != 0) {
                                fprintf (stderr,
                                         _("%s: line %jd: mkdir %s failed: %s\n"),
-                                        Prog, line, newpw.pw_dir,
-                                        strerror (errno));
+                                       Prog, line, newpw.pw_dir, strerrno());
                                if (errno != EEXIST) {
                                        fail_exit (EXIT_FAILURE, process_selinux);
                                }
@@ -1247,8 +1245,7 @@ int main (int argc, char **argv)
                        {
                                fprintf (stderr,
                                         _("%s: line %jd: chown %s failed: %s\n"),
-                                        Prog, line, newpw.pw_dir,
-                                        strerror (errno));
+                                       Prog, line, newpw.pw_dir, strerrno());
                                fail_exit (EXIT_FAILURE, process_selinux);
                        }
                }
index a29f9640b2f8e5b9332fca35f81cdf0f6c12f029..f51cf48d60fe96f3dac310751f73f3ccf53de7ad 100644 (file)
@@ -38,6 +38,7 @@
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "time/day_to_str.h"
 
 
@@ -214,7 +215,7 @@ static int new_password (const struct passwd *pw)
                        erase_pass (clear);
                        fprintf (stderr,
                                 _("%s: failed to crypt password with previous salt: %s\n"),
-                                Prog, strerror (errno));
+                                Prog, strerrno());
                        SYSLOG ((LOG_INFO,
                                 "Failed to crypt password with previous salt of user '%s'",
                                 pw->pw_name));
@@ -368,7 +369,7 @@ static int new_password (const struct passwd *pw)
        if (NULL == cp) {
                fprintf (stderr,
                         _("%s: failed to crypt password with salt '%s': %s\n"),
-                        Prog, salt, strerror (errno));
+                        Prog, salt, strerrno());
                return -1;
        }
 
index a4dd3638aabfb40b8d019e39fbdde11caa9d5d7d..0d26a0bcbf8adc23b7e38724cbe54da45e8f7694 100644 (file)
@@ -74,6 +74,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -534,7 +535,7 @@ set_defaults(void)
        new_file = aprintf("%s%s%s", prefix, prefix[0]?"/":"", NEW_USER_FILE);
        if (new_file == NULL) {
                fprintf(stderr, _("%s: cannot create new defaults file: %s\n"),
-                       Prog, strerror(errno));
+                       Prog, strerrno());
                return -1;
         }
 
@@ -543,7 +544,7 @@ set_defaults(void)
                if (default_file == NULL) {
                        fprintf(stderr,
                                _("%s: cannot create new defaults file: %s\n"),
-                               Prog, strerror(errno));
+                               Prog, strerrno());
                        goto err_free_new;
                }
        }
@@ -693,10 +694,9 @@ set_defaults(void)
        assert(SNPRINTF(buf, "%s-", default_file) != -1);
        unlink (buf);
        if ((link (default_file, buf) != 0) && (ENOENT != errno)) {
-               int err = errno;
                fprintf (stderr,
                         _("%s: Cannot create backup file (%s): %s\n"),
-                        Prog, buf, strerror (err));
+                        Prog, buf, strerrno());
                unlink (new_file);
                goto err_free_def;
        }
@@ -705,10 +705,9 @@ set_defaults(void)
         * Rename the new default file to its correct name.
         */
        if (rename (new_file, default_file) != 0) {
-               int err = errno;
                fprintf (stderr,
                         _("%s: rename: %s: %s\n"),
-                        Prog, new_file, strerror (err));
+                        Prog, new_file, strerrno());
                goto err_free_def;
        }
 #ifdef WITH_AUDIT
@@ -1969,7 +1968,7 @@ static void faillog_reset (uid_t uid)
        if (-1 == fd) {
                fprintf (stderr,
                         _("%s: failed to open the faillog file for UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to open the faillog file for UID %lu", (unsigned long) uid));
                return;
        }
@@ -1978,13 +1977,13 @@ static void faillog_reset (uid_t uid)
            || (fsync (fd) != 0)) {
                fprintf (stderr,
                         _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to reset the faillog entry of UID %lu", (unsigned long) uid));
        }
        if (close (fd) != 0 && errno != EINTR) {
                fprintf (stderr,
                         _("%s: failed to close the faillog file for UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to close the faillog file for UID %lu", (unsigned long) uid));
        }
 }
@@ -2014,7 +2013,7 @@ static void lastlog_reset (uid_t uid)
        if (-1 == fd) {
                fprintf (stderr,
                         _("%s: failed to open the lastlog file for UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to open the lastlog file for UID %lu", (unsigned long) uid));
                return;
        }
@@ -2023,14 +2022,14 @@ static void lastlog_reset (uid_t uid)
            || (fsync (fd) != 0)) {
                fprintf (stderr,
                         _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to reset the lastlog entry of UID %lu", (unsigned long) uid));
                /* continue */
        }
        if (close (fd) != 0 && errno != EINTR) {
                fprintf (stderr,
                         _("%s: failed to close the lastlog file for UID %lu: %s\n"),
-                        Prog, (unsigned long) uid, strerror (errno));
+                       Prog, (unsigned long) uid, strerrno());
                SYSLOG ((LOG_WARN, "failed to close the lastlog file for UID %lu", (unsigned long) uid));
                /* continue */
        }
index ae8cb61a369b641b10226b8981afd7c19a6a8af8..474977247bcd008c8f96d3075263620d520c01db 100644 (file)
@@ -56,6 +56,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 
 
 /*
@@ -777,8 +778,8 @@ static bool remove_mailbox (void)
                } else {
                        fprintf (stderr,
                                 _("%s: warning: can't remove %s: %s\n"),
-                                Prog, mailfile, strerror (errno));
-                       SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
+                               Prog, mailfile, strerrno());
+                       SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
                                      "delete-mail-file",
@@ -793,8 +794,8 @@ static bool remove_mailbox (void)
                if (unlink (mailfile) != 0) {
                        fprintf (stderr,
                                 _("%s: warning: can't remove %s: %s\n"),
-                                Prog, mailfile, strerror (errno));
-                       SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
+                               Prog, mailfile, strerrno());
+                       SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER, Prog,
                                      "delete-mail-file",
@@ -819,9 +820,7 @@ static bool remove_mailbox (void)
                fprintf (stderr,
                         _("%s: %s not owned by %s, not removing\n"),
                         Prog, mailfile, user_name);
-               SYSLOG ((LOG_ERR,
-                        "%s not owned by %s, not removed",
-                        mailfile, strerror (errno)));
+               SYSLOG((LOG_ERR, "%s not owned by %s, not removed", mailfile, strerrno()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_DEL_USER, Prog,
                              "delete-mail-file",
@@ -836,8 +835,8 @@ static bool remove_mailbox (void)
        if (unlink (mailfile) != 0) {
                fprintf (stderr,
                         _("%s: warning: can't remove %s: %s\n"),
-                        Prog, mailfile, strerror (errno));
-               SYSLOG ((LOG_ERR, "Cannot remove %s: %s", mailfile, strerror (errno)));
+                        Prog, mailfile, strerrno());
+               SYSLOG((LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno()));
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_DEL_USER, Prog,
                              "delete-mail-file",
@@ -877,7 +876,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
        }
        if (shadowtcb_drop_priv () == SHADOWTCB_FAILURE) {
                fprintf (stderr, _("%s: Cannot drop privileges: %s\n"),
-                        Prog, strerror (errno));
+                        Prog, strerrno());
                shadowtcb_gain_priv ();
                free (buf);
                return 1;
@@ -887,7 +886,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
         */
        if (remove_tree (buf, false) != 0) {
                fprintf (stderr, _("%s: Cannot remove the content of %s: %s\n"),
-                        Prog, buf, strerror (errno));
+                       Prog, buf, strerrno());
                shadowtcb_gain_priv ();
                free (buf);
                return 1;
@@ -896,7 +895,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
        free (buf);
        if (shadowtcb_remove (user_name) == SHADOWTCB_FAILURE) {
                fprintf (stderr, _("%s: Cannot remove tcb files for %s: %s\n"),
-                        Prog, user_name, strerror (errno));
+                       Prog, user_name, strerrno());
                ret = 1;
        }
        return ret;
index 414ff7b56d0317ce463c04be1b83d6d4615189e8..fc1a8361ef8eb0ff47911ebe94451f15527d4f5b 100644 (file)
@@ -68,6 +68,7 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
+#include "string/strerrno.h"
 #include "time/day_to_str.h"
 #include "typetraits.h"
 
@@ -368,7 +369,7 @@ prepend_range(const char *str, struct id_range_list_entry **head)
        if (!entry) {
                fprintf (stderr,
                        _("%s: failed to allocate memory: %s\n"),
-                       Prog, strerror (errno));
+                       Prog, strerrno());
                return 0;
        }
        entry->next = *head;
@@ -1917,7 +1918,7 @@ static void update_lastlog (void)
        if (-1 == fd) {
                fprintf (stderr,
                         _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
-                        Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                       Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                return;
        }
 
@@ -1929,7 +1930,7 @@ static void update_lastlog (void)
                    || (fsync (fd) != 0)) {
                        fprintf (stderr,
                                 _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
-                                Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                               Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                }
        } else {
                /* Assume lseek or read failed because there is
@@ -1945,7 +1946,7 @@ static void update_lastlog (void)
                            || (fsync (fd) != 0)) {
                                fprintf (stderr,
                                         _("%s: failed to copy the lastlog entry of user %lu to user %lu: %s\n"),
-                                        Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                                       Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                        }
                }
        }
@@ -1953,7 +1954,7 @@ static void update_lastlog (void)
        if (close (fd) != 0 && errno != EINTR) {
                fprintf (stderr,
                         _("%s: failed to copy the lastlog entry of user %ju to user %ju: %s\n"),
-                        Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerror (errno));
+                       Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerrno());
        }
 }
 #endif /* ENABLE_LASTLOG */
@@ -1981,7 +1982,7 @@ static void update_faillog (void)
        if (-1 == fd) {
                fprintf (stderr,
                         _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
-                        Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                       Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                return;
        }
 
@@ -1993,7 +1994,7 @@ static void update_faillog (void)
                    || (fsync (fd) != 0)) {
                        fprintf (stderr,
                                 _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
-                                Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                               Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                }
        } else {
                /* Assume lseek or read failed because there is
@@ -2009,7 +2010,7 @@ static void update_faillog (void)
                        {
                                fprintf (stderr,
                                         _("%s: failed to copy the faillog entry of user %lu to user %lu: %s\n"),
-                                        Prog, (unsigned long) user_id, (unsigned long) user_newid, strerror (errno));
+                                       Prog, (unsigned long) user_id, (unsigned long) user_newid, strerrno());
                        }
                }
        }
@@ -2017,7 +2018,7 @@ static void update_faillog (void)
        if (close (fd) != 0 && errno != EINTR) {
                fprintf (stderr,
                         _("%s: failed to copy the faillog entry of user %ju to user %ju: %s\n"),
-                        Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerror (errno));
+                       Prog, (uintmax_t) user_id, (uintmax_t) user_newid, strerrno());
        }
 }
 
index 29fa55a87f8af1001e25fa24012b815645adec4c..83ff3d92bbe2b74832882adf326407c4fe93e44f 100644 (file)
@@ -46,6 +46,7 @@
 #include "string/sprintf/aprintf.h"
 #include "string/sprintf/snprintf.h"
 #include "string/strcmp/streq.h"
+#include "string/strerrno.h"
 
 
 #define MSG_WARN_EDIT_OTHER_FILE _( \
@@ -310,8 +311,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
 
                status = system (buf);
                if (-1 == status) {
-                       fprintf (stderr, _("%s: %s: %s\n"), Prog, editor,
-                                strerror (errno));
+                       fprintf(stderr, _("%s: %s: %s\n"), Prog, editor, strerrno());
                        exit (1);
                } else if (   WIFEXITED (status)
                           && (WEXITSTATUS (status) != 0)) {
@@ -350,11 +350,11 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
                                editor_pgrp = tcgetpgrp(STDIN_FILENO);
                                if (editor_pgrp == -1) {
                                        fprintf (stderr, "%s: %s: %s", Prog,
-                                                "tcgetpgrp", strerror (errno));
+                                               "tcgetpgrp", strerrno());
                                }
                                if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
                                        fprintf (stderr, "%s: %s: %s", Prog,
-                                                "tcsetpgrp", strerror (errno));
+                                               "tcsetpgrp", strerrno());
                                }
                        }
                        kill (getpid (), SIGSTOP);
@@ -362,7 +362,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
                        if (editor_pgrp != -1) {
                                if (tcsetpgrp(STDIN_FILENO, editor_pgrp) == -1) {
                                        fprintf (stderr, "%s: %s: %s", Prog,
-                                                "tcsetpgrp", strerror (errno));
+                                               "tcsetpgrp", strerrno());
                                }
                        }
                        killpg (pid, SIGCONT);
@@ -374,8 +374,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
        if (orig_pgrp != -1) {
                 /* Restore terminal pgrp after editing. */
                if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
-                       fprintf(stderr, "%s: %s: %s", Prog,
-                               "tcsetpgrp", strerror(errno));
+                       fprintf(stderr, "%s: %s: %s", Prog, "tcsetpgrp", strerrno());
                }
                sigprocmask(SIG_SETMASK, &omask, NULL);
        }
@@ -447,7 +446,7 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
        if (rename (to_rename, file) == -1) {
                fprintf (stderr,
                         _("%s: can't restore %s: %s (your changes are in %s)\n"),
-                        Prog, file, strerror (errno), to_rename);
+                       Prog, file, strerrno(), to_rename);
 #ifdef WITH_TCB
                if (tcb_mode) {
                        free(to_rename);