diff options
author | sheldonh <sheldonh@FreeBSD.org> | 1999-06-26 07:16:42 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 1999-06-26 07:16:42 +0000 |
commit | 038f23db196442159b06c81a4252f05555ac884e (patch) | |
tree | cfe5519e7f09f7afdb786829f44b15b699ca4581 /lib/libutil/pw_util.c | |
parent | f8e5afd1931bde320bcbf134be48213201848fa0 (diff) | |
download | FreeBSD-src-038f23db196442159b06c81a4252f05555ac884e.zip FreeBSD-src-038f23db196442159b06c81a4252f05555ac884e.tar.gz |
Add -d option to vipw(8) to allow selection of an alternative directory
for the password files.
PR: 2703
Submitted by: jmg
Diffstat (limited to 'lib/libutil/pw_util.c')
-rw-r--r-- | lib/libutil/pw_util.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index 2003cd6..cdfcc4d 100644 --- a/lib/libutil/pw_util.c +++ b/lib/libutil/pw_util.c @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id: pw_util.c,v 1.12 1998/12/13 01:36:45 dillon Exp $"; + "$Id: pw_util.c,v 1.13 1998/12/13 01:39:32 dillon Exp $"; #endif /* not lint */ /* @@ -66,6 +66,8 @@ static const char rcsid[] = extern char *tempname; static pid_t editpid = -1; static int lockfd; +char *mppath = _PATH_PWD; +char *masterpasswd = _PATH_MASTERPASSWD; void pw_cont(sig) @@ -118,9 +120,9 @@ pw_lock() for (;;) { struct stat st; - lockfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0); + lockfd = open(masterpasswd, O_RDONLY, 0); if (lockfd < 0 || fcntl(lockfd, F_SETFD, 1) == -1) - err(1, "%s", _PATH_MASTERPASSWD); + err(1, "%s", masterpasswd); if (flock(lockfd, LOCK_EX|LOCK_NB)) errx(1, "the password db file is busy"); @@ -142,10 +144,13 @@ pw_lock() int pw_tmp() { - static char path[MAXPATHLEN] = _PATH_MASTERPASSWD; + static char path[MAXPATHLEN]; int fd; char *p; + strncpy(path, masterpasswd, MAXPATHLEN - 1); + path[MAXPATHLEN] = '\0'; + if ((p = strrchr(path, '/'))) ++p; else @@ -168,11 +173,12 @@ char *username; if (!(pid = fork())) { if(!username) { warnx("rebuilding the database..."); - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); + execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath, + tempname, NULL); } else { warnx("updating the database..."); - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-u", - username, tempname, NULL); + execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", mppath, + "-u", username, tempname, NULL); } pw_error(_PATH_PWD_MKDB, 1, 1); } @@ -250,7 +256,7 @@ pw_error(name, err, eval) warnx("NIS information unchanged"); else #endif /* YP */ - warnx("%s: unchanged", _PATH_MASTERPASSWD); + warnx("%s: unchanged", masterpasswd); (void)unlink(tempname); exit(eval); } |