agiledivider / vagrant-hostsupdater

MIT License
1.15k stars 130 forks source link

Issue with administrator privileges #174

Closed brunowego closed 5 years ago

brunowego commented 5 years ago

Following the references about "how by pass admin access to hosts", I created the follow instructions:

brunowego@ally [docker-datapipe] cat /private/etc/sudoers.d/vagrant-hosts                                                                                                           8:16:37  ☁  master ☂ ➜ ⚡ ✚ ✭
Cmnd_Alias      VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias      VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts

%admin          ALL = (root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE

Even so, I continue getting the issue with password:

brunowego@ally [docker-datapipe] vagrant destroy -f                                                                                                                                 8:15:08  ☁  develop ☂ ✭
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Pruning invalid NFS exports. Administrator privileges will be required...
Password:

Perhaps is because I am using OS X Mojave and this approach is different for this OS?

kamazee commented 5 years ago

@brunowego %admin stands for "admin" group so passwordless sudo for running a command that replaces hosts file is only available to "admin" group members. Is your user a member of "admin" group? Run groups in terminal to see list of groups you're a member of. If "admin" is not there, either add yourself to "admin" group or use your username instead of %admin in sudo configuration (without any prefix such as %, just the username).

kamazee commented 5 years ago

@brunowego oh, I didn't read through the issue description carefully. It's NFS exports that require sudo password, not vagrant-hostsupdater. This should help.

brunowego commented 5 years ago

Thanks @kamazee :)