From 07c6e99725c8126c452330491ca99d2332541822 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Thu, 18 Mar 2010 09:46:15 +0000 Subject: [PATCH] * src/pwck.c: Do not use pwd_file and spw_file. Always use the dbname() functions. --- ChangeLog | 5 +++++ src/pwck.c | 22 +++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 513b837f..5caa93d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2010-03-18 Nicolas François + + * src/pwck.c: Do not use pwd_file and spw_file. Always use the + dbname() functions. + 2010-03-18 Nicolas François * src/pwck.c: Re-indent. diff --git a/src/pwck.c b/src/pwck.c index 6ba7e647..0b8d2a3a 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -68,9 +68,7 @@ */ char *Prog; -static const char *pwd_file = PASSWD_FILE; static bool use_system_pw_file = true; -static const char *spw_file = SHADOW_FILE; static bool use_system_spw_file = true; static bool is_shadow = false; @@ -176,13 +174,11 @@ static void process_flags (int argc, char **argv) * and shadow password filenames. */ if (optind != argc) { - pwd_file = argv[optind]; - pw_setdbname (pwd_file); + pw_setdbname (argv[optind]); use_system_pw_file = false; } if ((optind + 2) == argc) { - spw_file = argv[optind + 1]; - spw_setdbname (spw_file); + spw_setdbname (argv[optind + 1]); is_shadow = true; use_system_spw_file = false; } else if (optind == argc) { @@ -210,7 +206,7 @@ static void open_files (void) if (pw_lock () == 0) { fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), - Prog, pwd_file); + Prog, pw_dbname ()); fail_exit (E_CANTLOCK); } pw_locked = true; @@ -231,9 +227,9 @@ static void open_files (void) */ if (pw_open (read_only ? O_RDONLY : O_RDWR) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), - Prog, pwd_file); + Prog, pw_dbname ()); if (use_system_pw_file) { - SYSLOG ((LOG_WARN, "cannot open %s", pwd_file)); + SYSLOG ((LOG_WARN, "cannot open %s", pw_dbname ())); } fail_exit (E_CANTOPEN); } @@ -269,10 +265,10 @@ static void close_files (bool changed) if (pw_opened && pw_close () == 0) { fprintf (stderr, _("%s: failure while writing changes to %s\n"), - Prog, pwd_file); + Prog, pw_dbname ()); SYSLOG ((LOG_ERR, "failure while writing changes to %s", - pwd_file)); + pw_dbname ())); fail_exit (E_CANTUPDATE); } pw_opened = false; @@ -571,7 +567,7 @@ static void check_pw_file (int *errors, bool *changed) */ if (strcmp (pwd->pw_passwd, SHADOW_PASSWD_STRING) != 0) { printf (_("user %s has an entry in %s, but its password field in %s is not set to 'x'\n"), - pwd->pw_name, spw_dbname (), pwd_file); + pwd->pw_name, spw_dbname (), pw_dbname ()); *errors += 1; } } @@ -722,7 +718,7 @@ static void check_spw_file (int *errors, bool *changed) * /etc/passwd entry and ask them to delete it. */ printf (_("no matching password file entry in %s\n"), - pwd_file); + pw_dbname ()); printf (_("delete line '%s'? "), spe->line); *errors += 1;