summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorSheldon Hearn <sheldonh@FreeBSD.org>1999-06-26 07:16:42 +0000
committerSheldon Hearn <sheldonh@FreeBSD.org>1999-06-26 07:16:42 +0000
commit58f855136d43c7a2d0230149b4738f9d7acd8b31 (patch)
tree333d00024befdc1122a08de211d55d6e0427a881 /libutil
parente7e9d20da36ec9757300784f37aed5181d178894 (diff)
downloadpw-darwin-58f855136d43c7a2d0230149b4738f9d7acd8b31.tar.gz
pw-darwin-58f855136d43c7a2d0230149b4738f9d7acd8b31.tar.zst
pw-darwin-58f855136d43c7a2d0230149b4738f9d7acd8b31.zip
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 'libutil')
-rw-r--r--libutil/pw_util.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c
index 2003cd6..cdfcc4d 100644
--- a/libutil/pw_util.c
+++ b/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);
}