[OpenIndiana-discuss] su improvement request to export user DISPLAY

cpforum cpforum at orange.fr
Thu Feb 16 20:25:12 UTC 2012


Hi

When system admin su to root and launch X 11 utilities (for exemple system-config-printer) or java application (for exemple OpenOffice ./setup) they get something like that :

# xterm
xterm Xt error: Can't open display: %s
xterm: DISPLAY is not set

or less friendly 

# system-config-printer
/usr/lib/python2.6/vendor-packages/gtk-2.0/gtk/__init__.py:57: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/lib/system-config-printer/system-config-printer.py:100: GtkWarning: file gdkcursor-x11.c: line 262: assertion `GDK_IS_DISPLAY (display)' failed
busy_cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
Traceback (most recent call last):
File "/usr/lib/system-config-printer/system-config-printer.py", line 100, in 
busy_cursor = gtk.gdk.Cursor(gtk.gdk.WATCH)
RuntimeError: could not create GdkCursor object

One way to export DISPLAY to root (or others users) is to declare the following function inside the user .profile 

unset su
function su
{
if (( $# > 2 )) || [[ -z $DISPLAY ]]
then
print "Running /usr/bin/su"
/usr/bin/su $@
else
print "Running su exporting DISPLAY to root"
XDISPLAY="$(uname -n)/unix:${DISPLAY#*:}"
/usr/bin/su - ${2-root} -c "DISPLAY=${DISPLAY} ${SHELL} -c \
\"(/usr/bin/xauth -f $XAUTHORITY nextract - ${XDISPLAY} | \
/usr/bin/xauth nmerge - ; ${SHELL})\""
fi
}

The problem with this method is that you have to add theses line for every host (this method is not portable and a bit different with Solaris 10 and works only with bash and ksh).

So improvement to put a code doing the job inside su.c (with or without an -X option) makes Openindiana more friendly for system admin.





More information about the OpenIndiana-discuss mailing list