diff --git a/ChangeLog b/ChangeLog index 1ae91212..fa76576a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-09-18 Nicolas François + + * src/pwconv.c: Fail if not called correctly. + * src/pwconv.c: At the end of main, the passwd and shadow files + are locked. No need to check before unlocking. + 2011-09-18 Nicolas François * src/newusers.c: Initially set the passwd's password to '*' diff --git a/src/pwconv.c b/src/pwconv.c index 8d004504..e103d6e4 100644 --- a/src/pwconv.c +++ b/src/pwconv.c @@ -1,7 +1,7 @@ /* * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2002 - 2006, Tomasz Kłoczko - * Copyright (c) 2009 , Nicolas François + * Copyright (c) 2009 - 2011, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -124,6 +124,7 @@ int main (int argc, char **argv) if (1 != argc) { (void) fputs (_("Usage: pwconv\n"), stderr); + fail_exit (E_USAGE); } Prog = Basename (argv[0]); @@ -260,20 +261,16 @@ int main (int argc, char **argv) /* continue */ } - if (pw_locked) { - 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 */ - } + 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 */ } - if (spw_locked) { - 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 (spw_unlock () == 0) { + fprintf (stderr, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); + SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); + /* continue */ } nscd_flush_cache ("passwd");