FreeNX server not running but responding (?!)

I’ve been working on getting NoMachine and FreeNX working together … and they’re both working well, listening on different ports (guess I should write a howto).

At some point I decided to write an init script to control FreeNX behaviour (start, stop, status, setup), since the Ubuntu version has one (called freenx-server) and openSUSE doesn’t, but I noticed that it was not necessary, as FreeNX got started automatically… but how ? I could not find any init.d script or command which would start the FreeNX server. Indeed it wasn’t actually running :

neelix:~ # /usr/bin/nxserver --status
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 110 NX Server is stopped
NX> 999 Bye

However I can start NX sessions on that machine and I just opened 3 from 3 different clients (2 under the same user).

neelix:~ # /usr/bin/nxserver --list
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 127 Sessions list:

Server     Display Username        Remote IP       Session ID
------ ------- --------------- --------------- --------------------------------
127.0.0.1	1002	jenny	xxx.xxx.xxx.x	2AA3B7D0B23C160C971F76A5AAE1F35C
127.0.0.1	1001	agnelo	xxx.xxx.xxx.x	CF8F9F2A999C30311058519075225979
127.0.0.1	1000	agnelo	xxx.xxx.xxx.x	ED1CD199D43663F71682DB0F744383F2
NX> 999 Bye

It seems that starting or stopping the server with nxserver --start and nxserver --stop has no effect … except reporting accordingly that the server is running or not running (nxserver --status). But whether the server appears to be running or not doesn’t make any difference: clients can connect !

What sense does it make ?

I’ve been trying version 0.7.2 from RemoteDesktop repo, version 0.7.3 from somebody’s home repo and finally self compiled 0.7.3. Same behaviour.

BTW NoMachine nxserver is currently stopped and disabled at all runlevels (I wouldn’t have let me open 3 sessions anyway and it’s enough to look at some environment variables to distinguish FreeNX sessions from Nomachine ones.) So an interaction with the NoNachine server is excluded here.

neelix:~ # chkconfig --list nxserver
nxserver                  0:off  1:off  2:off  3:off  4:off  5:off  6:off

Is it getting started via xinetd?
Anything in /etc/xinetd.d?

Nope. It is apparently not started anywhere and it is apparently not running (according to nxserver --status).
An the funny thing is that it will continue to respond (clients can open sessions) even if explicitely stopped (with nxserver --stop).
So where is the daemon?

xinetd based services:
        chargen:            off
        chargen-udp:        off
        cups-lpd:           off
        cvs:                off
        daytime:            off
        daytime-udp:        off
        discard:            off
        discard-udp:        off
        echo:               off
        echo-udp:           off
        netstat:            off
        pure-ftpd:          off
        rsync:              on
        sane-port:          off
        servers:            off
        services:           off
        svnserve:           off
        swat:               off
        systat:             off
        time:               off
        time-udp:           off
        vnc:                off

Here’s the situation

boot in runlevel 3

neelix:~ # nxserver --status
No processes found.
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 110 NX Server is stopped
NX> 999 Bye

But clients can open Gnome or Kde sessions, no X queries though (since XDMCP isn’t running on the server yet).

neelix:~ # nxserver --stop 
No processes found.
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 500 Service was already stopped
NX> 999 Bye

Doesn’t do anything, since the service wasn’t running (apparently). Clients can still connect

neelix:~ # nxserver --start 
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 122 Service started
NX> 999 Bye

Supposely starts nxserver. Clients can connect.

neelix:~ # nxserver --stop 
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 123 Service stopped
NX> 999 Bye

Successfully stops the nxserver. But clients can still connect.

neelix:~ # nxserver --status
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 110 NX Server is stopped
NX> 999 Bye

Server is reported as not running again. Clients can connect.

Whatever I do with nxserver, NX clients can get a session on the server machine. nxserver --stop and nxserver --start have no effect.

Hi
That’s because NX uses the sshd service to start the server/client
connection :wink:


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.3 Milestone 2 (i586) Kernel 2.6.33-rc7-3-desktop
up 1 day 2:26, 2 users, load average: 0.13, 0.19, 0.09
ASUS eeePC 1000HE ATOM N280 1.66GHz | GPU Mobile 945GM/GMS/GME

OK. That explains why NX is listening and responding. But it doesn’t explain why nxserver --start and nxserver --stop are doing nothing. In order to start/stop FreeNX, you have to run it on an alternate port and open/close that port… so it was necessary to have an init.d script for that purpose.

On 03/01/2010 10:56 AM, please try again wrote:
>
> OK. That explains why NX is listening and responding. But it doesn’t
> explain why nxserver --start and nxserver --stop are doing nothing. In
> order to start/stop FreeNX, you have to run it on an alternate port and
> open/close that port… so it was necessary to have an init.d script
> for that purpose.
>
>

NX uses ssh so why not stop sshd?
Why wouldn’t you allow GUI if you allow CLI over ssh.

Vahis

“Sunrise 7:21am (EET), sunset 5:44pm (EET) at Espoo, FI (10:22 hours
daylight)”
http://waxborg.servepics.com
Linux #1 SMP 2010-01-14 18:58:36 +0100 x86_64
5:32pm up 9 days 10:01, 15 users, load average: 0.00, 0.04, 0.00

For the same reason why I won’t shutdown a system to exit a program.

The question was not why individuals do what they want but why computer programs don’t do what they are expected to do (i.e start/stop when they provide --start and --stop options).

On 03/02/2010 04:36 AM, please try again wrote:
>
> Vahis;2128786 Wrote:
>>
>> NX uses ssh so why not stop sshd?
>>
>
> For the same reason why I won’t shutdown a system to exit a program.
>
> Vahis;2128786 Wrote:
>>
>> Why wouldn’t you allow GUI if you allow CLI over ssh.
>>
>
> The question was not why individuals do what they want but why computer
> programs don’t do what they are expected to do (i.e start/stop when they
> provide --start and --stop options).
>
>

O.K. I see your point.
I noticed one thing though (from your first post):

FreeNX got started automatically… but how ? I could
not find any init.d script or command which would start the FreeNX
server. Indeed it wasn’t actually running :

neelix:~ # /usr/bin/nxserver --status
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.2.0)
NX> 110 NX Server is stopped

I think the above is from the NoMachine one, not FreeNX

My FreeNX version is 0.7.2-18.1
from repo-oss

You can check here:
http://software.opensuse.org/search?p=1&baseproject=ALL&q=freenx

Vahis

“Sunrise 7:18am (EET), sunset 5:47pm (EET) at Espoo, FI (10:28 hours
daylight)”
http://waxborg.servepics.com
Linux #1 SMP 2010-01-14 18:58:36 +0100 x86_64
6:05am up 9 days 22:34, 15 users, load average: 1.33, 0.51, 0.23

This version refers to the nxagent (in the separate package NX). FreeNX depends on it, so you should have it too: rpm -qi NX

My FreeNX version is 0.7.3-5.1, compiled from source obtained from the same location you indicated in your post.
The reason why I installed 0.7.3 is that version 0.7.2 doesn’t handle XDMCP queries correctly.

/usr/bin/nxserver is from FreeNX. The NoMachine nxserver is /usr/NX/bin/nxserver.

Hmmm … I think I could explain something (to myself and to anyone interested). The FreeNX public key is in /var/lib/nxserver/home/.ssh/authorized_keys2. When you do nxserver --stop , the file gets renamed to authorized_keys2.disabled. When you do nxserver --start , authorized_keys2.disabled gets copied back to authorized_keys2. When authorized_keys2 is missing (renamed) clients should normally get a connection refused, and so you could pretend that the service is not running (although lsof -c sshd will show you that it is not true).
Now, I’m running NoMachine too on a different port. FreeNX forwards connection to that particular port to the NoMachine nxserver.

/etc/nxserver/node.conf
SSHD_PORT=9122
...
ENABLE_NOMACHINE_FORWARD_PORT="1"
NOMACHINE_FORWARD_PORT="9123"
NOMACHINE_SERVER="/usr/NX/bin/nxserver"
NOMACHINE_NX_HOME_DIR="/usr/NX/home/nx"
...

I use the same DSA private-public key pair for both nx servers. So I copied /var/lib/nxserver/home/.ssh/authorized_keys2 to /usr/NX/home/nx/.ssh/. And I believe that does the trick. FreeNX must use that key for authentication…

Nope! I got it.
FreeNX creates user nx:

nx:x:126:1002:FreeNX Server,,,:/var/lib/nxserver/home:/usr/bin/nxserver

NoMachine creates/changes user nx:

nx:x:126:1002:FreeNX Server,,,:/usr/NX/home/nx:/usr/NX/bin/nxserver

Now if you just modified the nx user home directory:
usermod -d /usr/NX/home/nx nx

FreeNX will get its public key from there and open a session to the client… even if you think you disabled it.

There is a sample /etc/init.d/freenx-server in the rpm source, which can be used to start/stop the service.

#!/bin/bash
#
# Sample startup script for FreeNX server
#
# Coypright (c) 2007 by Fabian Franz <freenx@fabian-franz.de>.
#
# License: GNU GPL, version 2
#
# SVN: $Id: freenx-server 485 2008-03-02 10:29:52Z fabianx $
#

# Read the config file
. $(PATH=$(cd $(dirname $0) && pwd):$PATH which nxloadconfig) --

case "$1" in
        start)
                 ! -d "/tmp/.X11-unix" ] && mkdir -m1755 /tmp/.X11-unix/
                $PATH_BIN/nxserver --cleanup
                $PATH_BIN/nxserver --start
        ;;
        stop)
                $PATH_BIN/nxserver --stop
                $PATH_BIN/nxserver --cleanup
        ;;      
        *)
                echo "Usage: $0 <start|stop>"
        ;;
esac

That’s it. Sorry for talking to myself, but I just got the explanation while writing this post. :wink: