]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/, tests/: Use fprinte() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Wed, 23 Jul 2025 15:39:19 +0000 (17:39 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 17 Jul 2026 13:48:04 +0000 (08:48 -0500)
While we don't use it directly in tests/, exit_if_null_() uses it, so we
need to link to it in its test.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
36 files changed:
lib/addgrps.c
lib/chowntty.c
lib/commonio.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/free_subid_range.c
src/get_subid_owners.c
src/getsubids.c
src/gpasswd.c
src/groupadd.c
src/lastlog.c
src/login.c
src/new_subid_range.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 a8fbbb508f2a640bb3d8d078135cd48eefeb5012..7413ef9116ecc8c9b4632304690df212140b52f1 100644 (file)
 #include <sys/types.h>
 
 #include "alloc/reallocf.h"
+#include "io/fprintf.h"
 #include "search/l/lsearch.h"
 #include "shadow/grp/agetgroups.h"
 #include "shadowlog.h"
 #include "string/strchr/strchrscnt.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 
 
 /*
@@ -71,7 +71,7 @@ add_groups(const char *list)
        free(dup);
 
        if (setgroups(n, gids) == -1) {
-               fprintf(log_get_logfd(), "setgroups: %s\n", strerrno());
+               fprinte(log_get_logfd(), "setgroups");
                goto free_gids;
        }
 
index 64f63d706d39500f32bb10e4c0844c180a2ef1fe..dc29203eedcba20e2faf77a382c1303b2af8d6bf 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 #include <grp.h>
-#include "prototypes.h"
-#include "defines.h"
 #include <pwd.h>
+
+#include "defines.h"
 #include "getdef.h"
+#include "io/fprintf.h"
+#include "prototypes.h"
 #include "shadowlog.h"
 
 /*
@@ -54,9 +56,7 @@ void chown_tty (const struct passwd *info)
            || (fchmod (STDIN_FILENO, getdef_num ("TTYPERM", 0600)) != 0)) {
                int err = errno;
 
-               fprintf (log_get_logfd(),
-                        _("Unable to change owner or mode of tty stdin: %s"),
-                        strerror (err));
+               fprinte(log_get_logfd(), _("Unable to change owner or mode of tty stdin"));
                SYSLOG(LOG_WARN,
                       "unable to change owner or mode of tty stdin for user `%s': %s\n",
                       info->pw_name, strerror(err));
index b2038831837be022bf5bcc008ebadbd07c9c3bda..da530ef2221ae5d60103cc940c438ff10ab8b665 100644 (file)
@@ -25,6 +25,7 @@
 #include "commonio.h"
 #include "defines.h"
 #include "fs/mkstemp/fmkomstemp.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #ifdef WITH_TCB
 #include <tcb.h>
@@ -37,7 +38,6 @@
 #include "string/sprintf/stprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 #undef NDEBUG
@@ -74,9 +74,8 @@ static int check_link_count (const char *file, bool log)
 
        if (stat (file, &sb) != 0) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: %s file stat error: %s\n",
-                                       log_get_progname(), file, strerrno());
+                       fprinte(log_get_logfd(), "%s: %s file stat error",
+                               log_get_progname(), file);
                }
                return 0;
        }
@@ -105,9 +104,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        fd = open (file, O_CREAT | O_TRUNC | O_WRONLY, 0600);
        if (-1 == fd) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: %s: %s\n",
-                                       log_get_progname(), file, strerrno());
+                       fprinte(log_get_logfd(), "%s: %s", log_get_progname(), file);
                }
                return 0;
        }
@@ -117,9 +114,8 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        len = (ssize_t) strlen (buf) + 1;
        if (write_full(fd, buf, len) == -1) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: %s file write error: %s\n",
-                                       log_get_progname(), file, strerrno());
+                       fprinte(log_get_logfd(), "%s: %s file write error",
+                               log_get_progname(), file);
                }
                (void) close (fd);
                unlink (file);
@@ -127,9 +123,8 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        }
        if (fdatasync (fd) == -1) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: %s file sync error: %s\n",
-                                       log_get_progname(), file, strerrno());
+                       fprinte(log_get_logfd(), "%s: %s file sync error",
+                               log_get_progname(), file);
                }
                (void) close (fd);
                unlink (file);
@@ -146,9 +141,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        fd = open (lock, O_RDWR);
        if (-1 == fd) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: %s: %s\n",
-                                       log_get_progname(), lock, strerrno());
+                       fprinte(log_get_logfd(), "%s: %s", log_get_progname(), lock);
                }
                unlink (file);
                errno = EINVAL;
@@ -189,9 +182,8 @@ static int do_lock_file (const char *file, const char *lock, bool log)
        }
        if (unlink (lock) != 0) {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: cannot get lock %s: %s\n",
-                                       log_get_progname(), lock, strerrno());
+                       fprinte(log_get_logfd(), "%s: cannot get lock %s",
+                               log_get_progname(), lock);
                }
                unlink (file);
                return 0;
@@ -202,9 +194,8 @@ static int do_lock_file (const char *file, const char *lock, bool log)
                retval = check_link_count (file, log);
        } else {
                if (log) {
-                       (void) fprintf (log_get_logfd(),
-                                       "%s: cannot get lock %s: %s\n",
-                                       log_get_progname(), lock, strerrno());
+                       fprinte(log_get_logfd(), "%s: cannot get lock %s",
+                               log_get_progname(), lock);
                }
        }
 
index 6045bbcd15706b1f68c92655787d819c4403ebd7..308e2edf6eb1b7b0c2363666df13f2541d2204c1 100644 (file)
@@ -12,8 +12,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include "io/fprintf.h"
 #include "shadowlog.h"
-#include "string/strerrno.h"
 
 
 /*
@@ -39,7 +39,7 @@ inline void
 exit_if_null_(void *p)
 {
        if (p == NULL) {
-               fprintf(log_get_logfd(), "%s: %s\n", log_get_progname(), strerrno());
+               fprinte(log_get_logfd(), "%s", log_get_progname());
                exit(13);
        }
 }
index 4e458cf0b0a2e136dd5b69e122aca6106a2e82bb..e25f191b9fe28bc54ca4647421101335d8d1b047 100644 (file)
 #include <errno.h>
 
 #include "alloc/calloc.h"
-#include "prototypes.h"
 #include "groupio.h"
 #include "getdef.h"
+#include "io/fprintf.h"
+#include "prototypes.h"
 #include "shadowlog.h"
-#include "string/strerrno.h"
 
 
 #undef NDEBUG
@@ -240,9 +240,8 @@ int find_new_gid (bool sys_group,
        /* Create an array to hold all of the discovered GIDs */
        used_gids = calloc_T(gid_max + 1, bool);
        if (NULL == used_gids) {
-               fprintf (log_get_logfd(),
-                        _("%s: failed to allocate memory: %s\n"),
-                        log_get_progname(), strerrno());
+               fprinte(log_get_logfd(), _("%s: failed to allocate memory"),
+                       log_get_progname());
                return -1;
        }
 
index 9ca6953f09d1e4f318cfe838f146dfc19f9ff4df..99e98c49207d5ac8d5a0dbbac24acb680c3163a7 100644 (file)
@@ -16,8 +16,8 @@
 #include "prototypes.h"
 #include "pwio.h"
 #include "getdef.h"
+#include "io/fprintf.h"
 #include "shadowlog.h"
-#include "string/strerrno.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -239,9 +239,8 @@ int find_new_uid(bool sys_user,
        /* Create an array to hold all of the discovered UIDs */
        used_uids = calloc_T(uid_max + 1, bool);
        if (NULL == used_uids) {
-               fprintf (log_get_logfd(),
-                        _("%s: failed to allocate memory: %s\n"),
-                        log_get_progname(), strerrno());
+               fprinte(log_get_logfd(), _("%s: failed to allocate memory"),
+                       log_get_progname());
                return -1;
        }
 
index 719ddb4054ec82b9783ae18274f8143900c6e3e1..1ef063e8d93756ba1eab0ff4e86a70a29d54c48e 100644 (file)
@@ -13,9 +13,9 @@
 #include "defines.h"
 #include "atoi/getnum.h"
 #include "defines.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "string/sprintf/stprintf.h"
-#include "string/strerrno.h"
 
 
 /*
@@ -60,15 +60,13 @@ int open_pidfd(const char *pidstr)
                return -ENOENT;
 
        if (stprintf_a(proc_dir_name, "/proc/%d/", target) == -1) {
-               fprintf(stderr, "snprintf of proc path failed for %d: %s\n",
-                       target, strerrno());
+               fprinte(stderr, "snprintf of proc path failed for %d", target);
                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, strerrno());
+               fprinte(stderr, _("Could not open proc directory for target %d"), target);
                return -EINVAL;
        }
        return proc_dir_fd;
index 0d1d59086ca54374047e65b13423ab49403f5751..bf52a8bb18172e273eb4364f030772b492bee38e 100644 (file)
@@ -13,9 +13,9 @@
 
 #include "atoi/a2i.h"
 #include "defines.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
-#include "string/strerrno.h"
 
 
 /*
@@ -38,9 +38,9 @@ gettime(void)
                return fallback;
 
        if (a2i(time_t, &epoch, source_date_epoch, NULL, 10, 0, fallback) == -1) {
-               fprintf(log_get_logfd(),
-                       _("Environment variable $SOURCE_DATE_EPOCH: a2i(\"%s\"): %s"),
-                       source_date_epoch, strerrno());
+               fprinte(log_get_logfd(),
+                       _("Environment variable $SOURCE_DATE_EPOCH: a2i(\"%s\")"),
+                       source_date_epoch);
                return fallback;
        }
        return epoch;
index 77631ec18a266aad0ec064d28b35256be4b88d23..ad399b38f40aa6f3556062029a19e9a2aa4fd9e0 100644 (file)
 #include "atoi/a2i.h"
 #include "attr.h"
 #include "idmapping.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "sizeof.h"
 #include "string/sprintf/seprintf.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 
 
 struct map_range *
@@ -197,18 +197,18 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
        /* Write the mapping to the mapping file */
        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, strerrno());
+               fprinte(log_get_logfd(), _("%s: open of %s failed"),
+                       log_get_progname(), map_file);
                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, strerrno());
+               fprinte(log_get_logfd(), _("%s: write to %s failed"),
+                       log_get_progname(), map_file);
                exit(EXIT_FAILURE);
        }
        if (close(fd) != 0 && errno != EINTR) {
-               fprintf(log_get_logfd(), _("%s: closing %s failed: %s\n"),
-                       log_get_progname(), map_file, strerrno());
+               fprinte(log_get_logfd(), _("%s: closing %s failed"),
+                       log_get_progname(), map_file);
                exit(EXIT_FAILURE);
        }
        free(buf);
index 7496805e9a8ec8b479ce6fee94d6b680c9e03b76..db8c1dc4ba2a5ae59fdb8824e5567a9e0b9bfa30 100644 (file)
@@ -16,6 +16,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "pwio.h"
 #ifdef SHADOWGRP
 #include "sgroupio.h"
@@ -30,7 +31,6 @@
 #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;
@@ -91,9 +91,8 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char **
                /* Drop privileges */
                if (   (setregid (getgid (), getgid ()) != 0)
                    || (setreuid (getuid (), getuid ()) != 0)) {
-                       fprintf (log_get_logfd(),
-                                _("%s: failed to drop privileges (%s)\n"),
-                                log_get_progname(), strerrno());
+                       fprinte(log_get_logfd(), _("%s: failed to drop privileges"),
+                               log_get_progname());
                        exit (EXIT_FAILURE);
                }
 
index 38ef0b4cdc1a77a43869e89874407760063e7c58..064289afa919c948b6da4cd05da5534622def1d7 100644 (file)
 #include "defines.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 
 
 static void change_root (const char* newroot);
@@ -75,8 +75,8 @@ static void change_root (const char* newroot)
        /* Drop privileges */
        if (   (setregid (getgid (), getgid ()) != 0)
            || (setreuid (getuid (), getuid ()) != 0)) {
-               fprintf (log_get_logfd(), _("%s: failed to drop privileges (%s)\n"),
-                        log_get_progname(), strerrno());
+               fprinte(log_get_logfd(), _("%s: failed to drop privileges"),
+                       log_get_progname());
                exit (EXIT_FAILURE);
        }
 
@@ -88,23 +88,20 @@ 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, strerrno());
+               fprinte(log_get_logfd(), _("%s: cannot access chroot directory %s"),
+                       log_get_progname(), newroot);
                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, strerrno());
+               fprinte(log_get_logfd(), _("%s: unable to chroot to directory %s"),
+                       log_get_progname(), newroot);
                exit (E_BAD_ARG);
        }
 
        if (chdir ("/") != 0) {
-               fprintf(log_get_logfd(),
-                       _("%s: cannot chdir in chroot directory %s: %s\n"),
-                       log_get_progname(), newroot, strerrno());
+               fprinte(log_get_logfd(), _("%s: cannot chdir in chroot directory %s"),
+                       log_get_progname(), newroot);
                exit (E_BAD_ARG);
        }
 }
index 97b5206636e814c9b75a0e98f500a9648fa889e3..88864e3d0c04a349506db2d4e32f71a34fa226a7 100644 (file)
 #include <unistd.h>
 #include <lib/prototypes.h>
 
+#include "io/fprintf.h"
 #include "run_part.h"
 #include "shadowlog.h"
 #include "string/sprintf/aprintf.h"
-#include "string/strerrno.h"
 
 
 static int run_part(char *script_path, const char *name, const char *action)
@@ -26,14 +26,14 @@ static int run_part(char *script_path, const char *name, const char *action)
 
        pid=fork();
        if (pid==-1) {
-               fprintf(log_get_logfd(), "fork: %s\n", strerrno());
+               fprinte(log_get_logfd(), "fork");
                return 1;
        }
        if (pid==0) {
                setenv("ACTION",action,1);
                setenv("SUBJECT",name,1);
                execv(script_path,args);
-               fprintf(log_get_logfd(), "execv: %s\n", strerrno());
+               fprinte(log_get_logfd(), "execv");
                _exit(1);
        }
 
@@ -42,7 +42,7 @@ static int run_part(char *script_path, const char *name, const char *action)
                return (wait_status);
        }
 
-       fprintf(log_get_logfd(), "wait: %s\n", strerrno());
+       fprinte(log_get_logfd(), "wait");
        return (1);
 }
 
@@ -64,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(log_get_logfd(), "aprintf: %s\n", strerrno());
+                       fprinte(log_get_logfd(), "aprintf");
                        for (; n<scanlist; n++) {
                                free(namelist[n]);
                        }
@@ -74,7 +74,7 @@ int run_parts(const char *directory, const char *name, const char *action)
 
                execute_result = 0;
                if (stat(s, &sb) == -1) {
-                       fprintf(log_get_logfd(), "stat: %s\n", strerrno());
+                       fprinte(log_get_logfd(), "stat");
                        free(s);
                        for (; n<scanlist; n++) {
                                free(namelist[n]);
index 4b6bf8521b1fc4f466a93bf49ae74755f46187b6..a434d0e774f9f71cdd9dd451d4d8035d3f74827f 100644 (file)
@@ -14,6 +14,7 @@
 #include <selinux/selinux.h>
 #include <selinux/label.h>
 
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/sprintf/aprintf.h"
@@ -191,9 +192,8 @@ int check_selinux_permit (const char *perm_name)
        selinux_set_callback (SELINUX_CB_LOG, (union selinux_callback) { .func_log = selinux_log_cb });
 
        if (getprevcon_raw (&user_context_raw) != 0) {
-               fprintf (log_get_logfd(),
-                   _("%s: can not get previous SELinux process context: %s\n"),
-                   log_get_progname(), strerrno());
+               fprinte(log_get_logfd(), _("%s: can not get previous SELinux process context"),
+                       log_get_progname());
                SYSLOG(LOG_WARN,
                       "can not get previous SELinux process context: %s",
                       strerrno());
index ff81cc920a7925358bf763ec396f5891bdef3d78..8e1750dc11356c8d9c8b4166e7be47fe4b61ff75 100644 (file)
@@ -14,9 +14,9 @@
 #include <string.h>
 
 #include "exitcodes.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
-#include "string/strerrno.h"
 
 
 int
@@ -39,12 +39,12 @@ run_command(const char *cmd, const char *argv[],
                if (ENOENT == errno) {
                        _exit (E_CMD_NOTFOUND);
                }
-               fprintf (log_get_logfd(), "%s: cannot execute %s: %s\n",
-                        log_get_progname(), cmd, strerrno());
+               fprinte(log_get_logfd(), "%s: cannot execute %s",
+                       log_get_progname(), cmd);
                _exit (E_CMD_NOEXEC);
        } else if ((pid_t)-1 == pid) {
-               fprintf (log_get_logfd(), "%s: cannot execute %s: %s\n",
-                        log_get_progname(), cmd, strerrno());
+               fprinte(log_get_logfd(), "%s: cannot execute %s",
+                       log_get_progname(), cmd);
                return -1;
        }
 
@@ -56,8 +56,8 @@ run_command(const char *cmd, const char *argv[],
                 || ((pid_t)-1 != wpid && wpid != pid));
 
        if ((pid_t)-1 == wpid) {
-               fprintf (log_get_logfd(), "%s: waitpid (status: %d): %s\n",
-                        log_get_progname(), *status, strerrno());
+               fprinte(log_get_logfd(), "%s: waitpid (status: %d)",
+                       log_get_progname(), *status);
                return -1;
        }
 
index c7cded8abe908c1a7ea58a5d003201296c47767f..fe0f1354176130003b3b3163ac213845afe19869 100644 (file)
@@ -20,6 +20,7 @@
 #include "defines.h"
 #include "fs/readlink/readlinknul.h"
 #include "getdef.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "tcbfuncs.h"
 #include "shadowio.h"
@@ -27,7 +28,6 @@
 #include "string/sprintf/aprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 
 
 #define SHADOWTCB_HASH_BY 1000
@@ -102,9 +102,7 @@ static /*@null@*/ char *shadowtcb_path_rel_existing (const char *name)
                return NULL;
        }
        if (lstat (path, &st) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot stat %s: %s\n"),
-                        log_get_progname(), path, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot stat %s"), log_get_progname(), path);
                free (path);
                return NULL;
        }
@@ -125,9 +123,8 @@ static /*@null@*/ char *shadowtcb_path_rel_existing (const char *name)
                return NULL;
        }
        if (readlinknul_a(path, link) == -1) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot read symbolic link %s: %s\n"),
-                        log_get_progname(), path, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot read symbolic link %s"),
+                       log_get_progname(), path);
                free (path);
                return NULL;
        }
@@ -186,9 +183,8 @@ static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
        }
        ptr = path;
        if (stat (TCB_DIR, &st) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot stat %s: %s\n"),
-                        log_get_progname(), TCB_DIR, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot stat %s"),
+                       log_get_progname(), TCB_DIR);
                goto out_free_path;
        }
        while (NULL != (ind = strchr(ptr, '/'))) {
@@ -199,21 +195,18 @@ static shadowtcb_status mkdir_leading (const char *name, uid_t uid)
                        return SHADOWTCB_FAILURE;
                }
                if ((mkdir (dir, 0700) != 0) && (errno != EEXIST)) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot create directory %s: %s\n"),
-                                log_get_progname(), dir, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot create directory %s"),
+                               log_get_progname(), dir);
                        goto out_free_dir;
                }
                if (chown (dir, 0, st.st_gid) != 0) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot change owner of %s: %s\n"),
-                                log_get_progname(), dir, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot change owner of %s"),
+                               log_get_progname(), dir);
                        goto out_free_dir;
                }
                if (chmod (dir, 0711) != 0) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot change mode of %s: %s\n"),
-                                log_get_progname(), dir, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                               log_get_progname(), dir);
                        goto out_free_dir;
                }
                free (dir);
@@ -242,9 +235,7 @@ static shadowtcb_status unlink_suffs (const char *user)
                        return SHADOWTCB_FAILURE;
                }
                if ((unlink (tmp) != 0) && (errno != ENOENT)) {
-                       fprintf (log_get_logfd(),
-                                _("%s: unlink: %s: %s\n"),
-                                log_get_progname(), tmp, strerrno());
+                       fprinte(log_get_logfd(), "%s: unlink: %s", log_get_progname(), tmp);
                        free (tmp);
                        return SHADOWTCB_FAILURE;
                }
@@ -272,9 +263,9 @@ rmdir_leading(const char *relpath)
 
                if (rmdir(path) != 0) {
                        if (errno != ENOTEMPTY) {
-                               fprint(log_get_logfd(),
-                                        _("%s: Cannot remove directory %s: %s\n"),
-                                        log_get_progname(), path, strerrno());
+                               fprinte(log_get_logfd(),
+                                       _("%s: Cannot remove directory %s"),
+                                       log_get_progname(), path);
                                ret = SHADOWTCB_FAILURE;
                        }
                        break;
@@ -306,9 +297,8 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
                goto out_free_nomem;
        }
        if (stat (olddir, &oldmode) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot stat %s: %s\n"),
-                        log_get_progname(), olddir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot stat %s"),
+                       log_get_progname(), olddir);
                goto out_free;
        }
        old_uid = oldmode.st_uid;
@@ -333,18 +323,16 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
                goto out_free;
        }
        if (rename (real_old_dir, real_new_dir) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot rename %s to %s: %s\n"),
-                        log_get_progname(), real_old_dir, real_new_dir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot rename %s to %s"),
+                       log_get_progname(), real_old_dir, real_new_dir);
                goto out_free;
        }
        if (rmdir_leading (real_old_dir_rel) == SHADOWTCB_FAILURE) {
                goto out_free;
        }
        if ((unlink (olddir) != 0) && (errno != ENOENT)) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot remove %s: %s\n"),
-                        log_get_progname(), olddir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot remove %s"),
+                       log_get_progname(), olddir);
                goto out_free;
        }
        newdir = aprintf(TCB_DIR "/%s", user_newname);
@@ -357,9 +345,8 @@ static shadowtcb_status move_dir (const char *user_newname, uid_t user_newid)
        }
        if (   !streq(real_new_dir, newdir)
            && (symlink (real_new_dir_rel, newdir) != 0)) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot create symbolic link %s: %s\n"),
-                        log_get_progname(), real_new_dir_rel, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot create symbolic link %s"),
+                       log_get_progname(), real_new_dir_rel);
                goto out_free;
        }
        ret = SHADOWTCB_SUCCESS;
@@ -472,28 +459,24 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
                return SHADOWTCB_FAILURE;
        }
        if (stat (tcbdir, &dirmode) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot stat %s: %s\n"),
-                        log_get_progname(), tcbdir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot stat %s"),
+                       log_get_progname(), tcbdir);
                goto out_free;
        }
        if (chown (tcbdir, 0, 0) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change owners of %s: %s\n"),
-                        log_get_progname(), tcbdir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change owners of %s"),
+                       log_get_progname(), tcbdir);
                goto out_free;
        }
        if (chmod (tcbdir, 0700) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change mode of %s: %s\n"),
-                        log_get_progname(), tcbdir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                       log_get_progname(), tcbdir);
                goto out_free;
        }
        if (lstat (shadow, &filemode) != 0) {
                if (errno != ENOENT) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot lstat %s: %s\n"),
-                                log_get_progname(), shadow, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot lstat %s"),
+                               log_get_progname(), shadow);
                        goto out_free;
                }
                fprintf (log_get_logfd(),
@@ -510,15 +493,13 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
                        goto out_free;
                }
                if (chown (shadow, user_newid, filemode.st_gid) != 0) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot change owner of %s: %s\n"),
-                                log_get_progname(), shadow, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot change owner of %s"),
+                               log_get_progname(), shadow);
                        goto out_free;
                }
                if (chmod (shadow, filemode.st_mode & 07777) != 0) {
-                       fprintf (log_get_logfd(),
-                                _("%s: Cannot change mode of %s: %s\n"),
-                                log_get_progname(), shadow, strerrno());
+                       fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                               log_get_progname(), shadow);
                        goto out_free;
                }
        }
@@ -526,15 +507,13 @@ shadowtcb_status shadowtcb_move (/*@NULL@*/const char *user_newname, uid_t user_
                goto out_free;
        }
        if (chown (tcbdir, user_newid, dirmode.st_gid) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change owner of %s: %s\n"),
-                        log_get_progname(), tcbdir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change owner of %s"),
+                       log_get_progname(), tcbdir);
                goto out_free;
        }
        if (chmod (tcbdir, dirmode.st_mode & 07777) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change mode of %s: %s\n"),
-                        log_get_progname(), tcbdir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                       log_get_progname(), tcbdir);
                goto out_free;
        }
        ret = SHADOWTCB_SUCCESS;
@@ -557,9 +536,8 @@ shadowtcb_status shadowtcb_create (const char *name, uid_t uid)
                return SHADOWTCB_SUCCESS;
        }
        if (stat (TCB_DIR, &tcbdir_stat) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot stat %s: %s\n"),
-                        log_get_progname(), TCB_DIR, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot stat %s"),
+                       log_get_progname(), TCB_DIR);
                return SHADOWTCB_FAILURE;
        }
        shadowgid = tcbdir_stat.st_gid;
@@ -582,39 +560,33 @@ shadowtcb_status shadowtcb_create (const char *name, uid_t uid)
                return SHADOWTCB_FAILURE;
        }
        if (mkdir (dir, 0700) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: mkdir: %s: %s\n"), log_get_progname(), dir, strerrno());
+               fprinte(log_get_logfd(), "%s: mkdir: %s", log_get_progname(), dir);
                goto out_free;
        }
        fd = open (shadow, O_RDWR | O_CREAT | O_TRUNC, 0600);
        if (fd < 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot open %s: %s\n"),
-                        log_get_progname(), shadow, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot open %s"),
+                       log_get_progname(), shadow);
                goto out_free;
        }
        if (fchown (fd, 0, authgid) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change owner of %s: %s\n"),
-                        log_get_progname(), shadow, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change owner of %s"),
+                       log_get_progname(), shadow);
                goto out_free;
        }
        if (fchmod (fd, (mode_t) ((authgid == shadowgid) ? 0600 : 0640)) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change mode of %s: %s\n"),
-                        log_get_progname(), shadow, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                       log_get_progname(), shadow);
                goto out_free;
        }
        if (chown (dir, 0, authgid) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change owner of %s: %s\n"),
-                        log_get_progname(), dir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change owner of %s"),
+                       log_get_progname(), dir);
                goto out_free;
        }
        if (chmod (dir, (mode_t) ((authgid == shadowgid) ? 02700 : 02710)) != 0) {
-               fprintf (log_get_logfd(),
-                        _("%s: Cannot change mode of %s: %s\n"),
-                        log_get_progname(), dir, strerrno());
+               fprinte(log_get_logfd(), _("%s: Cannot change mode of %s"),
+                       log_get_progname(), dir);
                goto out_free;
        }
        if (   (shadowtcb_set_user (name) == SHADOWTCB_FAILURE)
index ac215ec146a810e97d43fd34a8533fadf9c0d2a1..5511394a750d1deb894d35f89ae360339a343915 100644 (file)
@@ -24,6 +24,7 @@
 #include "atoi/a2i.h"
 #include "defines.h"
 #include "fields.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "pwio.h"
 #include "shadowio.h"
@@ -32,7 +33,6 @@
 #include "string/sprintf/stprintf.h"
 #include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
-#include "string/strerrno.h"
 #include "string/strftime.h"
 #include "time/day_to_str.h"
 /*@-exitarg@*/
@@ -742,8 +742,7 @@ int main (int argc, char **argv)
        /* Drop privileges */
        if (lflg && (   (setregid (rgid, rgid) != 0)
                     || (setreuid (ruid, ruid) != 0))) {
-               fprintf (stderr, _("%s: failed to drop privileges (%s)\n"),
-                        Prog, strerrno());
+               fprinte(stderr, _("%s: failed to drop privileges"), Prog);
                fail_exit (E_NOPERM, process_selinux);
        }
 
index e77ecc6ac7f284d26d5f0f2d34135c5fcb638e51..347a202eb57b0e40c768cd9f88c633a8f0d6cbc1 100644 (file)
 
 #include "atoi/a2i.h"
 #include "defines.h"
+#include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
-#include "groupio.h"
 #ifdef SHADOWGRP
 #include "sgroupio.h"
 #endif
@@ -33,7 +34,6 @@
 #include "shadow/gshadow/sgrp.h"
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 /*
@@ -436,9 +436,8 @@ int main (int argc, char **argv)
                        salt = crypt_make_salt (crypt_method, arg);
                        cp = pw_encrypt (newpwd, salt);
                        if (NULL == cp) {
-                               fprintf (stderr,
-                                        _("%s: failed to crypt password with salt '%s': %s\n"),
-                                       Prog, salt, strerrno());
+                               fprinte(stderr, _("%s: failed to crypt password with salt '%s'"),
+                                       Prog, salt);
                                fail_exit (1, process_selinux);
                        }
                }
index 9c2c5e7901045427e53a0fe960a55de71dd90803..bbbe4626e8b9cb6df005a4c875da67b2dd539a2b 100644 (file)
 #include "atoi/a2i.h"
 #include "chkhash.h"
 #include "defines.h"
+#include "getdef.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "sssd.h"
-#include "getdef.h"
 #include "prototypes.h"
 #include "pwio.h"
 #include "shadowio.h"
@@ -36,7 +37,6 @@
 #include "io/fgets/fgets.h"
 #include "shadowlog.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 
 
@@ -498,9 +498,8 @@ int main (int argc, char **argv)
                if (salt) {
                        cp = pw_encrypt (newpwd, salt);
                        if (NULL == cp) {
-                               fprintf (stderr,
-                                        _("%s: failed to crypt password with salt '%s': %s\n"),
-                                       Prog, salt, strerrno());
+                               fprinte(stderr, _("%s: failed to crypt password with salt '%s'"),
+                                       Prog, salt);
                                fail_exit (1, process_selinux);
                        }
                }
index 28cf7f58e1e4ea981798d5aad57e31eb9f830cdf..027f315c37d974b86b995a5d3e0cafaf8bd9d839 100644 (file)
 
 #include "atoi/a2i.h"
 #include "defines.h"
-#include "faillog.h"
-#include "prototypes.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "faillog.h"
+#include "io/fprintf.h"
+#include "prototypes.h"
 #include "shadowlog.h"
 #include "string/memset/memzero.h"
-#include "string/strerrno.h"
 #include "string/strftime.h"
 
 #undef NDEBUG
@@ -638,17 +638,13 @@ int main (int argc, char **argv)
                fail = fopen (FAILLOG_FILE, "r");
        }
        if (NULL == fail) {
-               fprintf (stderr,
-                        _("%s: Cannot open %s: %s\n"),
-                       Prog, FAILLOG_FILE, strerrno());
+               fprinte(stderr, _("%s: Cannot open %s"), Prog, FAILLOG_FILE);
                exit (E_NOPERM);
        }
 
        /* Get the size of the faillog */
        if (fstat (fileno (fail), &statbuf) != 0) {
-               fprintf (stderr,
-                        _("%s: Cannot get the size of %s: %s\n"),
-                       Prog, FAILLOG_FILE, strerrno());
+               fprinte(stderr, _("%s: Cannot get the size of %s"), Prog, FAILLOG_FILE);
                exit (E_NOPERM);
        }
 
@@ -673,9 +669,7 @@ int main (int argc, char **argv)
                    || (fflush (fail) != 0)
                    || (fsync  (fileno (fail)) != 0)
                    || (fclose (fail) != 0)) {
-                       fprintf (stderr,
-                                _("%s: Failed to write %s: %s\n"),
-                               Prog, FAILLOG_FILE, strerrno());
+                       fprinte(stderr, _("%s: Failed to write %s"), Prog, FAILLOG_FILE);
                        (void) fclose (fail);
                        errors = true;
                }
index fcce80b4b5756ccd2513a000b8684b06f14b75de..5dca40d431b0d7123746a1dd43954377881c33b5 100644 (file)
@@ -5,7 +5,7 @@
 #include <unistd.h>
 
 #include "atoi/a2i.h"
-#include "string/strerrno.h"
+#include "io/fprintf.h"
 #include "subid.h"
 #include "stdlib.h"
 
@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
        bool group = false;   // get subuids by default
 
        if (!subid_init(Prog, stderr))
-               fprintf(stderr, "subid_init: %s\n", strerrno());
+               fprinte(stderr, "subid_init");
        while ((c = getopt(argc, argv, "g")) != EOF) {
                switch(c) {
                case 'g': group = true; break;
index 653691374a096422c9db12f8bd93e46795bd7001..49d1ce1a3e0aabd9a8f630cf9fdc23ec63a7c205 100644 (file)
@@ -5,10 +5,10 @@
 
 #include "atoi/getnum.h"
 #include "attr.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "stdlib.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 #include "subid.h"
 
 
@@ -25,7 +25,7 @@ int main(int argc, char *argv[])
        uid_t  *uids;
 
        if (!subid_init(Prog, stderr))
-               fprintf(stderr, "subid_init: %s\n", strerrno());
+               fprinte(stderr, "subid_init");
        if (argc < 2) {
                usage();
        }
index 386c66d6faeab0d5f55187fd26df323dca212dd3..622e44b84e263e0de2fa8afc830880fb1bfe4e78 100644 (file)
@@ -5,9 +5,9 @@
 #include <string.h>
 
 #include "attr.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 #include "subid.h"
 
 static const char Prog[] = "getsubids";
@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
        const char *owner;
 
        if (!subid_init(Prog, stderr))
-               fprintf(stderr, "subid_init: %s\n", strerrno());
+               fprinte(stderr, "subid_init");
        if (argc < 2)
                usage();
        owner = argv[1];
index bb53087c6f796795ac2fcdb285c3e544a819dbc0..1e207c34c11feeed15a2133450db284461a06006 100644 (file)
@@ -27,6 +27,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #ifdef SHADOWGRP
@@ -40,7 +41,6 @@
 #include "string/strcmp/streq.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
-#include "string/strerrno.h"
 
 
 struct option_flags {
@@ -846,9 +846,7 @@ static void change_passwd (struct group *gr)
        cp = pw_encrypt (pass, salt);
        memzero_a(pass);
        if (NULL == cp) {
-               fprintf (stderr,
-                        _("%s: failed to crypt password with salt '%s': %s\n"),
-                       Prog, salt, strerrno());
+               fprinte(stderr, _("%s: failed to crypt password with salt '%s'"), Prog, salt);
                exit (1);
        }
 #ifdef SHADOWGRP
index 3c4ac8b13c2dda1fb9540d65fe6e8ad57ca30e38..f29ff83fe9ece696a21d9bb8caa9a13e780e28d9 100644 (file)
@@ -24,6 +24,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
@@ -370,7 +371,7 @@ static void open_files(const 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(), strerrno());
+               fprinte(stderr, _("%s: cannot open %s"), Prog, gr_dbname());
                SYSLOG(LOG_WARN, "cannot open %s: %s", gr_dbname(), strerrno());
                fail_exit (E_GRP_UPDATE);
        }
@@ -378,9 +379,7 @@ static void open_files(const struct option_flags *flags)
 #ifdef SHADOWGRP
        if (is_shadow_grp) {
                if (sgr_open (O_CREAT | O_RDWR) == 0) {
-                       fprintf (stderr,
-                                _("%s: cannot open %s: %s\n"),
-                                Prog, sgr_dbname(), strerrno());
+                       fprinte(stderr, _("%s: cannot open %s"), Prog, sgr_dbname());
                        SYSLOG(LOG_WARN, "cannot open %s: %s", sgr_dbname(), strerrno());
                        fail_exit (E_GRP_UPDATE);
                }
index ae172a0b6a94975b1df4f14c19ecbfb5cd7df303..97ad355dab6db384f352280ee86d3779b55be1f2 100644 (file)
 
 #include "atoi/a2i.h"
 #include "defines.h"
-#include "prototypes.h"
-#include "getdef.h"
 /*@-exitarg@*/
 #include "exitcodes.h"
+#include "getdef.h"
+#include "io/fprintf.h"
+#include "prototypes.h"
 #include "shadowlog.h"
 #include "sizeof.h"
 #include "string/memset/memzero.h"
-#include "string/strerrno.h"
 #include "string/strftime.h"
 
 #undef NDEBUG
@@ -437,9 +437,7 @@ int main (int argc, char **argv)
 
        /* Get the lastlog size */
        if (fstat (fileno (lastlogfile), &statbuf) != 0) {
-               fprintf (stderr,
-                        _("%s: Cannot get the size of %s: %s\n"),
-                       Prog, _PATH_LASTLOG, strerrno());
+               fprinte(stderr, _("%s: Cannot get the size of %s"), Prog, _PATH_LASTLOG);
                exit (EXIT_FAILURE);
        }
 
index 216e9ac3d3f52ce39f75eae1a43392fba2cae641..57ddaa66c951bce72e818e69ba7d16137f73312a 100644 (file)
@@ -35,6 +35,7 @@
 #include "faillog.h"
 #include "failure.h"
 #include "getdef.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "pwauth.h"
 #include "shadow/gshadow/endsgent.h"
@@ -46,7 +47,6 @@
 #include "string/strcmp/strprefix.h"
 #include "string/strcpy/strtcpy.h"
 #include "string/strdup/strdup.h"
-#include "string/strerrno.h"
 #include "string/strftime.h"
 #include "sysconf.h"
 
@@ -1094,7 +1094,7 @@ int main (int argc, char **argv)
        child = fork ();
        if (child < 0) {
                /* error in fork() */
-               fprintf(stderr, _("%s: failure forking: %s"), Prog, strerrno());
+               fprinte(stderr, _("%s: failure forking"), Prog);
                retcode = pam_close_session(pamh, 0);
                pam_end(pamh, retcode);
                exit (0);
index bca379d8b6d0a3a16e3620eb581db5b619ee35b4..978e4ef6585e37b366f4d152dbb1bba84aed7ed9 100644 (file)
@@ -4,7 +4,7 @@
 #include <unistd.h>
 
 #include "atoi/a2i.h"
-#include "string/strerrno.h"
+#include "io/fprintf.h"
 #include "subid.h"
 #include "stdlib.h"
 
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
        bool ok;
 
        if (!subid_init(Prog, stderr))
-               fprintf(stderr, "subid_init: %s\n", strerrno());
+               fprinte(stderr, "subid_init");
        while ((c = getopt(argc, argv, "gn")) != EOF) {
                switch(c) {
                case 'n': makenew = true; break;
index afda66657a6606d7d8c75ad496d99fd6457290fe..1faca380fa45f243e4d47512c7a81f86ac34cf5a 100644 (file)
 #include "defines.h"
 #include "getdef.h"
 #include "idmapping.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 #include "subordinateio.h"
 
 
@@ -103,8 +103,7 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
                        fprintf(stderr, _("%s: kernel doesn't support setgroups restrictions\n"), Prog);
                        goto out;
                }
-               fprintf(stderr, _("%s: couldn't open process setgroups: %s\n"),
-                       Prog, strerrno());
+               fprinte(stderr, _("%s: couldn't open process setgroups"), Prog);
                exit(EXIT_FAILURE);
        }
 
@@ -114,8 +113,7 @@ static void write_setgroups(int proc_dir_fd, bool allow_setgroups)
         * fail.
         */
        if (read(setgroups_fd, policy_buffer, sizeof(policy_buffer)) < 0) {
-               fprintf(stderr, _("%s: failed to read setgroups: %s\n"),
-                       Prog, strerrno());
+               fprinte(stderr, _("%s: failed to read setgroups"), Prog);
                exit(EXIT_FAILURE);
        }
        if (strprefix(policy_buffer, policy))
@@ -123,13 +121,11 @@ 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, strerrno());
+               fprinte(stderr, _("%s: failed to seek setgroups"), Prog);
                exit(EXIT_FAILURE);
        }
        if (dprintf(setgroups_fd, "%s", policy) < 0) {
-               fprintf(stderr, _("%s: failed to setgroups %s policy: %s\n"),
-                       Prog, policy, strerrno());
+               fprinte(stderr, _("%s: failed to setgroups %s policy"), Prog, policy);
                exit(EXIT_FAILURE);
        }
 
@@ -189,9 +185,7 @@ 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: %s\n"),
-                       Prog, strerrno());
+               fprinte(stderr, _("%s: Could not stat directory for target process"), Prog);
                return EXIT_FAILURE;
        }
 
@@ -211,9 +205,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(), strerrno());
+               fprinte(stderr, _("%s: cannot open %s"), Prog, sub_gid_dbname());
                return EXIT_FAILURE;
        }
 
index 0f12d577bbfa1088d77947a32a8a718f456bb7c6..b8f2e37f28d533cb1fce744e195db75347523fc9 100644 (file)
@@ -24,6 +24,7 @@
 /*@-exitarg@*/
 #include "exitcodes.h"
 #include "getdef.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "search/l/lfind.h"
 #include "search/l/lsearch.h"
@@ -36,7 +37,6 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
-#include "string/strerrno.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -188,9 +188,8 @@ static void check_perms (const struct group *grp,
                erase_pass (cp);
 
                if (NULL == cpasswd) {
-                       fprintf (stderr,
-                                _("%s: failed to crypt password with previous salt: %s\n"),
-                               Prog, strerrno());
+                       fprinte(stderr, _("%s: failed to crypt password with previous salt"),
+                               Prog);
                        SYSLOG(LOG_INFO,
                               "Failed to crypt password with previous salt of group '%s'",
                               groupname);
@@ -295,8 +294,8 @@ static void syslog_sg (const char *name, const char *group)
                child = fork ();
                if ((pid_t)-1 == child) {
                        /* error in fork() */
-                       fprintf (stderr, _("%s: failure forking: %s\n"),
-                               is_newgrp ? "newgrp" : "sg", strerrno());
+                       fprinte(stderr, _("%s: failure forking"),
+                               is_newgrp ? "newgrp" : "sg");
 #ifdef WITH_AUDIT
                        if (group) {
                                audit_logger_with_group(AUDIT_CHGRP_ID, "changing", NULL,
index 108852eae8621465ee5e6aa1f39d86fa1e2b50cf..bf3b8730ecb6ba7e79b984052a40929fd2e170c6 100644 (file)
 #include "defines.h"
 #include "getdef.h"
 #include "idmapping.h"
+#include "io/fprintf.h"
 #include "prototypes.h"
 #include "shadowlog.h"
 #include "string/strcmp/strprefix.h"
-#include "string/strerrno.h"
 #include "subordinateio.h"
 
 
@@ -123,9 +123,7 @@ 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: %s\n"),
-                       Prog, strerrno());
+               fprinte(stderr, _("%s: Could not stat directory for target process"), Prog);
                return EXIT_FAILURE;
        }
 
@@ -145,9 +143,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(), strerrno());
+               fprinte(stderr, _("%s: cannot open %s"), Prog, sub_uid_dbname());
                return EXIT_FAILURE;
        }
 
index 2baf1f567c1eaac9a3af9e5e0c4176daa9afe998..7b544fe89015bc4a8ad3802bd366c5cbc203c881 100644 (file)
@@ -41,6 +41,7 @@
 #include "getdef.h"
 #include "groupio.h"
 #include "io/fgets/fgets.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #include "pwio.h"
@@ -56,7 +57,6 @@
 #include "string/sprintf/stprintf.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"
 
@@ -453,9 +453,8 @@ static int update_passwd (struct passwd *pwd, const char *password)
                const char *salt = crypt_make_salt (crypt_method, crypt_arg);
                cp = pw_encrypt (password, salt);
                if (NULL == cp) {
-                       fprintf (stderr,
-                                _("%s: failed to crypt password with salt '%s': %s\n"),
-                               Prog, salt, strerrno());
+                       fprinte(stderr, _("%s: failed to crypt password with salt '%s'"),
+                               Prog, salt);
                        return 1;
                }
                pwd->pw_passwd = cp;
@@ -530,9 +529,9 @@ add_passwd(struct passwd *pwd, MAYBE_UNUSED const char *password)
                                                            crypt_arg);
                        cp = pw_encrypt (password, salt);
                        if (NULL == cp) {
-                               fprint(stderr,
-                                        _("%s: failed to crypt password with salt '%s': %s\n"),
-                                       Prog, salt, strerrno());
+                               fprinte(stderr,
+                                       _("%s: failed to crypt password with salt '%s'"),
+                                       Prog, salt);
                                return 1;
                        }
                        spent.sp_pwdp = cp;
@@ -580,9 +579,9 @@ add_passwd(struct passwd *pwd, MAYBE_UNUSED const char *password)
                const char *salt = crypt_make_salt (crypt_method, crypt_arg);
                cp = pw_encrypt (password, salt);
                if (NULL == cp) {
-                       fprint(stderr,
-                                _("%s: failed to crypt password with salt '%s': %s\n"),
-                               Prog, salt, strerrno());
+                       fprinte(stderr,
+                               _("%s: failed to crypt password with salt '%s'"),
+                               Prog, salt);
                        return 1;
                }
                spent.sp_pwdp = cp;
@@ -1111,7 +1110,7 @@ int main (int argc, char **argv)
                usernames = reallocf_T(usernames, nusers, char *);
                passwords = reallocf_T(passwords, nusers, char *);
                if (lines == NULL || usernames == NULL || passwords == NULL) {
-                       fprintf(stderr, _("%s: line %jd: %s\n"), Prog, line, strerrno());
+                       fprinte(stderr, _("%s: line %jd"), Prog, line);
                        fail_exit (EXIT_FAILURE, process_selinux);
                }
                lines[nusers-1]     = line;
@@ -1148,18 +1147,16 @@ int main (int argc, char **argv)
                                fail_exit (EXIT_FAILURE, process_selinux);
                        }
                        if (mkdir (newpw.pw_dir, mode) != 0) {
-                               fprintf (stderr,
-                                        _("%s: line %jd: mkdir %s failed: %s\n"),
-                                       Prog, line, newpw.pw_dir, strerrno());
+                               fprinte(stderr, _("%s: line %jd: mkdir %s failed"),
+                                       Prog, line, newpw.pw_dir);
                                if (errno != EEXIST) {
                                        fail_exit (EXIT_FAILURE, process_selinux);
                                }
                        }
                        if (chown(newpw.pw_dir, newpw.pw_uid, newpw.pw_gid) != 0)
                        {
-                               fprintf (stderr,
-                                        _("%s: line %jd: chown %s failed: %s\n"),
-                                       Prog, line, newpw.pw_dir, strerrno());
+                               fprinte(stderr, _("%s: line %jd: chown %s failed"),
+                                       Prog, line, newpw.pw_dir);
                                fail_exit (EXIT_FAILURE, process_selinux);
                        }
                }
@@ -1183,9 +1180,9 @@ int main (int argc, char **argv)
                        unsigned long sub_uid_count = 0;
                        if (find_new_sub_uids(newpw.pw_uid, &sub_uid_start, &sub_uid_count) != 0)
                        {
-                               fprint(stderr,
-                                       _("%s: can't find subordinate user range: %s\n"),
-                                       Prog, strerrno());
+                               fprinte(stderr,
+                                       _("%s: can't find subordinate user range"),
+                                       Prog);
                                SYSLOG(LOG_WARN, "can't find subordinate user range: %s\n",
                                       strerrno());
                                fail_exit (EXIT_FAILURE, process_selinux);
@@ -1206,9 +1203,9 @@ int main (int argc, char **argv)
                        gid_t sub_gid_start = 0;
                        unsigned long sub_gid_count = 0;
                        if (find_new_sub_gids(newpw.pw_uid, &sub_gid_start, &sub_gid_count) != 0) {
-                               fprint(stderr,
-                                       _("%s: can't find subordinate group range: %s\n"),
-                                       Prog, strerrno());
+                               fprinte(stderr,
+                                       _("%s: can't find subordinate group range"),
+                                       Prog);
                                SYSLOG(LOG_WARN, "can't find subordinate group range: %s\n",
                                       strerrno());
                                fail_exit (EXIT_FAILURE, process_selinux);
index 2a46975183565345ce85b9377aef56bc715ea9ac..520c1de8b64ba8b8f4c5073c71f847ce68ebfe5b 100644 (file)
@@ -25,6 +25,7 @@
 #include "chkname.h"
 #include "defines.h"
 #include "getdef.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #include "pwauth.h"
@@ -39,7 +40,6 @@
 #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"
 
 
@@ -207,9 +207,8 @@ static int new_password (const struct passwd *pw)
 
                if (NULL == cipher) {
                        erase_pass (clear);
-                       fprintf (stderr,
-                                _("%s: failed to crypt password with previous salt: %s\n"),
-                                Prog, strerrno());
+                       fprinte(stderr, _("%s: failed to crypt password with previous salt"),
+                               Prog);
                        SYSLOG(LOG_INFO,
                               "Failed to crypt password with previous salt of user '%s'",
                               pw->pw_name);
@@ -339,9 +338,8 @@ static int new_password (const struct passwd *pw)
        memzero_a(pass);
 
        if (NULL == cp) {
-               fprintf (stderr,
-                        _("%s: failed to crypt password with salt '%s': %s\n"),
-                        Prog, salt, strerrno());
+               fprinte(stderr, _("%s: failed to crypt password with salt '%s'"),
+                       Prog, salt);
                return -1;
        }
 
index 9b52c8fc8bdafdf2fc5c292109a1b0d99537bddf..643a029d687a57ee58f8aac6fdbcedfd73b65043 100644 (file)
@@ -42,6 +42,7 @@
 #include "getdef.h"
 #include "groupio.h"
 #include "io/fgets/fgets.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #include "pwauth.h"
@@ -70,7 +71,6 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
-#include "string/strerrno.h"
 #include "string/strtok/stpsep.h"
 #include "sysconf.h"
 
@@ -546,17 +546,14 @@ 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, strerrno());
+               fprinte(stderr, _("%s: cannot create new defaults file"), Prog);
                return -1;
        }
 
        if (prefix[0]) {
                default_file = aprintf("%s/%s", prefix, USER_DEFAULTS_FILE);
                if (default_file == NULL) {
-                       fprintf(stderr,
-                               _("%s: cannot create new defaults file: %s\n"),
-                               Prog, strerrno());
+                       fprinte(stderr, _("%s: cannot create new defaults file"), Prog);
                        goto err_free_new;
                }
        }
@@ -713,9 +710,7 @@ set_defaults(void)
        assert(stprintf_a(buf, "%s-", default_file) != -1);
        unlink (buf);
        if ((link (default_file, buf) != 0) && (ENOENT != errno)) {
-               fprintf (stderr,
-                        _("%s: Cannot create backup file (%s): %s\n"),
-                        Prog, buf, strerrno());
+               fprinte(stderr, _("%s: Cannot create backup file (%s)"), Prog, buf);
                unlink (new_file);
                goto err_free_def;
        }
@@ -724,9 +719,7 @@ set_defaults(void)
         * Rename the new default file to its correct name.
         */
        if (rename (new_file, default_file) != 0) {
-               fprintf (stderr,
-                        _("%s: rename: %s: %s\n"),
-                        Prog, new_file, strerrno());
+               fprinte(stderr, _("%s: rename: %s"), Prog, new_file);
                goto err_free_def;
        }
 #ifdef WITH_AUDIT
@@ -1986,24 +1979,21 @@ static void faillog_reset (uid_t uid)
 
        fd = open (FAILLOG_FILE, O_RDWR);
        if (-1 == fd) {
-               fprintf (stderr,
-                        _("%s: failed to open the faillog file for UID %lu: %s\n"),
-                       Prog, (unsigned long) uid, strerrno());
+               fprinte(stderr, _("%s: failed to open the faillog file for UID %lu"),
+                       Prog, (unsigned long) uid);
                SYSLOG(LOG_WARN, "failed to open the faillog file for UID %lu", (unsigned long) uid);
                return;
        }
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
            || (write_full(fd, &fl, sizeof(fl)) == -1)
            || (fsync (fd) != 0)) {
-               fprintf (stderr,
-                        _("%s: failed to reset the faillog entry of UID %lu: %s\n"),
-                       Prog, (unsigned long) uid, strerrno());
+               fprinte(stderr, _("%s: failed to reset the faillog entry of UID %lu"),
+                       Prog, (unsigned long) uid);
                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, strerrno());
+               fprinte(stderr, _("%s: failed to close the faillog file for UID %lu"),
+                       Prog, (unsigned long) uid);
                SYSLOG(LOG_WARN, "failed to close the faillog file for UID %lu", (unsigned long) uid);
        }
 }
@@ -2031,25 +2021,22 @@ static void lastlog_reset (uid_t uid)
 
        fd = open(_PATH_LASTLOG, O_RDWR);
        if (-1 == fd) {
-               fprintf (stderr,
-                        _("%s: failed to open the lastlog file for UID %lu: %s\n"),
-                       Prog, (unsigned long) uid, strerrno());
+               fprinte(stderr, _("%s: failed to open the lastlog file for UID %lu"),
+                       Prog, (unsigned long) uid);
                SYSLOG(LOG_WARN, "failed to open the lastlog file for UID %lu", (unsigned long) uid);
                return;
        }
        if (   (lseek (fd, offset_uid, SEEK_SET) != offset_uid)
            || (write_full(fd, &ll, sizeof(ll)) == -1)
            || (fsync (fd) != 0)) {
-               fprintf (stderr,
-                        _("%s: failed to reset the lastlog entry of UID %lu: %s\n"),
-                       Prog, (unsigned long) uid, strerrno());
+               fprinte(stderr, _("%s: failed to reset the lastlog entry of UID %lu"),
+                       Prog, (unsigned long) uid);
                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, strerrno());
+               fprinte(stderr, _("%s: failed to close the lastlog file for UID %lu"),
+                       Prog, (unsigned long) uid);
                SYSLOG(LOG_WARN, "failed to close the lastlog file for UID %lu", (unsigned long) uid);
                /* continue */
        }
@@ -2273,8 +2260,8 @@ static void create_home(const struct option_flags *flags)
                                fail_exit(E_HOMEDIR, process_selinux);
                        }
                        if (statfs(dirname(btrfs_check), &sfs) == -1) {
-                               fprintf(stderr, "%s: statfs(dirname(\"%s\")): %s\n",
-                                       Prog, path, strerrno());
+                               fprinte(stderr, "%s: statfs(dirname(\"%s\"))",
+                                       Prog, path);
                                fail_exit(E_HOMEDIR, process_selinux);
                        }
                        free(btrfs_check);
@@ -2661,9 +2648,9 @@ int main (int argc, char **argv)
 #ifdef ENABLE_SUBIDS
        if (is_sub_uid && subuid_count != 0) {
                if (find_new_sub_uids(user_id, &sub_uid_start, &subuid_count) < 0) {
-                       fprint(stderr,
-                                _("%s: can't create subordinate user IDs: %s\n"),
-                                Prog, strerrno());
+                       fprinte(stderr,
+                               _("%s: can't create subordinate user IDs"),
+                               Prog);
                        SYSLOG(LOG_WARN, "can't create subordinate user IDs: %s\n",
                               strerrno());
                        fail_exit(E_SUB_UID_UPDATE, process_selinux);
@@ -2671,9 +2658,9 @@ int main (int argc, char **argv)
        }
        if (is_sub_gid && subgid_count != 0) {
                if (find_new_sub_gids(user_id, &sub_gid_start, &subgid_count) < 0) {
-                       fprint(stderr,
-                                _("%s: can't create subordinate group IDs: %s\n"),
-                                Prog, strerrno());
+                       fprinte(stderr,
+                               _("%s: can't create subordinate group IDs"),
+                               Prog);
                        SYSLOG(LOG_WARN, "can't create subordinate group IDs: %s\n",
                               strerrno());
                        fail_exit(E_SUB_GID_UPDATE, process_selinux);
index ebd064c061be6de794289a163e3b790f77d5064d..ad36a97d00e234e51bc07cf9aa485fd442bdd8f5 100644 (file)
@@ -24,6 +24,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "sssd.h"
 #include "prototypes.h"
@@ -770,9 +771,7 @@ static bool remove_mailbox (void)
                        free(mailfile);
                        return 0;
                } else {
-                       fprintf (stderr,
-                                _("%s: warning: can't remove %s: %s\n"),
-                               Prog, mailfile, strerrno());
+                       fprinte(stderr, _("%s: warning: can't remove %s"), Prog, mailfile);
                        SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER,
@@ -786,9 +785,7 @@ static bool remove_mailbox (void)
 
        if (fflg) {
                if (unlink (mailfile) != 0) {
-                       fprintf (stderr,
-                                _("%s: warning: can't remove %s: %s\n"),
-                               Prog, mailfile, strerrno());
+                       fprinte(stderr, _("%s: warning: can't remove %s"), Prog, mailfile);
                        SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
 #ifdef WITH_AUDIT
                        audit_logger (AUDIT_DEL_USER,
@@ -827,9 +824,7 @@ static bool remove_mailbox (void)
                return 0;               /* mailbox doesn't exist */
        }
        if (unlink (mailfile) != 0) {
-               fprintf (stderr,
-                        _("%s: warning: can't remove %s: %s\n"),
-                        Prog, mailfile, strerrno());
+               fprinte(stderr, _("%s: warning: can't remove %s"), Prog, mailfile);
                SYSLOG(LOG_ERR, "Cannot remove %s: %s", mailfile, strerrno());
 #ifdef WITH_AUDIT
                audit_logger (AUDIT_DEL_USER,
@@ -869,8 +864,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
                return 1;
        }
        if (shadowtcb_drop_priv () == SHADOWTCB_FAILURE) {
-               fprintf (stderr, _("%s: Cannot drop privileges: %s\n"),
-                        Prog, strerrno());
+               fprinte(stderr, _("%s: Cannot drop privileges"), Prog);
                shadowtcb_gain_priv ();
                free (buf);
                return 1;
@@ -879,8 +873,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
         * We will regain them and remove the user's tcb directory afterwards.
         */
        if (remove_tree (buf, false) != 0) {
-               fprintf (stderr, _("%s: Cannot remove the content of %s: %s\n"),
-                       Prog, buf, strerrno());
+               fprinte(stderr, _("%s: Cannot remove the content of %s"), Prog, buf);
                shadowtcb_gain_priv ();
                free (buf);
                return 1;
@@ -888,8 +881,7 @@ static int remove_tcbdir (const char *user_name, uid_t user_id)
        shadowtcb_gain_priv ();
        free (buf);
        if (shadowtcb_remove (user_name) == SHADOWTCB_FAILURE) {
-               fprintf (stderr, _("%s: Cannot remove tcb files for %s: %s\n"),
-                       Prog, user_name, strerrno());
+               fprinte(stderr, _("%s: Cannot remove tcb files for %s"), Prog, user_name);
                ret = 1;
        }
        return ret;
index 31addeb34e612fb3b5b97335474b5c187321670d..e2ec58bbef4adc651e25db2d96749af8958ffbe9 100644 (file)
@@ -38,6 +38,7 @@
 #include "faillog.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #include "pwauth.h"
@@ -64,7 +65,6 @@
 #include "string/strcmp/streq.h"
 #include "string/strcmp/strprefix.h"
 #include "string/strdup/strdup.h"
-#include "string/strerrno.h"
 #include "string/strspn/stprspn.h"
 #include "sysconf.h"
 #include "time/day_to_str.h"
@@ -373,9 +373,7 @@ prepend_range(const char *str, struct id_range_list_entry **head)
 
        entry = malloc_T(1, struct id_range_list_entry);
        if (!entry) {
-               fprintf (stderr,
-                       _("%s: failed to allocate memory: %s\n"),
-                       Prog, strerrno());
+               fprinte(stderr, _("%s: failed to allocate memory"), Prog);
                return 0;
        }
        entry->next = *head;
@@ -399,7 +397,7 @@ find_range(struct id_range_list_entry **head, uid_t uid,
 
        entry = malloc_T(1, struct id_range_list_entry);
        if (entry == NULL) {
-               fprintf(stderr, "%s: malloc: %s\n", Prog, strerrno());
+               fprinte(stderr, "%s: malloc", Prog);
                return 0;
        }
 
@@ -1967,9 +1965,8 @@ static void update_lastlog (void)
        fd = open(_PATH_LASTLOG, O_RDWR);
 
        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, strerrno());
+               fprinte(stderr, _("%s: failed to copy the lastlog entry of user %lu to user %lu"),
+                       Prog, (unsigned long) user_id, (unsigned long) user_newid);
                return;
        }
 
@@ -1979,9 +1976,8 @@ static void update_lastlog (void)
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
                    || (write_full(fd, &ll, sizeof(ll)) == -1)
                    || (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, strerrno());
+                       fprinte(stderr, _("%s: failed to copy the lastlog entry of user %lu to user %lu"),
+                               Prog, (unsigned long) user_id, (unsigned long) user_newid);
                }
        } else {
                /* Assume lseek or read failed because there is
@@ -1995,17 +1991,15 @@ static void update_lastlog (void)
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
                            || (write_full(fd, &ll, sizeof(ll)) == -1)
                            || (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, strerrno());
+                               fprinte(stderr, _("%s: failed to copy the lastlog entry of user %lu to user %lu"),
+                                       Prog, (unsigned long) user_id, (unsigned long) user_newid);
                        }
                }
        }
 
        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, strerrno());
+               fprinte(stderr, _("%s: failed to copy the lastlog entry of user %ju to user %ju"),
+                       Prog, (uintmax_t) user_id, (uintmax_t) user_newid);
        }
 }
 #endif /* ENABLE_LASTLOG */
@@ -2031,9 +2025,8 @@ static void update_faillog (void)
        fd = open (FAILLOG_FILE, O_RDWR);
 
        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, strerrno());
+               fprinte(stderr, _("%s: failed to copy the faillog entry of user %lu to user %lu"),
+                       Prog, (unsigned long) user_id, (unsigned long) user_newid);
                return;
        }
 
@@ -2043,9 +2036,8 @@ static void update_faillog (void)
                if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
                    || (write_full(fd, &fl, sizeof(fl)) == -1)
                    || (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, strerrno());
+                       fprinte(stderr, _("%s: failed to copy the faillog entry of user %lu to user %lu"),
+                               Prog, (unsigned long) user_id, (unsigned long) user_newid);
                }
        } else {
                /* Assume lseek or read failed because there is
@@ -2059,17 +2051,15 @@ static void update_faillog (void)
                        if (   (lseek (fd, off_newuid, SEEK_SET) != off_newuid)
                            || (write_full(fd, &fl, sizeof(fl)) == -1))
                        {
-                               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, strerrno());
+                               fprinte(stderr, _("%s: failed to copy the faillog entry of user %lu to user %lu"),
+                                       Prog, (unsigned long) user_id, (unsigned long) user_newid);
                        }
                }
        }
 
        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, strerrno());
+               fprinte(stderr, _("%s: failed to copy the faillog entry of user %ju to user %ju"),
+                       Prog, (uintmax_t) user_id, (uintmax_t) user_newid);
        }
 }
 
@@ -2250,17 +2240,17 @@ int main (int argc, char **argv)
 #ifdef ENABLE_SUBIDS
        if (Sflg) {
                if (find_range (&add_sub_uids, user_id, find_new_sub_uids) == 0) {
-                       fprint(stderr,
-                               _("%s: unable to find new subordinate uid range: %s\n"),
-                               Prog, strerrno());
+                       fprinte(stderr,
+                               _("%s: unable to find new subordinate uid range"),
+                               Prog);
                        SYSLOG(LOG_WARN, "unable to find new subordinate uid range: %s\n",
                               strerrno());
                        fail_exit (E_SUB_UID_UPDATE, process_selinux);
                }
                if (find_range (&add_sub_gids, user_id, find_new_sub_gids) == 0) {
-                       fprint(stderr,
-                               _("%s: unable to find new subordinate gid range: %s\n"),
-                               Prog, strerrno());
+                       fprinte(stderr,
+                               _("%s: unable to find new subordinate gid range"),
+                               Prog);
                        SYSLOG(LOG_WARN, "unable to find new subordinate gid range: %s\n",
                               strerrno());
                        fail_exit (E_SUB_GID_UPDATE, process_selinux);
index 05c2935fcd63d4f6e0e55c59f22b39725a3a6a78..0b0643d718282a6fa8fb455b93fe1ead35ea5026 100644 (file)
@@ -30,6 +30,7 @@
 #include "defines.h"
 #include "getdef.h"
 #include "groupio.h"
+#include "io/fprintf.h"
 #include "nscd.h"
 #include "prototypes.h"
 #include "pwio.h"
@@ -47,7 +48,6 @@
 #include "string/sprintf/aprintf.h"
 #include "string/sprintf/stprintf.h"
 #include "string/strcmp/streq.h"
-#include "string/strerrno.h"
 
 
 #define MSG_WARN_EDIT_OTHER_FILE _( \
@@ -314,7 +314,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, strerrno());
+                       fprinte(stderr, "%s: %s", Prog, editor);
                        exit (1);
                } else if (   WIFEXITED (status)
                           && (WEXITSTATUS (status) != 0)) {
@@ -349,20 +349,17 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
                        if (orig_pgrp != -1) {
                                editor_pgrp = tcgetpgrp(STDIN_FILENO);
                                if (editor_pgrp == -1) {
-                                       fprintf (stderr, "%s: %s: %s", Prog,
-                                               "tcgetpgrp", strerrno());
+                                       fprinte(stderr, "%s: %s", Prog, "tcgetpgrp");
                                }
                                if (tcsetpgrp(STDIN_FILENO, orig_pgrp) == -1) {
-                                       fprintf (stderr, "%s: %s: %s", Prog,
-                                               "tcsetpgrp", strerrno());
+                                       fprinte(stderr, "%s: %s", Prog, "tcsetpgrp");
                                }
                        }
                        kill (getpid (), SIGSTOP);
                        /* wake child when resumed */
                        if (editor_pgrp != -1) {
                                if (tcsetpgrp(STDIN_FILENO, editor_pgrp) == -1) {
-                                       fprintf (stderr, "%s: %s: %s", Prog,
-                                               "tcsetpgrp", strerrno());
+                                       fprinte(stderr, "%s: %s", Prog, "tcsetpgrp");
                                }
                        }
                        killpg (pid, SIGCONT);
@@ -374,7 +371,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", strerrno());
+                       fprinte(stderr, "%s: %s", Prog, "tcsetpgrp");
                }
                sigprocmask(SIG_SETMASK, &omask, NULL);
        }
@@ -444,9 +441,8 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (bool))
        unlink (filebackup);
        link (file, filebackup);
        if (rename (to_rename, file) == -1) {
-               fprintf (stderr,
-                        _("%s: can't restore %s: %s (your changes are in %s)\n"),
-                       Prog, file, strerrno(), to_rename);
+               fprinte(stderr, _("%s: can't restore %s (your changes are in %s)"),
+                       Prog, file, to_rename);
 #ifdef WITH_TCB
                if (tcb_mode) {
                        free(to_rename);