Gksu in 14.04?

Bob ubuntu-qygzanxc at listemail.net
Wed Aug 6 22:52:28 UTC 2014


** Reply to message from Tom H <tomh0665 at gmail.com> on Wed, 6 Aug 2014 17:47:34
-0400

Warning I am a newbe to linux.

When I need to edit a config file that has root privileges I use "sudo gedit". 
I have seen many messages that say I should not do that.  It does work so I
assume that there is some side effect that can cause me problems.  What
problems could I have using "sudo gedit"?

I can not get pkexec working, see below.

I would like to get pkexec working if it is the correct tool to use for
executing gui applications as root.


> On Wed, Aug 6, 2014 at 5:20 PM, MR ZenWiz <mrzenwiz at gmail.com> wrote:
> > On Wed, Aug 6, 2014 at 1:39 PM, Tom H <tomh0665 at gmail.com> wrote:
> >>
> >> It works with
> >>
> >> pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY XDG_RUNTIME_DIR=/tmp nautilus


I normally don't run nautilus but do want to run gedit which gets the same
errors listed below.

I tried the above command line and it does not work on my system.  I get the
following error.

bob1 at Jupiter:~$ pkexec env DISPLAY=$DISPLAY XAUTHORITY=$AUTHORITY
XDG_RUNTIME_DIR=/tmp nautilus
No protocol specified

** (gedit:23645): WARNING **: Could not open X display
No protocol specified

(gedit:23645): Gtk-WARNING **: cannot open display: :0
bob1 at Jupiter:~$ 

>From my testing the only environment variable needed (on my system) is
XDG_RUNTIME_DIR.

using 
bob1 at Jupiter:~$ pkexec env XAUTHORITY=$AUTHORITY XDG_RUNTIME_DIR=/tmp gedit
or
bob1 at Jupiter:~$ pkexec env XDG_RUNTIME_DIR=/tmp nautilus
I get the following error.

(gedit:23637): Gtk-WARNING **: cannot open display: 
bob1 at Jupiter:~$ 


> >>
> >> from a terminal (but not from alt-f2!).
> >
> > Thanks again.
> >
> > When I first tried pkexec thunar, it failed as Chris described, but
> > after I ran it with your suggestion above, that worked, and it also
> > works without the env spec.
> >
> > I did find it also interesting that all those variables are already in
> > my environment, so I'm not sure why it didn't work the first time
> > without the env... extension added.
> 
> You're welcome.
> 
> Those variables are in your environment but in the above command,
> you're setting them for root.
> 
> From a security perspective, it'll be better to set something other
> than "/tmp" as XDG_RUNTIME_DIR. I was just testing and forgot to
> mention it earlier.

Would XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR work?

-- 
Robert Blair




More information about the ubuntu-users mailing list