def daemonize(self, args): log.setup(self.log_file) log.info("Daemonizing.") self.before_daemonize(args) if unix.still_running(self.name, pid_file_path=self.pid_path): log.error("%s still running. Aborting." % self.name) sys.exit(1) else: unix.daemonize(self.name, pid_file_path=self.pid_path) def shutdown_handler(signal, frame): self.shutdown(signal) sys.exit(0) unix.register_shutdown(shutdown_handler) self.before_jail(args) log.info("Setting up the chroot jail to: %s" % self.run_dir) unix.chroot_jail(self.run_dir) self.before_drop_privs(args) unix.drop_privileges(uid_name=self.uid, gid_name=self.gid) log.info("Server %s running." % self.name) self.start(args)
def test_chroot_jail(chroot_jail): unix.chroot_jail() assert_true(chroot_jail.called, "Failed to call the chroot jail.")