git: 41b2a80353e0 - main - pw: Add a missing chown() when creating dirs in mkdir_home_parents()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Sep 2025 22:42:49 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=41b2a80353e0dd04939cc260d5763854a264c158
commit 41b2a80353e0dd04939cc260d5763854a264c158
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-09-18 22:39:11 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-09-18 22:39:11 +0000
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
---
usr.sbin/pw/pw_user.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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 = '/';
}