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): ...@@ -399,6 +399,17 @@ class Filer(object):
os.rename(pth.join(self.tmp, short_name), pth.join(self.incoming, short_name)) 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( def daemonize(
work_dir=None, chroot_dir=None, work_dir=None, chroot_dir=None,
umask=None, uid=None, gid=None, umask=None, uid=None, gid=None,
...@@ -411,8 +422,10 @@ def daemonize( ...@@ -411,8 +422,10 @@ def daemonize(
os.umask(umask) os.umask(umask)
if work_dir is not None: if work_dir is not None:
os.chdir(work_dir) os.chdir(work_dir)
gid = get_uid_gid(gid, getgrnam)
if gid is not None: if gid is not None:
os.setgid(gid) os.setgid(gid)
uid = get_uid_gid(uid, getpwnam)
if uid is not None: if uid is not None:
os.setuid(uid) os.setuid(uid)
# Doublefork, split session # Doublefork, split session
...@@ -572,14 +585,14 @@ def get_args(): ...@@ -572,14 +585,14 @@ def get_args():
"-u", "--uid", "-u", "--uid",
default=None, default=None,
dest="uid", dest="uid",
type="int", type="string",
action="store", action="store",
help="user id to run under") help="user id to run under")
optp.add_option( optp.add_option(
"-g", "--gid", "-g", "--gid",
default=None, default=None,
dest="gid", dest="gid",
type="int", type="string",
action="store", action="store",
help="group id to run under") help="group id to run under")
optp.add_option( optp.add_option(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment