Hi Mentors, TLDR: in order to execute a command as another user, should `sudo` or `su --command` be used?
I'd like to get your opinion on how to best solve this issue: I've got a package [0] that uses dbconfig-common to manage its database. The database is owned by a specific user (not root). In the pre- and postinst scripts, a command has to be performed as that user (e.g. make a backup of the database). I've at first used sudo to perform that, and it worked fine until piuparts found an issue [1], since (as I hadn't realized) sudo is not part of the base system (installed on 76% of popcon-reporting machines [2]) I am wondering what the best way is to fix this. I see 2 solutions: 1. Depend on sudo 2. Use "su --command" instead First lines from the respective manpages: sudo, sudoedit - execute a command as another user su - change user ID or become superuser Following the Unix philosophy of using a collection of specialized small tools that do one thing best, when performing an action as another user it seems to be the correct thing to use a tool that "execute a command as another user" rather than one whose primary goal is "change user ID or become superuser". But on the other hand, su is part of corutils (which is in the base install), so using su would remove the need of installing a new package for about 25% of our users. What are your thoughts on this? Thanks for getting a fellow Debian Maintainer out of his confusion! (and let's hope it doesn't turn into a vi vs. Emacs debate ;) ) +Emilien [0] http://pts.debian.net/pkg/gnuhealth [1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739657 [2] Looking at popcon (obvious notice about [un]reliability of that data applies) data from 2014-02-24: - There are 167453 registered popcon users that sent information - corutils (package that amongst others, contains su) sports 167451 installations (99.998% of installs) [3] - sudo reports 127695 installations (76% of installs) [4] [3] http://qa.debian.org/popcon.php?package=sudo [4] http://qa.debian.org/popcon.php?package=coreutils -- To UNSUBSCRIBE, email to debian-bugs-rc-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org