in an startup-script that is typically being run as user
root, i would like to start a program (actually, a server) as a less-privileged user.
the script originally used
su -s /bin/sh -c "umask 026; unset HOME; /usr/bin/fooserver" foouser
then a user reported problems with the
su approach (in a complicated PAM setup using automounts and whatnot), and suggested to use
sudo -s /bin/sh -c "umask 026; unset HOME; /usr/bin/fooserver" -u foouser
now i wonder:
are these two approaches functionally equivalent?
are there any pitfalls i ought to be aware when using
sudo -uinstead of
su? (think: environment preservation)
i'm aware that there are zillions of questions (and answers) regarding the differences between
sudo, but it seems that all of them are asked from a user perspective (whereas i am using these programs as root)