New option: [-c]
Check if the password file is in the correct format. Do not change, add, or remove any files.
This commit is contained in:
parent
7ea944f3a6
commit
e2ab8bac10
@ -39,6 +39,7 @@
|
||||
.Nd "generate the password databases"
|
||||
.Sh SYNOPSIS
|
||||
.Nm pwd_mkdb
|
||||
.Op Fl c
|
||||
.Op Fl p
|
||||
.Op Fl d Ar directory
|
||||
.Ar file
|
||||
@ -61,6 +62,9 @@ different from the historic Version 7 style format.
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width flag
|
||||
.It Fl c
|
||||
Check if the password file is in the correct format. Do not
|
||||
change, add, or remove any files.
|
||||
.It Fl p
|
||||
Create a Version 7 style password file and install it into
|
||||
.Dq Pa /etc/passwd .
|
||||
|
@ -101,12 +101,17 @@ main(argc, argv)
|
||||
char sbuf2[MAXPATHLEN];
|
||||
char *username;
|
||||
u_int method, methoduid;
|
||||
int cflag;
|
||||
|
||||
cflag = 0;
|
||||
strcpy(prefix, _PATH_PWD);
|
||||
makeold = 0;
|
||||
username = NULL;
|
||||
while ((ch = getopt(argc, argv, "d:pu:v")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "cd:pu:v")) != EOF)
|
||||
switch(ch) {
|
||||
case 'c': /* verify only */
|
||||
cflag = 1;
|
||||
break;
|
||||
case 'd':
|
||||
strcpy(prefix, optarg);
|
||||
break;
|
||||
@ -118,7 +123,6 @@ main(argc, argv)
|
||||
break;
|
||||
case 'v': /* backward compatible */
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
@ -148,6 +152,12 @@ main(argc, argv)
|
||||
if (!(fp = fopen(pname, "r")))
|
||||
error(pname);
|
||||
|
||||
/* check only if password database is valid */
|
||||
if (cflag) {
|
||||
for (cnt = 1; scan(fp, &pwd); ++cnt);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Open the temporary insecure password database. */
|
||||
(void)snprintf(buf, sizeof(buf), "%s/%s.tmp", prefix, _MP_DB);
|
||||
(void)snprintf(sbuf, sizeof(sbuf), "%s/%s.tmp", prefix, _SMP_DB);
|
||||
@ -526,6 +536,6 @@ void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: pwd_mkdb [-p] [-d <dest dir>] [-u <local username>] file\n");
|
||||
(void)fprintf(stderr, "usage: pwd_mkdb [-c] [-p] [-d <dest dir>] [-u <local username>] file\n");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user