I was writing a simple script that had to be run as 'user'. I run it half the time as myself and half the time when su as the user, so to save time I wrote it as
sudo -u user ./doStuff
but this doesn't work correctly because when I am logged in as user this command fails because I don't have sudo permissions to do... everything I could already do.
My question is, is there a reason for not defaulting every user as having permission to sudo as themselves; for ease of scripts such as this? is there some sort of security whole I'm missing that would be created by this, or is it just not something anyone bothered to implement?
second, more out of curiosity then a real need, how would one modify the /etc/sudoers
file to make it so every user could, by default, sudo -u
as themselves? I know my original script could have been written by using a check who the user is, but I'm going to write lots of scripts like that one for convenience while testing and I want to cut out the extra steps that I could forget to add in some future script.
sudo
is required, OS X and Windows requires similar actions, its basically a way to verify the user is actually the user.