summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/CherryPyCore.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2015-01-16 03:53:00 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2015-02-25 18:35:00 +0100
commitf69d2c18d1351d49f4c1ffd2a6c282df0fa3d8e3 (patch)
treea8861e9ce11b6a5c320c2c1f9ba23cb152f6c20a /src/lib/Bcfg2/Server/CherryPyCore.py
parent12b769d5864c9e04235184d38a5089f1ee655c8c (diff)
downloadbcfg2-f69d2c18d1351d49f4c1ffd2a6c282df0fa3d8e3.tar.gz
bcfg2-f69d2c18d1351d49f4c1ffd2a6c282df0fa3d8e3.tar.bz2
bcfg2-f69d2c18d1351d49f4c1ffd2a6c282df0fa3d8e3.zip
Server/Core: drop privileges even if not running as daemon
Diffstat (limited to 'src/lib/Bcfg2/Server/CherryPyCore.py')
-rw-r--r--src/lib/Bcfg2/Server/CherryPyCore.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/CherryPyCore.py b/src/lib/Bcfg2/Server/CherryPyCore.py
index d097fd08f..c1581679c 100644
--- a/src/lib/Bcfg2/Server/CherryPyCore.py
+++ b/src/lib/Bcfg2/Server/CherryPyCore.py
@@ -103,17 +103,21 @@ class Core(BaseCore):
return cherrypy.serving.response.body
def _daemonize(self):
- """ Drop privileges with
- :class:`cherrypy.process.plugins.DropPrivileges`, daemonize
- with :class:`cherrypy.process.plugins.Daemonizer`, and write a
+ """ Drop privileges, daemonize
+ with :class:`cherrypy.process.plugins.Daemonizer` and write a
PID file with :class:`cherrypy.process.plugins.PIDFile`. """
+ self._drop_privileges()
+ Daemonizer(cherrypy.engine).subscribe()
+ PIDFile(cherrypy.engine, self.setup['daemon']).subscribe()
+ return True
+
+ def _drop_privileges(self):
+ """ Drop privileges with
+ :class:`cherrypy.process.plugins.DropPrivileges` """
DropPrivileges(cherrypy.engine,
uid=self.setup['daemon_uid'],
gid=self.setup['daemon_gid'],
umask=int(self.setup['umask'], 8)).subscribe()
- Daemonizer(cherrypy.engine).subscribe()
- PIDFile(cherrypy.engine, self.setup['daemon']).subscribe()
- return True
def _run(self):
""" Start the server listening. """