diff options
author | wosch <wosch@FreeBSD.org> | 1996-08-19 16:03:15 +0000 |
---|---|---|
committer | wosch <wosch@FreeBSD.org> | 1996-08-19 16:03:15 +0000 |
commit | 62a6bfaf7af4ee21d2b948141ae2e1700e9e2091 (patch) | |
tree | b027be7f5adf8c95dd0f27f33f34235fda73eb26 /usr.sbin/pwd_mkdb/pwd_mkdb.c | |
parent | 8720405f01ddad212948544d9a5cfbb66822672a (diff) | |
download | FreeBSD-src-62a6bfaf7af4ee21d2b948141ae2e1700e9e2091.zip FreeBSD-src-62a6bfaf7af4ee21d2b948141ae2e1700e9e2091.tar.gz |
New option: [-c]
Check if the password file is in the correct format. Do not
change, add, or remove any files.
Diffstat (limited to 'usr.sbin/pwd_mkdb/pwd_mkdb.c')
-rw-r--r-- | usr.sbin/pwd_mkdb/pwd_mkdb.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c index c4fa479..03d24b9 100644 --- a/usr.sbin/pwd_mkdb/pwd_mkdb.c +++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c @@ -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); } |