Skip to content
Snippets Groups Projects
Commit 5183c922 authored by Pavel Kácha's avatar Pavel Kácha
Browse files

LaBrea: add symbolic uid/gid

parent 13482cfe
No related branches found
No related tags found
No related merge requests found
......@@ -399,6 +399,17 @@ class Filer(object):
os.rename(pth.join(self.tmp, short_name), pth.join(self.incoming, short_name))
def get_uid_gid(str_id, get_nam_func):
if str_id:
try:
id = int(str_id)
except ValueError:
id = get_nam_func(str_id)[2]
else:
id = None
return id
def daemonize(
work_dir=None, chroot_dir=None,
umask=None, uid=None, gid=None,
......@@ -411,8 +422,10 @@ def daemonize(
os.umask(umask)
if work_dir is not None:
os.chdir(work_dir)
gid = get_uid_gid(gid, getgrnam)
if gid is not None:
os.setgid(gid)
uid = get_uid_gid(uid, getpwnam)
if uid is not None:
os.setuid(uid)
# Doublefork, split session
......@@ -572,14 +585,14 @@ def get_args():
"-u", "--uid",
default=None,
dest="uid",
type="int",
type="string",
action="store",
help="user id to run under")
optp.add_option(
"-g", "--gid",
default=None,
dest="gid",
type="int",
type="string",
action="store",
help="group id to run under")
optp.add_option(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment