Skip to content
Snippets Groups Projects
Commit 603cb28e authored by ale's avatar ale
Browse files

first chown, then setuid, take two

parent d73bd1ad
No related branches found
No related tags found
No related merge requests found
......@@ -99,14 +99,14 @@ def daemonize(opts, main_function, args, support_gevent=False):
sys.exit(1)
if opts.username:
os.chown(opts.pidfile, user_pw.pw_uid, user_pw.pw_gid)
try:
user_pw = pwd.getpwnam(opts.username)
os.setuid(user_pw.pw_uid)
except KeyError:
sys.stderr.write(
'Error: could not find user "%s"\n' % opts.username)
sys.exit(1)
os.chown(opts.pidfile, user_pw.pw_uid, user_pw.pw_gid)
os.setuid(user_pw.pw_uid)
if support_gevent:
import gevent
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment