From d1caf190131fb94a6cacd90170d07ccceafa478b Mon Sep 17 00:00:00 2001 From: "David E. Eisenstat" Date: Tue, 17 Apr 2007 19:03:46 +0000 Subject: [PATCH] Fork more cleanly in PlanetLabConf. --- conf_files.py | 2 +- tools.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/conf_files.py b/conf_files.py index 5d1cb56..4903b3f 100644 --- a/conf_files.py +++ b/conf_files.py @@ -29,7 +29,7 @@ class conf_files: def system(self, cmd): if not self.noscripts and cmd: logger.log('conf_files: running command %s' % cmd) - return os.system(cmd) + return tools.fork_as(None, os.system, cmd) else: return 0 def update_conf_file(self, cf_rec): diff --git a/tools.py b/tools.py index 994089e..6b3a84b 100644 --- a/tools.py +++ b/tools.py @@ -43,9 +43,10 @@ def fork_as(su, function, *args): try: os.chdir('/') close_nonstandard_fds() - pw_ent = pwd.getpwnam(su) - os.setegid(pw_ent[3]) - os.seteuid(pw_ent[2]) + if su: + pw_ent = pwd.getpwnam(su) + os.setegid(pw_ent[3]) + os.seteuid(pw_ent[2]) child_pid = os.fork() if child_pid == 0: function(*args) except: -- 2.47.0