[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gksudo -u user2 /usr/bin/links2 -g



Marko Randjelovic wrote:
> gksudo -u user2 /usr/bin/epiphany-browser -g # works

Epiphany opens its own graphics window.  gksudo is designed for
applications like epiphany that open its own window.

> sudo -u user2 /usr/bin/links2 -g # works

Sure.  That just runs in the same terminal you started the command.
Nothing interesting there.

> gksudo -u user2 /usr/bin/links2 -g # does not work

Needs a terminal.  How can it work without one?  It can't.  Right at
this point is where thing went wrong for you.  links2 reads stdin and
writes stdout and expects TERM to tell it what type of terminal escape
sequences to use.  But you have asked gksudo to launch it into the
background.  That can't work.  You will end up with both your shell
and the links2 program reading from your keyboard at the same time.

> In terminal, when I run those commands with links, elinks, links2
> (with or without -g), prompt disappears and as i press keys
> characters appear in the terminal. At first run, Welcome screen
> shows, but again no keys have no effect. After CTRL+C, only gksudo
> process disappears, and other 2 remain.
> 
> Does someone have an idea why could this work like this?

It is very similar to running:

  $ lynx &

Except that bash has job control and therefore will stop the process
upon SIGTTOU (Terminal output for background process) and prevent that
from happening.  Because it isn't something you would normally want as
you can see by your problems.  But if you can start a shell without
job control then you would find yourself in the same situation.

The answer is do not use gksu or gksudo on text programs.  For text
programs use su or sudo and run them in the current terminal window.

If you really want to run a text program but want it to launch in a
different terminal *and* want it to use the gksu/gksudo to have it run
as root then you must launch a terminal.  Have the terminal launch
your text application.

  gksudo -u user2 -g -- xterm -e links2

Feel free to use the terminal of your choice.  But specifying the
terminal and the command to run on that terminal makes the most sense
to me.  (Note in Debian the presense of x-terminal-emulator as a
system configured preferred default terminal.  See "update-alternatives
--display x-terminal-emulator" for more.)

The above all suffer from the problem of running the text browser as
root.  Why are you trying to do this?  I don't understand any benefit
from doing so.  And I see some problems with doing so.  Please say a
few words about what led you to doing it that way.  Since it is a web
browser it doesn't benefit you by running it as root.

Bob

Attachment: signature.asc
Description: Digital signature


Reply to: