From 51107f2ff0c956b90013a1479e5fffb58974050a Mon Sep 17 00:00:00 2001 From: addshore Date: Mon, 23 May 2016 16:32:55 +0200 Subject: [PATCH] Use os.devnull This is a setp toward making this run on Windows. This now means at least the help output can be seen on Windows. --- sshuttle/client.py | 6 +++--- sshuttle/hostwatch.py | 2 +- sshuttle/ssh.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sshuttle/client.py b/sshuttle/client.py index d85ce08..4e4115f 100644 --- a/sshuttle/client.py +++ b/sshuttle/client.py @@ -16,7 +16,7 @@ resolvconf_nameservers from sshuttle.methods import get_method, Features -_extra_fd = os.open('/dev/null', os.O_RDONLY) +_extra_fd = os.open(os.devnull, os.O_RDONLY) def got_signal(signum, frame): @@ -76,7 +76,7 @@ def daemonize(): # be deleted. signal.signal(signal.SIGTERM, got_signal) - si = open('/dev/null', 'r+') + si = open(os.devnull, 'r+') os.dup2(si.fileno(), 0) os.dup2(si.fileno(), 1) si.close() @@ -323,7 +323,7 @@ def onaccept_tcp(listener, method, mux, handlers): sock, srcip = listener.accept() sock.close() finally: - _extra_fd = os.open('/dev/null', os.O_RDONLY) + _extra_fd = os.open(os.devnull, os.O_RDONLY) return else: raise diff --git a/sshuttle/hostwatch.py b/sshuttle/hostwatch.py index 95a539a..3a671ac 100644 --- a/sshuttle/hostwatch.py +++ b/sshuttle/hostwatch.py @@ -21,7 +21,7 @@ hostnames = {} queue = {} try: - null = open('/dev/null', 'wb') + null = open(os.devnull, 'wb') except IOError as e: log('warning: %s\n' % e) null = os.popen("sh -c 'while read x; do :; done'", 'wb', 4096) diff --git a/sshuttle/ssh.py b/sshuttle/ssh.py index 7691c80..a3dc99f 100644 --- a/sshuttle/ssh.py +++ b/sshuttle/ssh.py @@ -108,7 +108,7 @@ def connect(ssh_cmd, rhostport, python, stderr, options): if python: pycmd = "'%s' -c '%s'" % (python, pyscript) else: - pycmd = ("P=python3.5; $P -V 2>/dev/null || P=python; " + pycmd = ("P=python3.5; $P -V 2>" + os.devnull + " || P=python; " "exec \"$P\" -c '%s'") % pyscript argv = (sshl + portl +