Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Aug 1996 23:03:13 +0200
From:      Wolfram Schneider <wosch@cs.tu-berlin.de>
To:        current@freebsd.org
Subject:   pwd_mkdb check option 
Message-ID:  <199608122103.XAA00867@campa.panke.de>

next in thread | raw e-mail | index | archive | help

Comments? Can someone test if this patch works with NIS?

-c
	Check if the password file is in the correct format. Do not
	change, add, or remove any files.

Index: pwd_mkdb.8
===================================================================
RCS file: /usr/cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.8,v
retrieving revision 1.2
diff -u -r1.2 pwd_mkdb.8
--- 1.2	1994/09/07 22:54:00
+++ pwd_mkdb.8	1996/08/12 18:37:34
@@ -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 @@
 .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 .
Index: pwd_mkdb.c
===================================================================
RCS file: /usr/cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.13
diff -u -r1.13 pwd_mkdb.c
--- 1.13	1996/07/12 08:20:28
+++ pwd_mkdb.c	1996/08/12 18:33:24
@@ -101,12 +101,17 @@
 	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 @@
 			break;
 		case 'v':                       /* backward compatible */
 			break;
-		case '?':
 		default:
 			usage();
 		}
@@ -148,6 +152,12 @@
 	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 @@
 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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608122103.XAA00867>