From: Alejandro Colomar Date: Wed, 23 Jul 2025 15:39:19 +0000 (+0200) Subject: lib/, tests/: Use fprinte() instead of its pattern X-Git-Tag: 4.20.0-rc3~27 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f7c712c3ade10c1d14916ea44408e42495fd1a8a;p=thirdparty%2Fshadow.git lib/, tests/: Use fprinte() instead of its pattern 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 --- diff --git a/lib/addgrps.c b/lib/addgrps.c index a8fbbb508..7413ef911 100644 --- a/lib/addgrps.c +++ b/lib/addgrps.c @@ -20,12 +20,12 @@ #include #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; } diff --git a/lib/chowntty.c b/lib/chowntty.c index 64f63d706..dc29203ee 100644 --- a/lib/chowntty.c +++ b/lib/chowntty.c @@ -16,10 +16,12 @@ #include #include #include -#include "prototypes.h" -#include "defines.h" #include + +#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)); diff --git a/lib/commonio.c b/lib/commonio.c index b20388318..da530ef22 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -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 @@ -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); } } diff --git a/lib/exit_if_null.h b/lib/exit_if_null.h index 6045bbcd1..308e2edf6 100644 --- a/lib/exit_if_null.h +++ b/lib/exit_if_null.h @@ -12,8 +12,8 @@ #include #include +#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); } } diff --git a/lib/find_new_gid.c b/lib/find_new_gid.c index 4e458cf0b..e25f191b9 100644 --- a/lib/find_new_gid.c +++ b/lib/find_new_gid.c @@ -13,11 +13,11 @@ #include #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; } diff --git a/lib/find_new_uid.c b/lib/find_new_uid.c index 9ca6953f0..99e98c492 100644 --- a/lib/find_new_uid.c +++ b/lib/find_new_uid.c @@ -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 @@ -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; } diff --git a/lib/get_pid.c b/lib/get_pid.c index 719ddb405..1ef063e8d 100644 --- a/lib/get_pid.c +++ b/lib/get_pid.c @@ -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; diff --git a/lib/gettime.c b/lib/gettime.c index 0d1d59086..bf52a8bb1 100644 --- a/lib/gettime.c +++ b/lib/gettime.c @@ -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; diff --git a/lib/idmapping.c b/lib/idmapping.c index 77631ec18..ad399b38f 100644 --- a/lib/idmapping.c +++ b/lib/idmapping.c @@ -24,12 +24,12 @@ #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); diff --git a/lib/prefix_flag.c b/lib/prefix_flag.c index 7496805e9..db8c1dc4b 100644 --- a/lib/prefix_flag.c +++ b/lib/prefix_flag.c @@ -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); } diff --git a/lib/root_flag.c b/lib/root_flag.c index 38ef0b4cd..064289afa 100644 --- a/lib/root_flag.c +++ b/lib/root_flag.c @@ -14,11 +14,11 @@ #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); } } diff --git a/lib/run_part.c b/lib/run_part.c index 97b520663..88864e3d0 100644 --- a/lib/run_part.c +++ b/lib/run_part.c @@ -11,10 +11,10 @@ #include #include +#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 #include +#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()); diff --git a/lib/spawn.c b/lib/spawn.c index ff81cc920..8e1750dc1 100644 --- a/lib/spawn.c +++ b/lib/spawn.c @@ -14,9 +14,9 @@ #include #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; } diff --git a/lib/tcbfuncs.c b/lib/tcbfuncs.c index c7cded8ab..fe0f13541 100644 --- a/lib/tcbfuncs.c +++ b/lib/tcbfuncs.c @@ -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) { - fprintf (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) diff --git a/src/chage.c b/src/chage.c index ac215ec14..5511394a7 100644 --- a/src/chage.c +++ b/src/chage.c @@ -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); } diff --git a/src/chgpasswd.c b/src/chgpasswd.c index e77ecc6ac..347a202eb 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -20,10 +20,11 @@ #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); } } diff --git a/src/chpasswd.c b/src/chpasswd.c index 9c2c5e790..bbbe4626e 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -25,9 +25,10 @@ #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); } } diff --git a/src/faillog.c b/src/faillog.c index 28cf7f58e..027f315c3 100644 --- a/src/faillog.c +++ b/src/faillog.c @@ -20,13 +20,13 @@ #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; } diff --git a/src/free_subid_range.c b/src/free_subid_range.c index fcce80b4b..5dca40d43 100644 --- a/src/free_subid_range.c +++ b/src/free_subid_range.c @@ -5,7 +5,7 @@ #include #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; diff --git a/src/get_subid_owners.c b/src/get_subid_owners.c index 653691374..49d1ce1a3 100644 --- a/src/get_subid_owners.c +++ b/src/get_subid_owners.c @@ -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(); } diff --git a/src/getsubids.c b/src/getsubids.c index 386c66d6f..622e44b84 100644 --- a/src/getsubids.c +++ b/src/getsubids.c @@ -5,9 +5,9 @@ #include #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]; diff --git a/src/gpasswd.c b/src/gpasswd.c index bb53087c6..1e207c34c 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -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 diff --git a/src/groupadd.c b/src/groupadd.c index 3c4ac8b13..f29ff83fe 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -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); } diff --git a/src/lastlog.c b/src/lastlog.c index ae172a0b6..97ad355da 100644 --- a/src/lastlog.c +++ b/src/lastlog.c @@ -25,14 +25,14 @@ #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); } diff --git a/src/login.c b/src/login.c index 216e9ac3d..57ddaa66c 100644 --- a/src/login.c +++ b/src/login.c @@ -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); diff --git a/src/new_subid_range.c b/src/new_subid_range.c index bca379d8b..978e4ef65 100644 --- a/src/new_subid_range.c +++ b/src/new_subid_range.c @@ -4,7 +4,7 @@ #include #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; diff --git a/src/newgidmap.c b/src/newgidmap.c index afda66657..1faca380f 100644 --- a/src/newgidmap.c +++ b/src/newgidmap.c @@ -17,10 +17,10 @@ #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; } diff --git a/src/newgrp.c b/src/newgrp.c index 0f12d577b..b8f2e37f2 100644 --- a/src/newgrp.c +++ b/src/newgrp.c @@ -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 @@ -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, diff --git a/src/newuidmap.c b/src/newuidmap.c index 108852eae..bf3b8730e 100644 --- a/src/newuidmap.c +++ b/src/newuidmap.c @@ -17,10 +17,10 @@ #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; } diff --git a/src/newusers.c b/src/newusers.c index 2baf1f567..7b544fe89 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -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) { - 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; } 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) { - 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; } 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) { - fprintf (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) { - fprintf (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); diff --git a/src/passwd.c b/src/passwd.c index 2a4697518..520c1de8b 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -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; } diff --git a/src/useradd.c b/src/useradd.c index 9b52c8fc8..643a029d6 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -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) { - fprintf (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) { - fprintf (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); diff --git a/src/userdel.c b/src/userdel.c index ebd064c06..ad36a97d0 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -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; diff --git a/src/usermod.c b/src/usermod.c index 31addeb34..e2ec58bbe 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -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) { - fprintf (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) { - fprintf (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); diff --git a/src/vipw.c b/src/vipw.c index 05c2935fc..0b0643d71 100644 --- a/src/vipw.c +++ b/src/vipw.c @@ -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);