[svn-upgrade] Integrating new upstream version, shadow (4.0.0)
This commit is contained in:
28
src/pwck.c
28
src/pwck.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID(PKG_VER "$Id: pwck.c,v 1.15 2000/09/02 18:40:44 marekm Exp $")
|
||||
RCSID(PKG_VER "$Id: pwck.c,v 1.16 2001/08/14 21:10:58 malekith Exp $")
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -95,9 +95,9 @@ static void
|
||||
usage(void)
|
||||
{
|
||||
#ifdef SHADOWPWD
|
||||
fprintf(stderr, _("Usage: %s [ -qr ] [ passwd [ shadow ] ]\n"), Prog);
|
||||
fprintf(stderr, _("Usage: %s [ -sqr ] [ passwd [ shadow ] ]\n"), Prog);
|
||||
#else
|
||||
fprintf(stderr, _("Usage: %s [ -qr ] [ passwd ]\n"), Prog);
|
||||
fprintf(stderr, _("Usage: %s [ -sqr ] [ passwd ]\n"), Prog);
|
||||
#endif
|
||||
exit(E_USAGE);
|
||||
}
|
||||
@@ -142,6 +142,7 @@ main(int argc, char **argv)
|
||||
int deleted = 0;
|
||||
struct commonio_entry *pfe, *tpfe;
|
||||
struct passwd *pwd;
|
||||
int sort_mode = 0;
|
||||
#ifdef SHADOWPWD
|
||||
struct commonio_entry *spe, *tspe;
|
||||
struct spwd *spw;
|
||||
@@ -164,7 +165,7 @@ main(int argc, char **argv)
|
||||
* Parse the command line arguments
|
||||
*/
|
||||
|
||||
while ((arg = getopt(argc, argv, "eqr")) != EOF) {
|
||||
while ((arg = getopt(argc, argv, "eqrs")) != EOF) {
|
||||
switch (arg) {
|
||||
case 'e': /* added for Debian shadow-961025-2 compatibility */
|
||||
case 'q':
|
||||
@@ -173,11 +174,20 @@ main(int argc, char **argv)
|
||||
case 'r':
|
||||
read_only = 1;
|
||||
break;
|
||||
case 's':
|
||||
sort_mode = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (sort_mode && read_only) {
|
||||
fprintf(stderr, _("%s: -s and -r are incompatibile\n"),
|
||||
Prog);
|
||||
exit(E_USAGE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make certain we have the right number of arguments
|
||||
*/
|
||||
@@ -256,6 +266,15 @@ main(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sort_mode) {
|
||||
pw_sort();
|
||||
#ifdef SHADOWPWD
|
||||
if (is_shadow)
|
||||
spw_sort();
|
||||
#endif
|
||||
goto write_and_bye;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop through the entire password file.
|
||||
*/
|
||||
@@ -568,6 +587,7 @@ shadow_done:
|
||||
*/
|
||||
|
||||
if (deleted) {
|
||||
write_and_bye:
|
||||
if (!pw_close()) {
|
||||
fprintf(stderr, _("%s: cannot update file %s\n"),
|
||||
Prog, pwd_file);
|
||||
|
Reference in New Issue
Block a user