summaryrefslogtreecommitdiffstats
path: root/pw/pw.c
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2015-07-12 20:29:51 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2015-07-12 20:29:51 +0000
commitf6975773c5ebf939f9e3f22b2b600d2c821604bc (patch)
tree8ae8db36682640068427bbf00fdaed91decb822d /pw/pw.c
parent5c8793faf0c3ceee6ca534d0f69b417a3759f7af (diff)
downloadpw-darwin-f6975773c5ebf939f9e3f22b2b600d2c821604bc.tar.gz
pw-darwin-f6975773c5ebf939f9e3f22b2b600d2c821604bc.tar.zst
pw-darwin-f6975773c5ebf939f9e3f22b2b600d2c821604bc.zip
Rework the home directory creation and copy or the skel content to use *at
functions This allows to simplify the code a bit for -R by not having to keep modifying path and also prepare the code to improve support -R in userdel While here, add regression tests for the functionality
Diffstat (limited to 'pw/pw.c')
-rw-r--r--pw/pw.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/pw/pw.c b/pw/pw.c
index 532d77b..d81cfb0 100644
--- a/pw/pw.c
+++ b/pw/pw.c
@@ -136,6 +136,7 @@ main(int argc, char *argv[])
name = NULL;
relocated = nis = false;
memset(&conf, 0, sizeof(conf));
+ strlcpy(conf.rootdir, "/", sizeof(conf.rootdir));
strlcpy(conf.etcpath, _PATH_PWD, sizeof(conf.etcpath));
conf.fd = -1;
@@ -215,6 +216,9 @@ main(int argc, char *argv[])
if (mode == -1 || which == -1)
cmdhelp(mode, which);
+ conf.rootfd = open(conf.rootdir, O_DIRECTORY|O_CLOEXEC);
+ if (conf.rootfd == -1)
+ errx(EXIT_FAILURE, "Unable to open '%s'", conf.rootdir);
conf.which = which;
/*
* We know which mode we're in and what we're about to do, so now