-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Improve use of sudo for NFS export manipulation #3638
Conversation
@@ -40,7 +40,7 @@ def self.nfs_export(env, ui, id, ips, folders) | |||
output.split("\n").each do |line| | |||
# This should only ask for administrative permission once, even | |||
# though its executed in multiple subshells. | |||
system(%Q[sudo su root -c "echo '#{line}' >> /etc/exports"]) | |||
system(%Q[echo '#{line}' | tee -a /etc/exports >/dev/null"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this missing a sudo
before tee
?
Looks good! Quick question on the Linux usage above. |
Ah yes, that'll teach me to commit untested stuff late at night ;) I've made sure the Linux stuff works now too. Linux sudoers entry should look like this for passwordless operation:
I've added example sudoers configs to contrib/ which seems like the right thing to do. It would be good to keep these up to date if the commands in the plugin change. |
AWESOME! LGMT> |
Improve use of sudo for NFS export manipulation
FYI, for those on fedora the 2nd and third lines should be:
Also I add my user to the vagrant group and change the last line to:
|
Some users (myself and the denizens of #2642 included) want to allow Vagrant to manipulate NFS configs without requesting a sudo password each time.
The current approach, using "sudo -s" requires that we permit the whole shell to be run passwordless in sudoers, and that's rather too open to be safe.
This patch uses an alternative idiom, using 'tee' instead of output redirection to append to the exports file. On application of this patch, the following sudoers config (on OSX, at least), permits fully passwordless operation in a much safer manner:
This feels like a good interim step if work on the suid helper has paused for now.
NB: I've been unable to test the patch to the Linux plugin at this time.