From 41f5b3e9c12808f512b85c715e430fbd109f4742 Mon Sep 17 00:00:00 2001 From: AbbalYouness Date: Wed, 17 Oct 2018 09:46:26 +0200 Subject: [PATCH] replace path /dev/null by os.devnull --- sshuttle/client.py | 6 +++--- sshuttle/hostwatch.py | 2 +- sshuttle/methods/ipfw.py | 2 +- sshuttle/ssh.py | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sshuttle/client.py b/sshuttle/client.py index 98abcae..e7d8e8f 100644 --- a/sshuttle/client.py +++ b/sshuttle/client.py @@ -33,7 +33,7 @@ except AttributeError: except ImportError: import socket -_extra_fd = os.open('/dev/null', os.O_RDONLY) +_extra_fd = os.open(os.devnull, os.O_RDONLY) def got_signal(signum, frame): @@ -93,7 +93,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() @@ -355,7 +355,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 94b462f..64ff43a 100644 --- a/sshuttle/hostwatch.py +++ b/sshuttle/hostwatch.py @@ -21,7 +21,7 @@ _smb_ok = True hostnames = {} queue = {} try: - null = open('/dev/null', 'wb') + null = open(os.devnull, 'wb') except IOError: _, e = sys.exc_info()[:2] log('warning: %s\n' % e) diff --git a/sshuttle/methods/ipfw.py b/sshuttle/methods/ipfw.py index 2a6bec0..2e3bfed 100644 --- a/sshuttle/methods/ipfw.py +++ b/sshuttle/methods/ipfw.py @@ -105,7 +105,7 @@ def _fill_oldctls(prefix): def _sysctl_set(name, val): argv = ['sysctl', '-w', '%s=%s' % (name, val)] debug1('>> %s\n' % ' '.join(argv)) - return ssubprocess.call(argv, stdout=open('/dev/null', 'w')) + return ssubprocess.call(argv, stdout=open(os.devnull, 'w')) _changedctls = [] diff --git a/sshuttle/ssh.py b/sshuttle/ssh.py index 5483527..e9d920a 100644 --- a/sshuttle/ssh.py +++ b/sshuttle/ssh.py @@ -116,8 +116,8 @@ def connect(ssh_cmd, rhostport, python, stderr, options): if python: pycmd = "'%s' -c '%s'" % (python, pyscript) else: - pycmd = ("P=python3; $P -V 2>/dev/null || P=python; " - "exec \"$P\" -c %s") % quote(pyscript) + pycmd = ("P=python3; $P -V 2>%s || P=python; " + "exec \"$P\" -c %s") % (os.devnull, quote(pyscript)) pycmd = ("exec /bin/sh -c %s" % quote(pycmd)) argv = (sshl + portl +