diff --git a/ChangeLog b/ChangeLog index 19475c77..a80f612a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-08-17 Nicolas François + + * src/chage.c, src/chgpasswd.c, src/chpasswd.c, src/chsh.c, + src/gpasswd.c, src/groupadd.c, src/groupdel.c, src/groupmems.c, + src/groupmod.c, src/grpck.c, src/grpconv.c, src/grpunconv.c, + src/newusers.c, src/passwd.c, src/pwck.c, src/pwconv.c, + src/pwunconv.c, src/useradd.c, src/userdel.c, src/usermod.c: In + case of a lock failure, indicate to the user that she can try + again later. Do not log to syslog. + 2008-08-17 Nicolas François * NEWS, src/passwd.c: For compatibility with other passwd version, diff --git a/src/chage.c b/src/chage.c index 3f9e299e..91a338ec 100644 --- a/src/chage.c +++ b/src/chage.c @@ -561,13 +561,13 @@ static void open_files (bool readonly) * file entries into memory. Then we get a pointer to the password * file entry for the requested user. */ - if (!readonly && (pw_lock () == 0)) { - fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, pw_dbname ()); - SYSLOG ((LOG_ERR, "cannot lock %s", pw_dbname ())); - fail_exit (E_NOPERM); - } if (!readonly) { + if (pw_lock () == 0) { + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); + fail_exit (E_NOPERM); + } pw_locked = true; } if (pw_open (readonly ? O_RDONLY: O_RDWR) == 0) { @@ -582,13 +582,13 @@ static void open_files (bool readonly) * does not have to exist in this case; a new entry will be created * for this user if one does not exist already. */ - if (!readonly && (spw_lock () == 0)) { - fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, spw_dbname ()); - SYSLOG ((LOG_ERR, "cannot lock %s", spw_dbname ())); - fail_exit (E_NOPERM); - } if (!readonly) { + if (spw_lock () == 0) { + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, spw_dbname ()); + fail_exit (E_NOPERM); + } spw_locked = true; } if (spw_open (readonly ? O_RDONLY: O_RDWR) == 0) { diff --git a/src/chgpasswd.c b/src/chgpasswd.c index 1b4f237e..4fb02b0b 100644 --- a/src/chgpasswd.c +++ b/src/chgpasswd.c @@ -290,7 +290,8 @@ static void open_files (void) */ if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (1); } group_locked = true; @@ -304,7 +305,8 @@ static void open_files (void) /* Do the same for the shadowed database, if it exist */ if (is_shadow_grp) { if (sgr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (1); } diff --git a/src/chpasswd.c b/src/chpasswd.c index ace0ea60..136bf6b6 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -284,7 +284,8 @@ static void open_files (void) */ if (pw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); fail_exit (1); } passwd_locked = true; @@ -298,7 +299,7 @@ static void open_files (void) if (is_shadow_pwd) { if (spw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (1); } diff --git a/src/chsh.c b/src/chsh.c index 4f531f61..e1c68709 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -365,7 +365,6 @@ static void update_shell (const char *user, char *newshell) if (pw_lock () == 0) { fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ())); fail_exit (1); } pw_locked = true; diff --git a/src/gpasswd.c b/src/gpasswd.c index d4dd16bc..2a087488 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -368,8 +368,9 @@ static void check_flags (int argc, int opt_index) static void open_files (void) { if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ())); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking /etc/group", @@ -382,8 +383,8 @@ static void open_files (void) if (is_shadowgrp) { if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ())); + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking /etc/gshadow", diff --git a/src/groupadd.c b/src/groupadd.c index 4bc7b810..25e94009 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -298,8 +298,9 @@ static void close_files (void) static void open_files (void) { if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ())); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking group file", @@ -322,8 +323,8 @@ static void open_files (void) if (is_shadow_grp) { if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ())); + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking gshadow file", diff --git a/src/groupdel.c b/src/groupdel.c index 3866b40a..1d10aedd 100644 --- a/src/groupdel.c +++ b/src/groupdel.c @@ -222,8 +222,8 @@ static void open_files (void) { if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, gr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s",gr_dbname ())); + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } group_locked = true; @@ -237,9 +237,8 @@ static void open_files (void) if (is_shadow_grp) { if (sgr_lock () == 0)) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ())); fail_exit (E_GRP_UPDATE); } gshadow_locked = true; diff --git a/src/groupmems.c b/src/groupmems.c index d3aa0da4..5d26977a 100644 --- a/src/groupmems.c +++ b/src/groupmems.c @@ -254,7 +254,7 @@ int main (int argc, char **argv) if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, gr_dbname ()); fail_exit (EXIT_GROUP_FILE); } diff --git a/src/groupmod.c b/src/groupmod.c index 49ade1e8..cc31a218 100644 --- a/src/groupmod.c +++ b/src/groupmod.c @@ -586,8 +586,9 @@ static void close_files (void) static void open_files (void) { if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", gr_dbname ())); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } group_locked = true; @@ -600,9 +601,8 @@ static void open_files (void) if (is_shadow_grp) { if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", sgr_dbname ())); fail_exit (E_GRP_UPDATE); } gshadow_locked = true; @@ -618,9 +618,8 @@ static void open_files (void) if (gflg) { if (pw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ())); fail_exit (E_GRP_UPDATE); } passwd_locked = true; diff --git a/src/grpck.c b/src/grpck.c index d0619108..6f734440 100644 --- a/src/grpck.c +++ b/src/grpck.c @@ -211,21 +211,17 @@ static void open_files (void) */ if (!read_only) { if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), Prog, grp_file); - if (use_system_grp_file) { - SYSLOG ((LOG_WARN, "cannot lock %s", grp_file)); - } closelog (); exit (E_CANT_LOCK); } #ifdef SHADOWGRP if (is_shadow && (sgr_lock () == 0)) { - fprintf (stderr, _("%s: cannot lock %s\n"), + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), Prog, sgr_file); - if (use_system_sgr_file) { - SYSLOG ((LOG_WARN, "cannot lock %s", sgr_file)); - } closelog (); exit (E_CANT_LOCK); } diff --git a/src/grpconv.c b/src/grpconv.c index 5b7ef056..beb31574 100644 --- a/src/grpconv.c +++ b/src/grpconv.c @@ -83,7 +83,9 @@ int main (int argc, char **argv) (void) textdomain (PACKAGE); if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (5); } group_locked = true; @@ -93,7 +95,9 @@ int main (int argc, char **argv) } if (sgr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); fail_exit (5); } gshadow_locked = true; diff --git a/src/grpunconv.c b/src/grpunconv.c index 8cc1fdb6..cb88f9d4 100644 --- a/src/grpunconv.c +++ b/src/grpunconv.c @@ -98,7 +98,8 @@ int main (int argc, char **argv) if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (5); } group_locked = true; @@ -110,7 +111,8 @@ int main (int argc, char **argv) if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); fail_exit (5); } gshadow_locked = true; diff --git a/src/newusers.c b/src/newusers.c index d6ba0fe2..eacfdfd6 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -608,23 +608,31 @@ static void open_files (void) * it gets locked, assume the others can be locked right away. */ if (pw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); fail_exit (1); } passwd_locked = true; if (is_shadow && (spw_lock () == 0)) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, spw_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, spw_dbname ()); fail_exit (1); } shadow_locked = true; if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (1); } group_locked = true; #ifdef SHADOWGRP if (is_shadow_grp && (sgr_lock () == 0)) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); fail_exit (1); } gshadow_locked = true; diff --git a/src/passwd.c b/src/passwd.c index 938e3d51..9d19cd46 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -515,7 +515,6 @@ static void update_noshadow (void) fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", pw_dbname ())); exit (E_PWDBUSY); } if (pw_open (O_RDWR) == 0) { @@ -561,7 +560,6 @@ static void update_shadow (void) fprintf (stderr, _("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); - SYSLOG ((LOG_WARN, "cannot lock %s", spw_dbname ())); exit (E_PWDBUSY); } if (spw_open (O_RDWR) == 0) { diff --git a/src/pwck.c b/src/pwck.c index 36ea2366..dac85557 100644 --- a/src/pwck.c +++ b/src/pwck.c @@ -197,21 +197,17 @@ static void open_files (void) */ if (!read_only) { if (pw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), Prog, pwd_file); - if (use_system_pw_file) { - SYSLOG ((LOG_WARN, "cannot lock %s", pwd_file)); - } fail_exit (E_CANTLOCK); } pw_locked = true; if (is_shadow) { if (spw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), Prog, spw_file); - if (use_system_spw_file) { - SYSLOG ((LOG_WARN, "cannot lock %s", spw_file)); - } fail_exit (E_CANTLOCK); } spw_locked = true; diff --git a/src/pwconv.c b/src/pwconv.c index e0443d0c..81478bdb 100644 --- a/src/pwconv.c +++ b/src/pwconv.c @@ -127,7 +127,8 @@ int main (int argc, char **argv) if (pw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); fail_exit (E_PWDBUSY); } passwd_locked = true; @@ -139,7 +140,8 @@ int main (int argc, char **argv) if (spw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, spw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, spw_dbname ()); fail_exit (E_PWDBUSY); } shadow_locked = true; diff --git a/src/pwunconv.c b/src/pwunconv.c index fb6d2af8..562c151a 100644 --- a/src/pwunconv.c +++ b/src/pwunconv.c @@ -93,7 +93,7 @@ int main (int argc, char **argv) if (pw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, pw_dbname ()); fail_exit (5); } @@ -107,7 +107,7 @@ int main (int argc, char **argv) if (spw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (5); } diff --git a/src/useradd.c b/src/useradd.c index 4d81f6d4..83ef0769 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -1327,7 +1327,9 @@ static void close_files (void) static void open_files (void) { if (pw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); exit (E_PW_UPDATE); } passwd_locked = true; @@ -1338,7 +1340,7 @@ static void open_files (void) if (is_shadow_pwd) { if (spw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, spw_dbname ()); fail_exit (E_PW_UPDATE); } @@ -1355,7 +1357,9 @@ static void open_files (void) * Lock and open the group file. */ if (gr_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } group_locked = true; @@ -1367,7 +1371,7 @@ static void open_files (void) if (is_shadow_grp) { if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), + _("%s: cannot lock %s; try again later.\n"), Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } diff --git a/src/userdel.c b/src/userdel.c index b64a1fb0..1cb8ce5e 100644 --- a/src/userdel.c +++ b/src/userdel.c @@ -429,7 +429,9 @@ static void fail_exit (int code) static void open_files (void) { if (pw_lock () == 0) { - fprintf (stderr, _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + fprintf (stderr, + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking password file", @@ -451,7 +453,8 @@ static void open_files (void) if (is_shadow_pwd) { if (spw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, spw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, spw_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking shadow password file", @@ -462,7 +465,8 @@ static void open_files (void) shadow_locked = true; if (spw_open (O_RDWR) == 0) { fprintf (stderr, - _("%s: cannot open %s\n"), Prog, spw_dbname ()); + _("%s: cannot open %s\n"), + Prog, spw_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "opening shadow password file", @@ -473,7 +477,8 @@ static void open_files (void) } if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking group file", @@ -495,7 +500,8 @@ static void open_files (void) if (is_shadow_grp) { if (sgr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); #ifdef WITH_AUDIT audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "locking shadow group file", diff --git a/src/usermod.c b/src/usermod.c index fe145f73..99f53a57 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -1197,7 +1197,8 @@ static void open_files (void) { if (pw_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, pw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, pw_dbname ()); fail_exit (E_PW_UPDATE); } pw_locked = true; @@ -1208,7 +1209,8 @@ static void open_files (void) } if (is_shadow_pwd && (spw_lock () == 0)) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, spw_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, spw_dbname ()); fail_exit (E_PW_UPDATE); } spw_locked = true; @@ -1225,7 +1227,8 @@ static void open_files (void) */ if (gr_lock () == 0) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, gr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, gr_dbname ()); fail_exit (E_GRP_UPDATE); } gr_locked = true; @@ -1237,7 +1240,8 @@ static void open_files (void) #ifdef SHADOWGRP if (is_shadow_grp && (sgr_lock () == 0)) { fprintf (stderr, - _("%s: cannot lock %s\n"), Prog, sgr_dbname ()); + _("%s: cannot lock %s; try again later.\n"), + Prog, sgr_dbname ()); fail_exit (E_GRP_UPDATE); } sgr_locked = true;