Revision 743b53d4 lib/utils.py

b/lib/utils.py
2192 2192
  logging.debug("Memory lock set")
2193 2193

  
2194 2194

  
2195
def Daemonize(logfile):
2195
def Daemonize(logfile, run_uid, run_gid):
2196 2196
  """Daemonize the current process.
2197 2197

  
2198 2198
  This detaches the current process from the controlling terminal and
......
2200 2200

  
2201 2201
  @type logfile: str
2202 2202
  @param logfile: the logfile to which we should redirect stdout/stderr
2203
  @type run_uid: int
2204
  @param run_uid: Run the child under this uid
2205
  @type run_gid: int
2206
  @param run_gid: Run the child under this gid
2203 2207
  @rtype: int
2204 2208
  @return: the value zero
2205 2209

  
......
2213 2217
  pid = os.fork()
2214 2218
  if (pid == 0):  # The first child.
2215 2219
    os.setsid()
2220
    # FIXME: When removing again and moving to start-stop-daemon privilege drop
2221
    #        make sure to check for config permission and bail out when invoked
2222
    #        with wrong user.
2223
    os.setgid(run_gid)
2224
    os.setuid(run_uid)
2216 2225
    # this might fail
2217 2226
    pid = os.fork() # Fork a second child.
2218 2227
    if (pid == 0):  # The second child.

Also available in: Unified diff