Skip to content

Commit

Permalink
Use ignore_environ like process
Browse files Browse the repository at this point in the history
  • Loading branch information
Arusekk committed Nov 24, 2023
1 parent bc35c4e commit c18a865
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pwnlib/tubes/ssh.py
Expand Up @@ -58,7 +58,7 @@ class ssh_channel(sock):
#: Command specified for the constructor
process = None

def __init__(self, parent, process = None, tty = False, cwd = None, env = None, env_add = {}, raw = True, *args, **kwargs):
def __init__(self, parent, process = None, tty = False, cwd = None, env = None, raw = True, *args, **kwargs):
super(ssh_channel, self).__init__(*args, **kwargs)

# keep the parent from being garbage collected in some cases
Expand Down Expand Up @@ -760,7 +760,7 @@ def shell(self, shell = None, tty = True, timeout = Timeout.default):
"""
return self.run(shell, tty, timeout = timeout)

def process(self, argv=None, executable=None, tty=True, cwd=None, env=None, env_add={}, timeout=Timeout.default, run=True,
def process(self, argv=None, executable=None, tty=True, cwd=None, env=None, ignore_environ=None, timeout=Timeout.default, run=True,
stdin=0, stdout=1, stderr=2, preexec_fn=None, preexec_args=(), raw=True, aslr=None, setuid=None,
shell=False):
r"""
Expand Down Expand Up @@ -788,10 +788,9 @@ def process(self, argv=None, executable=None, tty=True, cwd=None, env=None, env_
Working directory. If :const:`None`, uses the working directory specified
on :attr:`cwd` or set via :meth:`set_working_directory`.
env(dict):
Environment variables to set in the child. If :const:`None`, inherits the
default environment.
env_add(dict):
Environment variables to ADD in the child, in addition to those it inherits.
Environment variables to add to the environment.
ignore_environ(bool):
Ignore default environment. By default use default environment iff env not specified.
timeout(int):
Timeout to set on the `tube` created to interact with the process.
run(bool):
Expand Down Expand Up @@ -911,6 +910,9 @@ def process(self, argv=None, executable=None, tty=True, cwd=None, env=None, env_

aslr = aslr if aslr is not None else context.aslr

if ignore_environ is None:
ignore_environ = env is not None # compat

argv, env = misc.normalize_argv_env(argv, env, self)

if shell:
Expand Down Expand Up @@ -961,17 +963,16 @@ def func(): pass
os.chdir(%(cwd)r)
if %(ignore_environ)r:
os.environ.clear()
environ = getattr(os, 'environb', os.environ)
if env is not None:
env = OrderedDict((bytes(k), bytes(v)) for k,v in env)
os.environ.clear()
environ.update(env)
else:
env = environ
env.update(%(env_add)r)
def is_exe(path):
return os.path.isfile(path) and os.access(path, os.X_OK)
Expand Down

0 comments on commit c18a865

Please sign in to comment.