From 038f23db196442159b06c81a4252f05555ac884e Mon Sep 17 00:00:00 2001 From: sheldonh Date: Sat, 26 Jun 1999 07:16:42 +0000 Subject: Add -d option to vipw(8) to allow selection of an alternative directory for the password files. PR: 2703 Submitted by: jmg --- usr.sbin/vipw/vipw.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'usr.sbin/vipw/vipw.c') diff --git a/usr.sbin/vipw/vipw.c b/usr.sbin/vipw/vipw.c index 30b789e..c555690 100644 --- a/usr.sbin/vipw/vipw.c +++ b/usr.sbin/vipw/vipw.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)vipw.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: vipw.c,v 1.5 1997/10/27 07:53:22 charnier Exp $"; #endif /* not lint */ #include @@ -57,6 +57,8 @@ static const char rcsid[] = #include "pw_util.h" +extern char *mppath; +extern char *masterpasswd; char *tempname; void copyfile __P((int, int)); @@ -71,8 +73,21 @@ main(argc, argv) struct stat begin, end; int ch; - while ((ch = getopt(argc, argv, "")) != -1) + while ((ch = getopt(argc, argv, "d:")) != -1) switch (ch) { + case 'd': + if ((masterpasswd = malloc(strlen(optarg) + + strlen(_MASTERPASSWD) + 2)) == NULL) + err(1, NULL); + strcpy(masterpasswd, optarg); + if (masterpasswd[strlen(masterpasswd) - 1] != '/') + masterpasswd[strlen(masterpasswd)] = '/'; + strcat(masterpasswd, _MASTERPASSWD); + if ((mppath = strdup(optarg)) == NULL) + err(1, NULL); + if (mppath[strlen(mppath) - 1] == '/') + mppath[strlen(mppath) - 1] = '\0'; + break; case '?': default: usage(); @@ -126,6 +141,6 @@ static void usage() { - (void)fprintf(stderr, "usage: vipw\n"); + (void)fprintf(stderr, "usage: vipw [ -d directory ]\n"); exit(1); } -- cgit v1.1