From owner-freebsd-current Mon Aug 12 15:37:57 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id PAA01334 for current-outgoing; Mon, 12 Aug 1996 15:37:57 -0700 (PDT) Received: from mail.cs.tu-berlin.de (root@mail.cs.tu-berlin.de [130.149.17.13]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id PAA01324 for ; Mon, 12 Aug 1996 15:37:52 -0700 (PDT) Received: from campa.panke.de (anonymous213.ppp.cs.tu-berlin.de [130.149.17.213]) by mail.cs.tu-berlin.de (8.6.12/8.6.12) with ESMTP id AAA23571 for ; Tue, 13 Aug 1996 00:23:59 +0200 Received: (from wosch@localhost) by campa.panke.de (8.6.12/8.6.12) id XAA00867; Mon, 12 Aug 1996 23:03:13 +0200 Date: Mon, 12 Aug 1996 23:03:13 +0200 From: Wolfram Schneider Message-Id: <199608122103.XAA00867@campa.panke.de> To: current@freebsd.org Subject: pwd_mkdb check option Reply-to: Wolfram Schneider MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 ] [-u ] file\n"); + (void)fprintf(stderr, "usage: pwd_mkdb [-c] [-p] [-d ] [-u ] file\n"); exit(1); }