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
commit82e3411026949c74f9a726bb418b3fdcbc4e9fd0 (patch)
tree220b3c93097f3a69a4282486b48c4b4ae65d1110 /pw/pw.c
parent36810b94302ed35424caa32ae205ee0f1d4f7185 (diff)
downloadpw-darwin-82e3411026949c74f9a726bb418b3fdcbc4e9fd0.tar.gz
pw-darwin-82e3411026949c74f9a726bb418b3fdcbc4e9fd0.tar.zst
pw-darwin-82e3411026949c74f9a726bb418b3fdcbc4e9fd0.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