Skip to content

Commit

Permalink
fix error with sudo -D
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
dadevel committed Dec 28, 2024
1 parent 121288f commit af19914
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wgnetns"
version = "2.3.4"
version = "2.3.5"
description = "wg-quick for network namespaces"
authors = ["dadevel <[email protected]>"]
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions wgnetns/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def cli(args):
data = json.loads(output)
print('\n'.join(item['name'] for item in data))
elif opts.action == 'switch':
os.execvp('sudo', ['ip', 'ip', 'netns', 'exec', opts.netns, 'sudo', '-u', getpass.getuser(), '-D', Path.cwd().as_posix(), os.environ['SHELL'], '-i'])
os.execvp('sudo', ['ip', 'ip', 'netns', 'exec', opts.netns, 'sudo', '-u', getpass.getuser(), os.environ['SHELL'], '-i'])
elif opts.action == 'exec':
os.execvp('sudo', ['ip', 'ip', 'netns', 'exec', opts.netns, 'sudo', '-u', getpass.getuser(), '-D', Path.cwd().as_posix(), *opts.command])
os.execvp('sudo', ['ip', 'ip', 'netns', 'exec', opts.netns, 'sudo', '-u', getpass.getuser(), *opts.command])
else:
raise RuntimeError('congratulations, you reached unreachable code')

Expand Down

0 comments on commit af19914

Please sign in to comment.