redirect all fd of slapd instances to /dev/null

This commit is contained in:
Benjamin Dauvergne 2016-03-18 14:23:01 +01:00
parent 4adfa74fac
commit 19922faaf8
1 changed files with 9 additions and 4 deletions

View File

@ -90,9 +90,14 @@ olcAccess: {{0}}to *
checkpoints = None
data_dirs = None
def create_process(self, args):
return subprocess.Popen(args, stdin=subprocess.PIPE, env=os.environ, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
def create_process(self, args, pipe=True):
if pipe:
return subprocess.Popen(args, stdin=subprocess.PIPE, env=os.environ,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
else:
DEVNULL = open(os.devnull, 'w')
return subprocess.Popen(args, stdin=DEVNULL, env=os.environ, stdout=DEVNULL,
stderr=DEVNULL)
def __init__(self, ldap_url=None):
assert has_slapd()
@ -148,7 +153,7 @@ olcAccess: {{0}}to * by manage'''
'-d768', # put slapd in foreground
'-F' + self.config_dir,
'-h', self.ldap_url]
self.process = self.create_process(cmd)
self.process = self.create_process(cmd, pipe=False)
atexit.register(self.clean)
while True: