Closed sasg closed 9 years ago
Thanks @sasg! Looks fine. Still trying to think of some cases where this could cause breakage for the current behavior...
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$
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
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.
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
HI @tmatilai, @sasg,
I understand config.ssh.pty
is the reason. This modification looks better than before.
@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.
Great, thanks!
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