diff options
author | bapt <bapt@FreeBSD.org> | 2015-06-07 14:34:38 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-06-07 14:34:38 +0000 |
commit | c6afeed630caacfd5c4b23de8544bf606a30af8f (patch) | |
tree | d59491e160f454ebf02f9561c09e6251dad8727d /usr.sbin/pw/pwupd.c | |
parent | c31a38b994d9eeac6b476cf034ab84479d78acff (diff) | |
download | FreeBSD-src-c6afeed630caacfd5c4b23de8544bf606a30af8f.zip FreeBSD-src-c6afeed630caacfd5c4b23de8544bf606a30af8f.tar.gz |
Add a new global struct pwconf to store etcpath, rootdir and struct userconf
Do not add anymore -R and -V to arglist
Add an error message if both -V and -R are set in arguments
Diffstat (limited to 'usr.sbin/pw/pwupd.c')
-rw-r--r-- | usr.sbin/pw/pwupd.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c index 89d0856..f9e1959 100644 --- a/usr.sbin/pw/pwupd.c +++ b/usr.sbin/pw/pwupd.c @@ -44,28 +44,12 @@ static const char rcsid[] = #include "pwupd.h" -static char pathpwd[] = _PATH_PWD; -static char * pwpath = pathpwd; - -int -setpwdir(const char * dir) -{ - if (dir == NULL) - return (-1); - else - pwpath = strdup(dir); - if (pwpath == NULL) - return (-1); - - return (0); -} - char * getpwpath(char const * file) { static char pathbuf[MAXPATHLEN]; - snprintf(pathbuf, sizeof pathbuf, "%s/%s", pwpath, file); + snprintf(pathbuf, sizeof pathbuf, "%s/%s", conf.etcpath, file); return (pathbuf); } @@ -80,9 +64,9 @@ pwdb_check(void) args[i++] = _PATH_PWD_MKDB; args[i++] = "-C"; - if (pwpath != pathpwd) { + if (strcmp(conf.etcpath, _PATH_PWD) != 0) { args[i++] = "-d"; - args[i++] = pwpath; + args[i++] = conf.etcpath; } args[i++] = getpwpath(_MASTERPASSWD); args[i] = NULL; @@ -117,7 +101,7 @@ pw_update(struct passwd * pwd, char const * user) if (user != NULL) old_pw = GETPWNAM(user); - if (pw_init(pwpath, NULL)) + if (pw_init(conf.etcpath, NULL)) err(1, "pw_init()"); if ((pfd = pw_lock()) == -1) { pw_fini(); |