On 02/27/2014 03:37 PM, David Kalnischkies wrote: > On Wed, Feb 26, 2014 at 04:07:35PM +0100, Emilien Klein wrote: >> In the pre- and postinst scripts, a command has to be performed as >> that user (e.g. make a backup of the database). > […] >> I am wondering what the best way is to fix this. I see 2 solutions: >> 1. Depend on sudo >> 2. Use "su --command" instead > > Beside what others already said: > As you said it is run in preinst scripts you would need to pre-depend on > sudo – and you would need to discuss this first on debian-devel@ as > strongly recommend by debian-policy (§3.5 and §7.2). The outcome of this > discussion would probably be that you should use su… > > su on the other hand is 'free' to use as it is provided by the essential > login package, so no dependency is needed at all.
I have made the switch to su instead of sudo. One minor challenge that I faced is that I couldn't get the commands to run using su. With the help of Karsten Hilbert I understood that the issue was that the user being a system user, she didn't have a shell (default shell for new system users is /bin/false). Running the commands as su --shell /bin/sh -c <COMMAND> <USERNAME> works as expected. Thanks Andreas, Karsten, David and Thibaut for your input. +Emilien
signature.asc
Description: OpenPGP digital signature