← Back to team overview

clicompanion-devs team mailing list archive

Re: lp:~bdfhjk/clicompanion/sudo-control-add into lp:~clicompanion-devs/clicompanion/debian

 

On 01/14/2012 12:37 PM, David Caro wrote:

> Review: Needs Information


> Are you sure that we must force the debian user to use sudo? maybe it
> whold be better to add some logic to the commands (something like [[
> wchich sudo ]] && getroot="sudo" || geroot="su -c"; $getroot command
> ), it's not as nice as only sudo, but works without it.


If you are going to mess with this, it would probably be leaner to make
an (optional) environment variable SUDO, the commands are then something
like

  ${SUDO:-sudo} apt-get install

and the clicompanion UI can have a way to set that variable in the
environment of the terminal window it launches, so it can (for example)
be set to su -c, or to gksudo for a GUI password prompt on both OSes,
for example, but if you do nothing, it uses sudo as before.

There might be quoting issues with su -c, I am not sure, especially for
commands that are include io redirection.  For example, doing su -c "foo
>baz" and su -c "foo" >baz are subtly different.  In one baz is written
by root, in the second it is written by $USER.

A second approach could be to have a set of commands that use sudo, and
a set that use su, and tag one as being for Ubuntu and the other for
Debian (or test whether the root account has is locked?) and the show
the user the set of commands that is appropriate for them?

Jonathan