diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-16 18:24:33 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-16 18:24:33 +0000 |
commit | dd5753f8fb6df4bed736a5e28149872f1e22b232 (patch) | |
tree | 1100e277a3013f7eee6cbee9dd86c3e806b5a8d8 /lib/libutil/passwd.c | |
parent | 776a32a453266176bb3a1c6c60db0190758c6b9d (diff) |
Add new 'secureonly' arg to pw_mkdb() to correspond to pwd_mkdb's new -s
flag and crank the library major due to the interface change.
Diffstat (limited to 'lib/libutil/passwd.c')
-rw-r--r-- | lib/libutil/passwd.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/lib/libutil/passwd.c b/lib/libutil/passwd.c index ea86b1e1e3d..6912f7adae9 100644 --- a/lib/libutil/passwd.c +++ b/lib/libutil/passwd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: passwd.c,v 1.26 2001/07/11 16:11:10 aaron Exp $ */ +/* $OpenBSD: passwd.c,v 1.27 2001/08/16 18:24:32 millert Exp $ */ /* * Copyright (c) 1987, 1993, 1994, 1995 @@ -34,7 +34,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: passwd.c,v 1.26 2001/07/11 16:11:10 aaron Exp $"; +static char rcsid[] = "$OpenBSD: passwd.c,v 1.27 2001/08/16 18:24:32 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> @@ -273,33 +273,45 @@ pw_lock(retries) } int -pw_mkdb(username) +pw_mkdb(username, secureonly) char *username; + int secureonly; { - int pstat; + int pstat, ac; pid_t pid; + char *av[8]; struct stat sb; + if (pw_lck == NULL) + return(-1); + /* A zero length passwd file is never ok */ - if (pw_lck && stat(pw_lck, &sb) == 0) { - if (sb.st_size == 0) { - warnx("%s is zero length", pw_lck); - return (-1); - } + if (stat(pw_lck, &sb) == 0 && sb.st_size == 0) { + warnx("%s is zero length", pw_lck); + return (-1); } + ac = 0; + av[ac++] = "pwd_mkdb"; + av[ac++] = "-d"; + av[ac++] = pw_dir; + if (secureonly) + av[ac++] = "-s"; + else + av[ac++] = "-p"; + if (username) { + av[ac++] = "-u"; + av[ac++] = username; + } + av[ac++] = pw_lck; + av[ac] = NULL; + pid = vfork(); if (pid == -1) return (-1); if (pid == 0) { - if (pw_lck) { - if (username) - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", - pw_dir, "-u", username, pw_lck, (char *)NULL); - else - execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-d", - pw_dir, pw_lck, (char *)NULL); - } + if (pw_lck) + execv(_PATH_PWD_MKDB, av); _exit(1); } pid = waitpid(pid, &pstat, 0); |