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

ignore aliases for different commands #90

Merged
merged 3 commits into from
Nov 30, 2014

Conversation

sasg
Copy link

@sasg sasg commented Nov 17, 2014

Hi,

i had the problem that e.g. CentOS6 sets some aliases for mv, rm and cp to use -i (interactive).
In this case, the plugin doesn't work properly. It seems to wait forever.
I simply added a backslash in front of the commands, which ignores aliases.

Regards,
Sascha

@tmatilai
Copy link
Owner

Thanks @sasg! Looks fine. Still trying to think of some cases where this could cause breakage for the current behavior...

@otahi
Copy link
Collaborator

otahi commented Nov 17, 2014

Hi @sasg,
I just tried bash with sudo on Mac OS X. Sudo commands are not expanded.

I checked sudo part on Vagrant uses sudo -E -H.
I tried same option with Vagrant but commands were not expanded.

Can you give detail of your situation? Which files do you configure alias?(/etc/bashrc ? /etc/profile.d/ ?)

bash-3.2$ grep alias /etc/bashrc
alias ll='ls -l'
bash-3.2$ ll
total 10072
total 10072
drwx------    9 otahi  staff      306 11  1 06:07 Applications
:
bash-3.2$ sudo ll
sudo: ll: command not found
bash-3.2$ sudo -E -H ll
sudo: ll: command not found
bash-3.2$

@sasg
Copy link
Author

sasg commented Nov 17, 2014

Hi @otahi,

thanks for testing!

I did some more debugging and found it only happens, when "config.ssh.pty" in Vagrant is set to true.

Then you will get this:

DEBUG ssh: PTY stdout parsed:
DEBUG ssh: Re-using SSH connection.
 INFO ssh: Execute: mv /etc/environment.new /etc/environment (sudo=true)
DEBUG ssh: pty obtained for connection
DEBUG ssh: stdout: export TERM=vt100
stty raw -echo
export PS1=
export PS2=
export PROMPT_COMMAND=
printf bccbb768c119429488cfd109aacea6b5-pty
mv /etc/environment.new /etc/environment
exitcode=$?
printf bccbb768c119429488cfd109aacea6b5-pty
exit $exitcode

DEBUG ssh: stdout: [root@puppetmaster vagrant]# export TERM=vt100
[root@puppetmaster vagrant]# stty raw -echo

DEBUG ssh: stdout: [root@puppetmaster vagrant]# bccbb768c119429488cfd109aacea6b5-pty
DEBUG ssh: stdout: mv: overwrite `/etc/environment'?
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...

The mv: overwrite /etc/environment'? is due to the aliases :

For example:

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

Another solution would be to add a -f instead of \ for the mention commands.

Thanks and Regards,
Sascha

@tmatilai
Copy link
Owner

Oh, config.ssh.pty will get you into many other issues too... Even Vagrant core itself has code that won't work with it.
Mitchell has said that he regrets introducing that configuration key, and is even thinking deprecating it. The recommended way is to build the box so that it doesn't have requiretty in /etc/sudoers.

So not really sure what to do here.

@sasg
Copy link
Author

sasg commented Nov 18, 2014

Hi @tmatilai,

you're absolutely right! I played a little bit with some vagrant options and also with the proxyconf plugin.
During some testings, I didn't remember the pty setting. :-(

But for the problem, I looked deeper in the code of vagrant and they also using the "-f" option for commands in some parts of the code.
So I changed the proxyconf code to have a "-f" instead of "" and it works too.

Do you think it makes sense to have this small change for reasons like this ?

Thanks and Regards,
Sascha

@otahi
Copy link
Collaborator

otahi commented Nov 18, 2014

HI @tmatilai, @sasg,

I understand config.ssh.pty is the reason. This modification looks better than before.

@otahi
Copy link
Collaborator

otahi commented Nov 30, 2014

@tmatilai,
I think this can be merged. If you don't have time and you allow me to merge it, I will merge it.
Thank you.

@tmatilai
Copy link
Owner

Great, thanks!

tmatilai added a commit that referenced this pull request Nov 30, 2014
ignore aliases for different commands
@tmatilai tmatilai merged commit dee3db3 into tmatilai:master Nov 30, 2014
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

Successfully merging this pull request may close these issues.

4 participants