Skip to content

Commit

Permalink
Add support for SSHUTTLE_ARGS environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjurkiewicz authored and brianmay committed Aug 9, 2023
1 parent 3c3f5de commit 0ddebde
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
12 changes: 12 additions & 0 deletions docs/manpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ annotations. For example::
192.168.63.0/24


Environment Variable
--------------------

You can specify command line options with the `SSHUTTLE_ARGS` environment
variable. If a given option is defined in both the environment variable and
command line, the value on the command line will take precedence.

For example::

SSHUTTLE_ARGS="-e 'ssh -v' --dns" sshuttle -r example.com 0/0


Examples
--------

Expand Down
11 changes: 10 additions & 1 deletion sshuttle/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import os
import re
import shlex
import socket
import sys
import sshuttle.helpers as helpers
import sshuttle.client as client
import sshuttle.firewall as firewall
Expand All @@ -11,7 +14,13 @@


def main():
opt = parser.parse_args()
if 'SSHUTTLE_ARGS' in os.environ:
env_args = shlex.split(os.environ['SSHUTTLE_ARGS'])
else:
env_args = []
args = [*env_args, *sys.argv[1:]]

opt = parser.parse_args(args)

if opt.sudoers_no_modify:
# sudoers() calls exit() when it completes
Expand Down

0 comments on commit 0ddebde

Please sign in to comment.