diff options
| author | Mark Johnston <markj@FreeBSD.org> | 2025-09-18 22:39:11 +0000 |
|---|---|---|
| committer | Mark Johnston <markj@FreeBSD.org> | 2025-09-18 22:39:11 +0000 |
| commit | 41b2a80353e0dd04939cc260d5763854a264c158 (patch) | |
| tree | 031ab80240bcad76d80036294453553f5a780615 | |
| parent | 42dc71a544a4d78d0068f70b6d4089a8c9e07cb1 (diff) | |
pw: Add a missing chown() when creating dirs in mkdir_home_parents()
mkdir_home_parents() effectively performs a mkdir -p of the root home
directory. It chowns the home directory to 0, 0, but doesn't do so for
the intermediate directories. Add an explicit chown() call for those
too. Fix a long line while here.
Reviewed by: bapt
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52587
| -rw-r--r-- | usr.sbin/pw/pw_user.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c index 9f5cfb0f4473..007f750c7d1a 100644 --- a/usr.sbin/pw/pw_user.c +++ b/usr.sbin/pw/pw_user.c @@ -115,7 +115,11 @@ mkdir_home_parents(int dfd, const char *dir) *tmp = '\0'; if (fstatat(dfd, dirs, &st, 0) == -1) { if (mkdirat(dfd, dirs, _DEF_DIRMODE) == -1) - err(EX_OSFILE, "'%s' (home parent) is not a directory", dirs); + err(EX_OSFILE, + "'%s' (home parent) is not a directory", + dirs); + if (fchownat(dfd, dirs, 0, 0, 0) != 0) + warn("chown(%s)", dirs); } *tmp = '/'; } |
