mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 18:25:07 -05:00
conf: create directories before dropping root
Create logdir and dumpdir before dropping root. Set their uid/gid to the user chronyd will switch to. This allows chronyd to create the directories in a directory where the user won't have write permissions (e.g. /var/lib).
This commit is contained in:
5
main.c
5
main.c
@@ -493,12 +493,13 @@ int main
|
||||
if ((pw = getpwnam(user)) == NULL)
|
||||
LOG_FATAL(LOGF_Main, "Could not get %s uid/gid", user);
|
||||
|
||||
/* Create all directories before dropping root */
|
||||
CNF_CreateDirs(pw->pw_uid, pw->pw_gid);
|
||||
|
||||
/* Drop root privileges if the user has non-zero uid or gid */
|
||||
if (pw->pw_uid || pw->pw_gid)
|
||||
SYS_DropRoot(pw->pw_uid, pw->pw_gid);
|
||||
|
||||
LOG_CreateLogFileDir();
|
||||
|
||||
REF_Initialise();
|
||||
SST_Initialise();
|
||||
NIO_Initialise(address_family);
|
||||
|
||||
Reference in New Issue
Block a user