From 830c8bb18ada89abc3851bec552ce08913348ec0 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 26 Aug 2025 08:38:07 +0200 Subject: [PATCH] util: switch create_dir() from chown() to lchown() 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.c b/util.c index 21fbc1b..404e5b7 100644 --- 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);