summaryrefslogtreecommitdiffstats
path: root/pw/pwupd.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 14:34:38 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-06-07 14:34:38 +0000
commit39d77815028ba1a72509c07e0a8583493f6ec0a8 (patch)
treee3b778855ca7b7ba0df773f33e8aa263ded157d5 /pw/pwupd.c
parent9eca0d3b9875657b856d9f4b2c808164886ef1cd (diff)
downloadpw-darwin-39d77815028ba1a72509c07e0a8583493f6ec0a8.tar.gz
pw-darwin-39d77815028ba1a72509c07e0a8583493f6ec0a8.tar.zst
pw-darwin-39d77815028ba1a72509c07e0a8583493f6ec0a8.zip
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 'pw/pwupd.c')
-rw-r--r--pw/pwupd.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/pw/pwupd.c b/pw/pwupd.c
index 89d0856..f9e1959 100644
--- a/pw/pwupd.c
+++ b/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();