##// END OF EJS Templates
dummyssh: make sure we don't inherit files descriptor to the children...
marmoute -
r48574:fb8389f2 stable
parent child Browse files
Show More
@@ -1,35 +1,35 b''
1 #!/usr/bin/env python3
1 #!/usr/bin/env python3
2
2
3 from __future__ import absolute_import
3 from __future__ import absolute_import
4
4
5 import os
5 import os
6 import shlex
6 import shlex
7 import subprocess
7 import subprocess
8 import sys
8 import sys
9
9
10 os.chdir(os.getenv('TESTTMP'))
10 os.chdir(os.getenv('TESTTMP'))
11
11
12 if sys.argv[1] != "user@dummy":
12 if sys.argv[1] != "user@dummy":
13 sys.exit(-1)
13 sys.exit(-1)
14
14
15 os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1')
15 os.environ["SSH_CLIENT"] = "%s 1 2" % os.environ.get('LOCALIP', '127.0.0.1')
16
16
17 log = open("dummylog", "ab")
17 log = open("dummylog", "ab")
18 log.write(b"Got arguments")
18 log.write(b"Got arguments")
19 for i, arg in enumerate(sys.argv[1:]):
19 for i, arg in enumerate(sys.argv[1:]):
20 log.write(b" %d:%s" % (i + 1, arg.encode('latin1')))
20 log.write(b" %d:%s" % (i + 1, arg.encode('latin1')))
21 log.write(b"\n")
21 log.write(b"\n")
22 log.close()
22 log.close()
23 hgcmd = sys.argv[2]
23 hgcmd = sys.argv[2]
24 if os.name == 'nt':
24 if os.name == 'nt':
25 # hack to make simple unix single quote quoting work on windows
25 # hack to make simple unix single quote quoting work on windows
26 hgcmd = hgcmd.replace("'", '"')
26 hgcmd = hgcmd.replace("'", '"')
27 cmds = shlex.split(hgcmd)
27 cmds = shlex.split(hgcmd)
28 if cmds[0].endswith('.py'):
28 if cmds[0].endswith('.py'):
29 python_exe = os.environ['PYTHON']
29 python_exe = os.environ['PYTHON']
30 cmds.insert(0, python_exe)
30 cmds.insert(0, python_exe)
31 hgcmd = shlex.join(cmds)
31 hgcmd = shlex.join(cmds)
32 # shlex generate windows incompatible string...
32 # shlex generate windows incompatible string...
33 hgcmd = hgcmd.replace("'", '"')
33 hgcmd = hgcmd.replace("'", '"')
34 r = subprocess.call(hgcmd, shell=True)
34 r = subprocess.call(hgcmd, shell=True, close_fds=True)
35 sys.exit(bool(r))
35 sys.exit(bool(r))
General Comments 0
You need to be logged in to leave comments. Login now