useradd: create /etc/default saving defaults.

Since bbf4b79, we stopped shipping /etc/default/useradd, and therefore
install of shadow does not auto-create /etc/default.  So when useradd
tries to save a new default, it needs to create the directory.

Closes #390.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
This commit is contained in:
Serge Hallyn 2021-07-25 16:19:56 -05:00
parent cd551ef728
commit 33c33a32a2

View File

@ -567,6 +567,14 @@ static int set_defaults (void)
assert (wlen == (int) len -1);
}
ret = mkdir(dirname(NEW_USER_FILE), 0755);
if (-1 == ret && EEXIST != errno) {
fprintf (stderr,
_("%s: cannot create directory for defaults file\n"),
Prog);
goto setdef_err;
}
/*
* Create a temporary file to copy the new output to.
*/