From 0342c1d1bb5093959e7f084856abdd4f82dc94ee Mon Sep 17 00:00:00 2001 From: caffeinated92 Date: Thu, 14 Nov 2024 11:33:59 +0700 Subject: [PATCH] move chown to LimitPrivileges function --- server/server.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/server.go b/server/server.go index 83015352c..66e8f5352 100644 --- a/server/server.go +++ b/server/server.go @@ -1621,6 +1621,9 @@ func (repman *ReplicationManager) LimitPrivileges() { repman.LogModulePrintf(repman.Conf.Verbose, config.ConstLogModGeneral, config.LvlInfo, "Setting uid and gid to target user: %s, uid: %d, gid: %d", targetUser.Username, uidInt, gidInt) + // Compatibility with old version, for files with root level permission in workingdir + misc.ChownR(repman.Conf.WorkingDir, uidInt, gidInt) + // Set GID (Group ID) err = syscall.Setgid(gidInt) if err != nil { @@ -1686,11 +1689,6 @@ func (repman *ReplicationManager) Run() error { u, err := user.Lookup(repman.Conf.MonitoringSystemUser) if err == nil { ExpectedUser = u - - // Compatibility with old version, for files with root level permission in workingdir - uid, _ := strconv.Atoi(ExpectedUser.Uid) - gid, _ := strconv.Atoi(ExpectedUser.Gid) - misc.ChownR(repman.Conf.WorkingDir, uid, gid) } }