Re: Need help running command as another user using su
Does the "gnuhealth" user have a login shell ?
Karsten
On Fri, Feb 28, 2014 at 10:54:46PM +0100, Emilien Klein wrote:
> Date: Fri, 28 Feb 2014 22:54:46 +0100
> From: Emilien Klein <emilien+debian@klein.st>
> To: Debian Med Project List <debian-med@lists.debian.org>
> Cc: 739637@bugs.debian.org
> Subject: Need help running command as another user using su
>
> Hi,
>
> TLDR: is it possible to run a command as another user using su, if
> that user is a system user?
>
>
> I'm trying to solve bug#739637 by running the command as user
> gnuhealth, using the command `su` instead of `sudo`.
>
> Let's take a simple example to start, running the command whoami as
> another user, from a root shell.
>
> First, become root by your prefered way (I use sudo ;) )
> emilien@debiansid:~$ sudo su -
> [sudo] password for emilien:
> root@debiansid:~#
>
> Running the command using sudo, I see the username being returned as expected:
>
> root@debiansid:~# sudo -u gnuhealth whoami
> gnuhealth
>
>
> Now trying to reproduce that using su.
> According to the manpage:
> su [options] [username]
> -c, --command COMMAND
>
> So I would expect to first have the command name su, then -c and the
> command to execute, and then the username.
>
> root@debiansid:~# su -c whoami gnuhealth
> root@debiansid:~#
>
> That doesn't return the expected output.
>
> Trying different kinds of possibilities (quoting the command, using =
> and putting the username before the command) doesn't give better
> results:
>
> root@debiansid:~# su -c "whoami" gnuhealth
> root@debiansid:~# su -c=whoami gnuhealth
> root@debiansid:~# su -c="whoami" gnuhealth
> root@debiansid:~# su --command whoami gnuhealth
> root@debiansid:~# su --command "whoami" gnuhealth
> root@debiansid:~# su --command=whoami gnuhealth
> root@debiansid:~# su --command="whoami" gnuhealth
> root@debiansid:~# su gnuhealth -c whoami
> root@debiansid:~# su gnuhealth -c "whoami"
> root@debiansid:~# su gnuhealth -c=whoami
> root@debiansid:~# su gnuhealth -c="whoami"
> root@debiansid:~# su gnuhealth --command whoami
> root@debiansid:~# su gnuhealth --command "whoami"
> root@debiansid:~# su gnuhealth --command=whoami
> root@debiansid:~# su gnuhealth --command="whoami"
> root@debiansid:~#
>
> The weird part is that running these commands [*] in a terminal on my
> Ubuntu host machine *do* return the expected username back.
> What could be the reason I don't get the command su to run on my
> Debian sid machine?
> Are you able to run that?
>
>
> Aaaaaah, wait, now that I'm typing this, I have an enlightenment: the
> user is created as a system user (I believed according to the
> instructions on the GNU Health wiki, but I can't find that back now).
> Could that be the reason why I can't get su to run the command as that
> user?
>
> User creation is done in gnuhealth-server.postinst by this command:
> adduser --home /var/lib/gnuhealth --quiet --system --group gnuhealth
>
>
> Questions:
> - Is it possible to run a command as another user using su, if that
> user is a system user?
> - Should the created user not be a system user?
>
> Cheers,
> +Emilien
>
>
> [*] except the variants using = with -c
>
>
> --
> To UNSUBSCRIBE, email to debian-med-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> Archive: [🔎] CANqxmqHiQmFNmbyZYpi10j7G_OEZVNymMARLFa993S9OtAWpCg@mail.gmail.com">https://lists.debian.org/[🔎] CANqxmqHiQmFNmbyZYpi10j7G_OEZVNymMARLFa993S9OtAWpCg@mail.gmail.com
>
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
Reply to: