diff options
author | bapt <bapt@FreeBSD.org> | 2015-07-12 20:29:51 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-07-12 20:29:51 +0000 |
commit | 8621997ee99ee7487f32e3f5c0c45b8dc9c21d5a (patch) | |
tree | 473edb252332496a7902109f52368a7f025499d7 /usr.sbin/pw/pw.c | |
parent | 93f91db3aac7ffbe93771407ae5d86292b916cff (diff) | |
download | FreeBSD-src-8621997ee99ee7487f32e3f5c0c45b8dc9c21d5a.zip FreeBSD-src-8621997ee99ee7487f32e3f5c0c45b8dc9c21d5a.tar.gz |
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 'usr.sbin/pw/pw.c')
-rw-r--r-- | usr.sbin/pw/pw.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.sbin/pw/pw.c b/usr.sbin/pw/pw.c index 532d77b..d81cfb0 100644 --- a/usr.sbin/pw/pw.c +++ b/usr.sbin/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 |