[FreeNX-kNX] FreeNX XDM support A diff - u patch for nxnode

chris at ccburton.com chris at ccburton.com
Mon Nov 28 15:01:34 UTC 2011


Here's a patch to nxnode which adds code to support xdmcp. As you can see 
there isn't much to it !!

It adds code so it shouldn't affect anything else, but as ever, make a 
backup and test it "out of hours"
in case I messed up copying it into the email for example.

Notes
As a good common basis I've added it to the original 2008 version of 
nxnode
then run "diff" 
but
the nxnode from your distro will probably be different as various patches 
have been added.

You can add manually if "patch" doesnt work.


The "port" directive is ignored by my nxagent, but I added it anyway in 
case that changes.
"Broadcast" doesn't produce any broadcasts from my nxagent (it does from 
my ordinary Xorg).

If anyone finds port and broadcast working I'd be interested to know which 
version of NX you use.


You can add the following to /etc/nxserver/node.conf  :-

XDM_PORT=177
XDM_TYPE=query
XDM_HOST=myhost

Which supports the nxclient option to "Let the NX server decide, use host 
and port mandated by the NX server administrator"

If you want greater granularity, then you can change the parmeters using 
/usr/bin/nxacl for selected users or groups, which can overwrite whatever 
they select in nxclient,
or
if you trap port=-1 and then check the user, you can allow them to have 
their own default but still choose if they need to.

If you want to, you can add the "-from local-address" also to node.conf

XDM_LOCAL_ADDRESS="$(hostname --fqdn)"
or if you know the static ip address
XDM_LOCAL_ADDRESS="192.168.1.100"
depending
upon which interface on the FreeNX server the xdmcp will exit,

however
I have multihomed hosts and split dns etc.
so
I set the default to ask "ip route get xdmcp-server-name" for the src 
interface for the xdm host.

This also allows for changing the addressing or dhcp on your FreeNX 
machine.

In this case eiher miss out  XDM_LOCAL_ADDRESS or put
XDM_LOCAL_ADDRESS=""
into node.conf

The nxclient option "Query an X desktop manager" works with Host set to 
"localhost" set so you can test it against your FreeNX server itself.







--- nxnode      2008-08-23 13:09:39.000000000 +0100
+++ nxnode.xdmcp        2011-11-28 11:58:33.000000000 +0000
@@ -224,6 +224,9 @@
                unix-console)
                        NODE_STARTX=$COMMAND_XTERM
                ;;
+               unix-xdm)
+                       NODE_STARTX=""
+               ;;
                unix-default|*)
                        if [ -x "$HOME/$USER_X_STARTUP_SCRIPT" ]; then
                                NODE_STARTX="$HOME/$USER_X_STARTUP_SCRIPT"
@@ -522,6 +525,68 @@
                # nxproxy single application mode session
                [ "$SET_LD_LIBRARY_PATH" = "1" ] && export 
LD_LIBRARY_PATH="$PROXY_LIBRARY_PATH:$LD_LIBRARY_PATH"
                $PATH_BIN/nxproxy -C :$display $PROXY_EXTRA_OPTIONS 2>&3 &
+
+       elif [ "$type" = "unix-xdm" ]                   #eg 
--xdm_type="query" --xdm_host="192.168.1.100" --xdm_port="177"
+       then
+               XDM_PORT_TEST=$(getparam xdm_port)      # need to get this 
first to check for -1 . .
+               if [ $XDM_PORT_TEST != -1 ] ; then      # DON'T use any 
host/port values set up by the admin setting XDM_PORT XDM_TYPE XDM_HOST in 
node.conf
+                       XDM_PORT=$(getparam xdm_port)
+                       XDM_TYPE=$(getparam xdm_type)
+                       XDM_HOST=$(getparam xdm_host)
+               FROM_INTERFACE="" # initialise the " -from " parameter. If 
querying localhost (!!??) or listing localhost leave empty
+               # else
+                       # $XDM_PORT_TEST = -1 so use the so use the values 
already set from /etc/nxserver/node.conf (do nothing)
+               fi
+
+               # Anything parameters missing ??
+               [ -z $XDM_PORT ] && XDM_PORT=177                        # 
Set default if blank
+               [ -z $XDM_TYPE ] && XDM_TYPE="broadcast"                # 
No type is set, try broadcast and clear XDM_HOST
+               [ -z $XDM_HOST ] && XDM_HOST="localhost"                # 
Ensure XDM_HOST is set to something
+               [ $XDM_TYPE = "broadcast" ] && XDM_HOST=""      # Clear 
XDM_HOST if type is broadcast else nxagent complains
+               [ $XDM_TYPE = "list" ] && XDM_TYPE="indirect"   # nxclient 
says list but nxagent wants indirect
+
+               if [ $XDM_TYPE = "query" -a $XDM_HOST != "localhost" -o 
$XDM_TYPE = "indirect" -a $XDM_HOST != "localhost" ] ; then # ensure we 
have a "-from local-address" set
+                       # NOTE
+                       # local-address in "-from local-address" if a 
hostname,must resolve on the FREENX server
+                       #                to a (return) IP address 
accessible from xdmcp target host which you want to use.
+                       # so either set the relevent IP address or 
hostname manually in /etc/nxserver/node.conf
+                       #                i.e. add 
XDM_LOCAL_ADDRESS=hostname or XDM_LOCAL_ADDRESS=a.b.c.d
+                       # or hostname/hostname -fqdn should work in most 
cases,instead of the IP address
+                       # i.e. you can uncomment here
+                       # XDM_LOCAL_ADDRESS="$(hostname --fqdn)"
+                       #       or
+                       # XDM_LOCAL_ADDRESS="$(hostname)"
+                       #       both of which will resolv to a local IP 
address (and can also be put in /etc/nxserver/node.conf instead)
+                       # but
+                       # when multi-homed with a split DNS you might be 
in for some fun, so I ask "ip route get" for an egress address  for the 
xdmcp host.
+                       # In fact -from is there for just this reason, so 
. . . .
+
+                       if [ -z $XDM_LOCAL_ADDRESS ] ; then # If we don't 
have a local address/hostname set yet, let's see which interface ip route 
will choose for the xdmcp host
+                               if [ $(echo $XDM_HOST|egrep -c 
"^([0-9]{1,3}[.]){3}[0-9]{1,3}$" ) -eq 1 ] ; then
+                                       # Not a host-name & (maybe not a 
proper IP address, but I don't care)
+                                       XDM_HOST_ADDRESS=$XDM_HOST
+                               else
+                                       # A host name so resolv & get 1st 
IP address to ask IP route for an egress IP as a -from local-address
+                                       XDM_HOST_ADDRESS=$(dig +short 
+search $XDM_HOST|egrep "^([0-9]{1,3}[.]){3}[0-9]{1,3}$"|tr "\n" " "|cut 
-d " " -f1)
+                               fi
+
+                       XDM_LOCAL_ADDRESS="$(ip route get 
$XDM_HOST_ADDRESS|grep src|sed -e "s/^.* src //g") "
+                       fi
+                       # now we can set up the command line parameter
+                       FROM_INTERFACE=" -from $XDM_LOCAL_ADDRESS " 
+               fi
+               # add our options to AGENT_EXTRA_OPTIONS_X and need to 
remove the default " -nolisten tcp " if its still there.
+               AGENT_EXTRA_OPTIONS_X=$(echo " $AGENT_EXTRA_OPTIONS_X 
-$XDM_TYPE $XDM_HOST $FROM_INTERFACE -port $XDM_PORT "|sed -e "s/ 
-nolisten[ ]\{1,\}tcp//g")
+
+               [ "$SET_LD_LIBRARY_PATH" = "1" ] && export 
LD_LIBRARY_PATH="$AGENT_LIBRARY_PATH:$LD_LIBRARY_PATH"
+               P=$(node_agent_persistent_session)
+               FP=""
+               [ -n "$AGENT_FONT_SERVER" ] && FP="-fp $AGENT_FONT_SERVER"
+
+               # Start the agent
+ 
+               PATH="$PATH_BIN:$PATH" $PATH_BIN/nxagent $P $R -name "NX - 
$user@$SERVER_NAME:$display - $session (GPL Edition)" -option 
"$USER_FAKE_HOME/.nx/C-$sess_id/options" $K $G $B $FP 
$AGENT_EXTRA_OPTIONS_X :$display 2>&3 &
+
        else
                # nxagent session (X11)
                [ "$SET_LD_LIBRARY_PATH" = "1" ] && export 
LD_LIBRARY_PATH="$AGENT_LIBRARY_PATH:$LD_LIBRARY_PATH"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/freenx-knx/attachments/20111128/82fe3e77/attachment.html>


More information about the FreeNX-kNX mailing list