Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Oct 2025 13:13:32 GMT
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 53b6ea81fa20 - stable/14 - pw: Add a missing chown() when creating dirs in mkdir_home_parents()
Message-ID:  <202510051313.595DDWDC075235@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=53b6ea81fa201a5699cf00e82a994becd858be2d

commit 53b6ea81fa201a5699cf00e82a994becd858be2d
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-09-18 22:39:11 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-10-05 13:13:00 +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
    
    (cherry picked from commit 41b2a80353e0dd04939cc260d5763854a264c158)
---
 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 = '/';
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510051313.595DDWDC075235>