Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--run interprets shell quotes wrong #865

Closed
Dominik-K opened this issue Dec 12, 2018 · 3 comments
Closed

--run interprets shell quotes wrong #865

Dominik-K opened this issue Dec 12, 2018 · 3 comments
Labels
stale Issue is stale and will be closed

Comments

@Dominik-K
Copy link

What were you trying to do?

Trying out Telepresence with Golang. Quoted the argument for --run:

telepresence --namespace telepresence --run "$GOPATH/bin/wuzz http://hello-world.telepresence:8000"

to avoid falsely interpreting whitespaces inside the argument.

What did you expect to happen?

Normal run. Same as --run without quotes.

What happened instead?

Telepresence interpreted the whole argument as a file.?

Automatically included information

Command line: ['/usr/local/bin/telepresence', '--namespace', 'telepresence', '--run', '/Users/dominik/go/bin/wuzz http://hello-world.telepresence:8000/']
Version: 0.95
Python version: 3.7.1 (default, Nov 8 2018, 12:42:00) [Clang 8.0.0 (clang-800.0.42.1)]
OS: Darwin Dominiks-MacBook-Pro.local 18.2.0 Darwin Kernel Version 18.2.0: Fri Oct 5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
Traceback:

Traceback (most recent call last):
  File "/usr/local/bin/telepresence/telepresence/cli.py", line 129, in crash_reporting
    yield
  File "/usr/local/bin/telepresence/telepresence/main.py", line 78, in main
    runner, remote_info, env, socks_port, ssh, mount_dir
  File "/usr/local/bin/telepresence/telepresence/outbound/__init__.py", line 60, in launch
    runner_, remote_info, command, args.also_proxy, env, ssh
  File "/usr/local/bin/telepresence/telepresence/outbound/local.py", line 122, in launch_vpn
    process = Popen(command, env=env)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 769, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1516, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dominik/go/bin/wuzz http://hello-world.telepresence:8000/': '/Users/dominik/go/bin/wuzz http://hello-world.telepresence:8000/'

@ark3
Copy link
Contributor

ark3 commented Dec 14, 2018

Sorry about the crash! That was fixed in #870 and will function correctly in the next release.

Telepresence does not interpret shell quotes; that's the shell's job. Telepresence behaves the same as other command line software that executes a command on your behalf:

$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost

$ env "cat /etc/hosts"
env: cat /etc/hosts: No such file or directory

$ sudo "cat /etc/hosts"
sudo: cat /etc/hosts: command not found

$ docker run --rm -it alpine "cat /etc/hosts"
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"cat /etc/hosts\": stat cat /etc/hosts: no such file or directory": unknown.

$ 

@Dominik-K
Copy link
Author

Tested it again and found out that Telepresence assumes --run is the last argument. The telepresence --help suggests it's a normal flag:

usage: telepresence [SKIPPED]
                    [--run-shell | --run ... | --docker-run ...]

I suggest using [COMMAND] [ARG] as positional arguments, like in docker run:

Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

or even better explicitly break them from beforehand arguments with --, like in kubectl:

Usage:
   kubectl run NAME --image=image [SKIPPED] -- [COMMAND] [args...] [options]

@stale
Copy link

stale bot commented Nov 16, 2020

This issue has been automatically marked as stale because it has not had recent activity.
Issue Reporter: Is this still a problem? If not, please close this issue.
Developers: Do you need more information? Is this a duplicate? What's the next step?

@stale stale bot added the stale Issue is stale and will be closed label Nov 16, 2020
@stale stale bot closed this as completed Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue is stale and will be closed
Projects
None yet
Development

No branches or pull requests

2 participants