Comment 25 for bug 796076

Revision history for this message
Freecore (softdreamter) wrote :

Temporary SOLUTION:

I've found another workaround. Unfortunately for us this doesn't seems to be a bug, at least I guess there's no intention from gnome developers to solve it soon:

A upstream developer said: "You shouldn't start GNOME programmes with elevated privileges, it's not supported. In any case, not a gnome-terminal bug". It's not just nautilus it's any gnome application with a GUI.

This can be confirmed according to the upstream of the Nautilus bug, https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/805682, at Gnome bugzilla (https://bugzilla.gnome.org/show_bug.cgi?id=654184). It's clear that Gnome developers don't design their programs to be runned as root.

So, since they don't want to support gnome graphical programs as root, it's not a bug. If you can read more about why they don't support this you can read:
- http://ubuntuforums.org/showthread.php?t=2014450
- https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1019995

But it IS a problem if we want to start gnome graphical programs as root. So we need alternative solutions:

- Paddy Landau have created a workaround for it (comment #20) and posted it at http://ubuntuforums.org/showpost.php?p=12071894&postcount=81.
- You can use alternative applications (like graphical leafpad or vim and nando in the terminal).
- Running sudo gedit (NOT recommended, graphical programs should be runned with gksudo or kdesudo)
- The simplest solution I got. (See down).

As Derek White posted in https://bugs.launchpad.net/ubuntu/+source/gedit/+bug/890041.

$ gedit # opens untitled document
$ gedit /path/to/file # opens file
$ sudo gedit /path/to/file # opens file
$ gksu gedit /path/to/file # opens file & untitled document
$ gksudo gedit /path/to/file # opens file & untitled document

I figured out that it only happens when you try to gksudo with other user. For example:

$ gksudo -u userA /path/to/file # Will opens file normally if logged as userA.
$ gksudo /path/to/file # Will also opens normally if you're logged as root (with sudo -i or something).

But if you are root and try to gksudo with other user it will brings the untitled document again:

$ gksudo -u UserA /path/to/file # Will opens file & untitled document.

So, as long as we are supossed to run graphical applications with gksudo, the solution is to be logged as root and run gedit with gksudo (whitout parameters it'll run as root). If you want to do this in one single line you can do:

$ sudo gksudo gedit /path/to/file # Works perfectly.
$ gksudo gksudo gedit /path/to/file # Works perfectly. I recomend this, specially if you want to call gedit in a script or something.

That's it!

I wish this can help to devs to deciding fix this problem an support graphical as root. Or someone else to add the feature to Gnome applications.