Xvnc has built-in support to run from inetd. If a user points his vncviewer to a certain port on the server, a VNC-based xdm session will automatically be launched.
vncsmall 5950/tcp # 800x600x24
vnclarge 5951/tcp # 1024x768x24
vncsmall stream tcp nowait nobody /usr/local/bin/Xvncinetd Xvncinetd 800x600 24
vnclarge stream tcp nowait nobody /usr/local/bin/Xvncinetd Xvncinetd 1024x768 24
/usr/local/bin/Xvncinetd wrapper script:
/usr/local/bin/Xvnc -inetd -query localhost -once -geometry $1 -depth $2
Two final remarks:
/tmp/.X11-unix/, so you may have to do a
chmod 1777 /tmp/.X11-unix.