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

SUP_ENV needs escaping #154

Open
untoreh opened this issue Jan 22, 2019 · 4 comments
Open

SUP_ENV needs escaping #154

untoreh opened this issue Jan 22, 2019 · 4 comments

Comments

@untoreh
Copy link

untoreh commented Jan 22, 2019

SUP_ENV is not escaped:

sup -D -e HELLO="1 2 3" local env
fra@localhost | bash: line 0: export: `2': not a valid identifier
fra@localhost | bash: line 0: export: `3': not a valid identifier
fra@localhost | + echo SUP_ENV is '-e HELLO=1'
fra@localhost | SUP_ENV is -e HELLO=1
commands:
  env:
    desc: print env
    run: echo SUP_ENV is "$SUP_ENV"

this one does not break but the quoting is lost

sup -D -e HELLO="'""1 2 3""'" local env

this one does not break and preserves quoting

sup -D -e HELLO='"'"'1 2 3'"'"' local env
@VojtechVitek
Copy link
Collaborator

Sup sets the env var as a string value, it shouldn't need any additional escaping.

I think you need to escape the "$HELLO" variable in the remote shell.

$ export HELLO="1 2 3"

$ $HELLO
bash: 1: command not found

$ "$HELLO"
bash: 1 2 3: command not found

Please, feel free to reopen if this doesn't help.

@untoreh
Copy link
Author

untoreh commented Jan 23, 2019

I don't think I understood what you meant.
The point is that sup doesn't escape quotes in the SUP_ENV variable. And since sup (well the go ssh package since sup does not do any mods) executes the command as an argument (bash -c "export SUP....") it ends up like
bash -c "...; export SUP_ENV="HELLO=" 1 2 3" OTHER_VAR=X"; ... "
when it should be
bash -c "...; export SUP_ENV="HELLO=\" 1 2 3\" OTHER_VAR=X"; ... "
The user has no control over the SUP_ENV variable

@VojtechVitek
Copy link
Collaborator

I might have misunderstood then. Can you provide a reproducer Supfile?

@VojtechVitek VojtechVitek reopened this Jan 23, 2019
@untoreh
Copy link
Author

untoreh commented Jan 24, 2019

well there was already the command snippet just add a local network

# Supfile
version: 0.4
networks:
  local:
    hosts:
      - localhost
commands:
  env:
    desc: print env
    run: echo SUP_ENV is "$SUP_ENV"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants