View | Details | Raw Unified | Return to bug 34812
Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/univention-cli-client (-15 / +10 lines)
 Lines 37-42   import time Link Here 
37
import ast
37
import ast
38
import os
38
import os
39
import sys
39
import sys
40
import subprocess
41
import pipes
40
from univention.config_registry import ConfigRegistry
42
from univention.config_registry import ConfigRegistry
41
43
42
44
 Lines 61-81   def get_logfile(): Link Here 
61
def fork_server(sock, socket_path):
63
def fork_server(sock, socket_path):
62
	"""Fork UDM command line server."""
64
	"""Fork UDM command line server."""
63
	# start new server
65
	# start new server
64
	pid = os.fork()
66
	argv = ['univention-cli-server', '-n']
65
	if pid == 0:  # child
67
	logfile = get_logfile()
66
		null = os.open(os.path.devnull, os.O_RDWR)
68
	if logfile:
67
		os.dup2(null, sys.stdin.fileno())
69
		argv.extend(['-L', logfile])
68
		os.dup2(null, sys.stdout.fileno())
70
	if socket_path != default_socket_path:
69
		os.dup2(null, sys.stderr.fileno())
71
		argv.extend(['-s', socket_path])
70
		argv = ['univention-cli-server']
72
	with open(os.path.devnull, "rb+") as null:
71
		logfile = get_logfile()
73
		subprocess.Popen('exec %s & wait %%-' % ' '.join(pipes.quote(x) for x in ['/usr/share/univention-directory-manager-tools/univention-cli-server'] + argv[1:]), close_fds=True, stdin=null, stdout=null, stderr=null, shell=True)
72
		if logfile:
73
			argv.extend(['-L', logfile])
74
		if socket_path != default_socket_path:
75
			argv.extend(['-s', socket_path])
76
		os.execv('/usr/share/univention-directory-manager-tools/univention-cli-server', argv)
77
	else:  # parent
78
		os.waitpid(pid, os.P_NOWAIT)
79
74
80
	ucr = ConfigRegistry()
75
	ucr = ConfigRegistry()
81
	ucr.load()
76
	ucr.load()

Return to bug 34812