Bug 7582 - xdg-su should not care if there is no GUI when being run as root.
Summary: xdg-su should not care if there is no GUI when being run as root.
Alias: None
Product: Portland
Classification: Unclassified
Component: xdg-utils (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: high normal
Assignee: Fathi Boudra
QA Contact:
Depends on:
Reported: 2006-07-20 15:32 UTC by Tom Whipple
Modified: 2019-02-16 13:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

Don't depend on $DISPLAY if already in the right account (695 bytes, patch)
2012-12-05 19:55 UTC, Francois Gouget
Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Whipple 2006-07-20 15:32:25 UTC
Suppose we are already root. Then,

# xdg-su -c whoami

Should simply print "root" without any difficulty. Instead,
Command (xdg-su -c whoami) gave exit code 3, expected 0
Incorrect output written to stdout, as shown below
expected stdout:root

Unexpected output written to stderr, as shown below:
stderr:xdg-su: no graphical method available for invoking 'whoami' as 'root'

See test case xdg-su/t.su_basic_asroot
Comment 1 Waldo Bastian 2006-07-31 08:38:05 UTC
Defer till after 1.0
xdg-su will be dropped from 1.0 release
Comment 2 Nicolas Lécureuil 2009-08-03 13:36:44 UTC
works perfectly here

#./xdg-su -c whoami

can you still reproduce with a cvs snapshot ?
Comment 3 Francois Gouget 2012-12-05 19:53:48 UTC
I can still reproduce this problem here:

# DISPLAY= xdg-su -c whoami
xprop:  unable to open display ''
./xdg-su: 304: [: x: unexpected operator
xdg-su: no graphical method available for invoking 'whoami' as 'root'

xdg-su does say that it's meant 'for use inside a desktop session only'. But I still feel it would make sense to fix this (see the attached patch).
Comment 4 Francois Gouget 2012-12-05 19:55:05 UTC
Created attachment 71041 [details] [review]
Don't depend on $DISPLAY if already in the right account
Comment 5 Francois Gouget 2015-12-07 10:14:22 UTC
This bug is still present in b110b355 (2015/11/12).
Comment 6 Simon Lees (SUSE) 2016-11-03 00:31:33 UTC
Personally I don't think it makes sense to run xdg-su outside a graphical session, if one launches a desktop file calling xdg-su then a graphical prompt needs to be shown to ask for the password. If you are running from a terminal using "su -c".

There is of course the issues around wayland where I don't think xdg-su works currently.
Comment 7 GitLab Migration User 2019-02-16 13:28:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/14.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.