Beware he be dragons ;-) sudo and other methods for changing your effective uid (particularly in a script) are tres dangerous and open to exploits. I see the following issues:
- If someone with malevolent intent were to get write access to that script (not as hard as you may expect) they would have the right to run riot on your filesystem.
- Sudo requires permission to be given to a specific user to call it, now do you really want to blindly give permission to nobody (created to have no permissions) direct access to root?
- Sudo requires a password to be entered nobody typically has no password and no shell as it is not an account for someone to log in as.
- Sudo is inherently interactive, it opens /dev/tty (or equiv) to read the password this will make noninteractive usage difficult
OK so those are the reasons that sudo are bad ;-) the best way is to look at what you want to do and sort that. If all you want to do it manipulate the .forward and .vacation.msg files then chgrp them to something nice, change the permission to give write permission for that group for those files. Ensure nobody is in that group and bingo!! This is still not nice but it is less not nice.
--
Zigster