diff --git a/ChangeLog b/ChangeLog index 84bcb145..5ef40352 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-08-06 Nicolas François + + * src/chage.c: Report failure to unlock the passwd or shadow file + to stderr and syslog. + 2008-08-06 Nicolas François * src/pwconv.c: Report failure to unlock the passwd or shadow file diff --git a/src/chage.c b/src/chage.c index 2f7a859b..3f9e299e 100644 --- a/src/chage.c +++ b/src/chage.c @@ -109,10 +109,18 @@ static void fail_exit (int code); static void fail_exit (int code) { if (spw_locked) { - spw_unlock (); + if (spw_unlock () == 0) { + fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); + /* continue */ + } } if (pw_locked) { - pw_unlock (); + if (pw_unlock () == 0) { + fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ())); + /* continue */ + } } closelog (); @@ -616,9 +624,17 @@ static void close_files (void) SYSLOG ((LOG_ERR, "failure while writing changes to %s", pw_dbname ())); fail_exit (E_NOPERM); } - spw_unlock (); + if (spw_unlock () == 0) { + fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); + /* continue */ + } spw_locked = false; - pw_unlock (); + if (pw_unlock () == 0) { + fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); + SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ())); + /* continue */ + } pw_locked = false; }