setgid should be called before setuid
If you setuid to a non-zero value first(meaning you're no longer root), then call setgroups, the effective uid of the process is now no longer root, meaning that the internal setgid call fails This also removes the duplicated if loop Change-Id: I5d66fccd9ffb07df0c2e4435ec3da767b3b61117
This commit is contained in:
parent
c2b6df05e0
commit
476d358c7b
|
@ -414,13 +414,11 @@ class Daemon(object):
|
|||
msg = _('Failed to remove supplemental groups')
|
||||
LOG.critical(msg)
|
||||
raise FailedToDropPrivileges(msg)
|
||||
setgid(self.group)
|
||||
|
||||
if self.user is not None:
|
||||
setuid(self.user)
|
||||
|
||||
if self.group is not None:
|
||||
setgid(self.group)
|
||||
|
||||
finally:
|
||||
capabilities.set_keepcaps(False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue