]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
util: switch create_dir() from chown() to lchown()
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Aug 2025 06:38:07 +0000 (08:38 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 26 Aug 2025 10:32:33 +0000 (12:32 +0200)
Use lchown(), the safer variant of chown() that does not follow
symlinks, when changing the ownership of a created directory (logdir,
dumpdir, ntsdumpdir, and the directory of bindcmdaddress) to the chrony
user.

util.c

diff --git a/util.c b/util.c
index 21fbc1bd72292c73a84aa54abc871fad5208fe92..404e5b74e4532087c3aebc5188d49d5866d32360 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1203,7 +1203,7 @@ create_dir(char *p, mode_t mode, uid_t uid, gid_t gid)
   }
 
   /* Set its owner */
-  if (chown(p, uid, gid) < 0) {
+  if (lchown(p, uid, gid) < 0) {
     LOG(LOGS_ERR, "Could not change ownership of %s : %s", p, strerror(errno));
     /* Don't leave it there with incorrect ownership */
     rmdir(p);