Ticket #1473: deluge-web-setuid.patch
File deluge-web-setuid.patch, 2.9 KB (added by cinderblock, 13 years ago) |
---|
-
deluge/ui/web/web.py
deluge/ui/web/web.py | 35 ++++++++++++++++++++++++++++++----- 1 files changed, 30 insertions(+), 5 deletions(-) diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py index a2b5765..23cabcd 100644
a b def __init__(self): 56 56 group.add_option("-b", "--base", dest="base", 57 57 help="Set the base path that the ui is running on (proxying)", 58 58 action="store", default=None) 59 group.add_option("-f", "--fork", dest="fork", 60 help="Fork the web interface process into the background", 61 action="store_true", default=False) 59 if not (deluge.common.windows_check() or deluge.common.osx_check()): 60 group.add_option("-f", "--fork", dest="fork", 61 help="Fork the web interface process into the background", 62 action="store_true", default=False) 63 group.add_option("-P", "--pidfile", dest="pidfile", type="str", 64 help="Use pidfile to store process id", 65 action="store", default=None) 66 if not deluge.common.windows_check(): 67 group.add_option("-U", "--user", dest="user", type="str", 68 help="User to switch to. Only use it when starting as root", 69 action="store", default=None) 70 group.add_option("-g", "--group", dest="group", type="str", 71 help="Group to switch to. Only use it when starting as root", 72 action="store", default=None) 62 73 group.add_option("-p", "--port", dest="port", type="int", 63 74 help="Sets the port to be used for the webserver", 64 75 action="store", default=None) … … def start(self): 86 97 import deluge.common 87 98 # Steps taken from http://www.faqs.org/faqs/unix-faq/programmer/faq/ 88 99 # Section 1.7 89 if self.options.fork and not deluge.common.windows_check():100 if self.options.fork: 90 101 # fork() so the parent can exit, returns control to the command line 91 102 # or shell invoking the program. 92 103 if os.fork(): … … def start(self): 103 114 # use that may prevent a filesystem unmount. 104 115 import deluge.configmanager 105 116 os.chdir(deluge.configmanager.get_config_dir()) 106 117 118 if self.options.pidfile: 119 open(self.options.pidfile, "wb").write("%d\n" % os.getpid()) 120 121 if self.options.group: 122 if not self.options.group.isdigit(): 123 import grp 124 self.options.group = grp.getgrnam(self.options.group)[2] 125 os.setuid(self.options.group) 126 if self.options.user: 127 if not self.options.user.isdigit(): 128 import pwd 129 self.options.user = pwd.getpwnam(self.options.user)[2] 130 os.setuid(self.options.user) 131 107 132 import server 108 133 self.__server = server.DelugeWeb() 109 134