The branch main has been updated by markj:

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

commit daa63c9417a28ad08881ff03df828fd8180dad12
Author:     Mark Johnston <[email protected]>
AuthorDate: 2025-09-18 22:38:33 +0000
Commit:     Mark Johnston <[email protected]>
CommitDate: 2025-09-18 22:38:33 +0000

    pw: Print warnings when metadata updates fail
    
    We do this in most places already, but not consistently.
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Sponsored by:   Klara, Inc.
---
 usr.sbin/pw/cpdir.c   | 6 ++++--
 usr.sbin/pw/pw_user.c | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/usr.sbin/pw/cpdir.c b/usr.sbin/pw/cpdir.c
index 3dee8f7c43ac..63068cab000c 100644
--- a/usr.sbin/pw/cpdir.c
+++ b/usr.sbin/pw/cpdir.c
@@ -127,8 +127,10 @@ copymkdir(int rootfd, char const * dir, int skelfd, mode_t 
mode, uid_t uid,
                /*
                 * Propagate special filesystem flags
                 */
-               fchown(destfd, uid, gid);
-               fchflags(destfd, st.st_flags);
+               if (fchown(destfd, uid, gid) != 0)
+                       warn("chown(%s)", p);
+               if (fchflags(destfd, st.st_flags) != 0)
+                       warn("chflags(%s)", p);
                close(destfd);
        }
        closedir(d);
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 8a9a4342f5ef..9f5cfb0f4473 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -123,7 +123,8 @@ mkdir_home_parents(int dfd, const char *dir)
        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);
-               fchownat(dfd, dirs, 0, 0, 0);
+               if (fchownat(dfd, dirs, 0, 0, 0) != 0)
+                       warn("chown(%s)", dirs);
        }
 
        free(dirs);

Reply via email to