aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2025-09-18 22:38:33 +0000
committerMark Johnston <markj@FreeBSD.org>2025-09-18 22:38:33 +0000
commitdaa63c9417a28ad08881ff03df828fd8180dad12 (patch)
tree564a616a63e4541cde25d5ad1904851715e5c2c8
parent4784ca87441093328cec4e9b133608e172343f64 (diff)
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.
-rw-r--r--usr.sbin/pw/cpdir.c6
-rw-r--r--usr.sbin/pw/pw_user.c3
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);