From: Miroslav Lichvar Date: Tue, 26 Aug 2025 06:38:07 +0000 (+0200) Subject: util: switch create_dir() from chown() to lchown() X-Git-Tag: 4.8~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=830c8bb18ada89abc3851bec552ce08913348ec0;p=thirdparty%2Fchrony.git 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. --- diff --git a/util.c b/util.c index 21fbc1bd..404e5b74 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);