From 6789e5acf22b51ee0d83a01a3231e0b5c014770b Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 22 Jan 2017 18:55:01 +0000 Subject: [PATCH] Readd a feature lost in pw(8) refactoring pw usermod foo -m It used to be able to (re)create the home directory if it didn't exists PR: 216224 Reported by: ae MFC after: 3 days --- usr.sbin/pw/pw_user.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index 75e7fb6e5c88..6e991a858d8f 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -1697,6 +1697,10 @@ pw_user_mod(int argc, char **argv, char *arg1) edited = true; } + if (createhome && fstatat(conf.rootfd, pwd->pw_dir, &st, 0) == -1) { + docreatehome = true; + } + if (homedir && strcmp(pwd->pw_dir, homedir) != 0) { pwd->pw_dir = homedir; edited = true;