NX script, still broken
Warren Togami <[email protected]>
| Newsgroups | gmane.linux.terminal-server.devel |
|---|---|
| Message-ID | <[email protected]> |
I looked at the thread began by Veli-Matti Lintu entitled "nxagent
continued.." and tried his script with nx-3.2.0 in Fedora. It is an
interesting approach that does indeed work transparently with no other
LTSP changes. This approach shims nxagent between the X clients (i.e.
gnome-session) and the X server with a proxy X server that merely
reduces the network round-trips. This approach is interesting but
ultimately proves to be unusable for a few reasons.
1) NX is a horrible piece of software with a tremendous amount of bugs
making it barely usable. Examples: nxagent doesn't work on x86_64 at
all, had to use i386. It still has hard coded paths in /usr/X11R6.
nxagent needs a long delay before it will handle X clients. The "wait
for SIGUSR1" thing is unsafe to depend on with nxagent. There were
other problems as well...
2) This approach did successfully reduce Youtube video playing from
65mbit/sec to 20mbit/sec for example. But it also made it impossible to
do remote GL like compiz.
3) That Youtube video was reduced in bandwidth substantially by making
it very jerky and unviewable. Also interactivity with the X session
over the network took 20-30 seconds for a click to be recognized while
it was going on. Unusable.
I suppose it *could* be more interactive with a full end-to-end NX
session. I will attempt to try this later, but I am not holding out hope.
Below is the improved script with notes.
#!/bin/bash
SESS_DISPLAY=1000
# XXX: We would need a better way to do this.
# This is racy and INSECURE.
# It writes to /tmp/.X11-unix/ which any user can write, and it is
# totally predictable because it is incremental.
# Even randomized it is unsafe and should not be shipped in any
# distribution.
while true
do
let TEST_DISPLAY=$SESS_DISPLAY+6000
if [ -f /tmp/.X${SESS_DISPLAY}-lock ]; then
let SESS_DISPLAY=$SESS_DISPLAY+1
continue
fi
if [ -f /tmp/.X11-unix/X${SESS_DISPLAY} ]; then
let SESS_DISPLAY=$SESS_DISPLAY+1
continue
fi
if nc -z 127.0.0.1 $TEST_DISPLAY 2>/dev/null
then
let SESS_DISPLAY=$SESS_DISPLAY+1
continue
fi
break
done
# Identify the specific entry in xauth that we want to copy
case "$DISPLAY" in
localhost*)
# ssh forwarded xauth proxy or local X server
REALDISPNUMBER="${DISPLAY##localhost:}"
# we need the two spaces after
XAUTHENTRY="unix:$(echo $REALDISPNUMBER | awk -F'.' '{print
$1}') "
;;
*)
# assume hostname or IP address
XAUTHENTRY="$DISPLAY"
;;
esac
KEY=$(xauth list | grep "$XAUTHENTRY"| awk '{print $3}')
PROTOCOL=$(xauth list | grep "$XAUTHENTRY"| awk '{print $2}')
### It turns out that the way it was grabbing keys from xauth was wrong.
### It was grabbing old stale keys because it was doing it in the same
### fashion as ldm's script, which grabs the wrong key in this case.
### I fixed that above, but then realized that we do not even want this
### key. We want a new key generated for nxagent... so the above should
### be ripped out.
KEY=`mcookie`
PROTOCOL=MIT-MAGIC-COOKIE-1
xauth remove :${SESS_DISPLAY}
xauth add :${SESS_DISPLAY} ${PROTOCOL} ${KEY}
ulimit -c unlimited
/usr/bin/nxagent :${SESS_DISPLAY} -D \
-auth ~/.Xauthority -nopersistent -noignore &
ulimit -c 0
# UGLY HACK: We need to properly detect that X is done launching before
# proceeding
# Normally you would wait for SIGUSR1 from the child process, but
# we can't do that in a shell script. Another approach is to run
# an X client in a loop.
if [ -x /usr/bin/setxkbmap ]; then
while true; do
#/usr/bin/setxkbmap 2> /dev/null
/usr/bin/xhost
RETVAL=$?
if [ $RETVAL -eq 1 ]; then
sleep 0.2
else
break
fi
done
fi
# But that didn't work! nxagent tells the X client that it is ready,
# but then proceeds to fail when gnome-session talks to nxagent.
# An arbitrary delay before gnome-session seems to solve this issue.
sleep 5
export REAL_DISPLAY=${DISPLAY}
DISPLAY=:${SESS_DISPLAY} /usr/bin/gnome-session
Warren Togami
[email protected]
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you. Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_____________________________________________________________________
Ltsp-developer mailing list. To un-subscribe, or change prefs, goto:
https://lists.sourceforge.net/lists/listinfo/ltsp-developer
For additional LTSP help, try #ltsp channel on irc.freenode.net