Patches for VNC

These are some small patches for VNC on Unix-like operating systems.

Running VNC from Xinetd through a wrapper

The Inetd and display number patch makes it possible to launch VNC servers on demand when users connect, and run programs without requiring the users to log in. One case where this can be useful is if you have an X program that you want to make available to remote users, and you don't want to create user accounts for your users because your program handles access control its own way. It would be as easily accessed as a web interface and still have all the possibilities of a full-featured GUI application.

To run XVNC – the Unix VNC server – from Xinetd (or Inetd) you must give it the -inetd parameter. XVNC will then pick an unused display number for its virtual screen. To get any programs running on the virtual screen, XVNC will normally have to contact a display manager which will display a login window. To avoid this you can let Xinetd run a wrapper program which first launches XVNC and then starts one or more other programs on the newly created virtual screen. The wrapper will have to tell these other programs the display number of the virtual screen, so instead of letting XVNC choose the display number the wrapper must choose it and tell XVNC which number to use.

XVNC behaves a little strangely when both -inetd and a display number are given on the command line. It refuses to run if -inetd appears before the display number, but if the display number appears first, then XVNC just ignores it and uses the first free number. With this patch applied, XVNC will always use the specified display number if one is given on the command line, and will pick a free number only if -inetd is given but no display number.

These files are available:

Inetd_and_display_number_3.3.6.patch   The patch for VNC 3.3.6.
Inetd_and_display_number_3.3.7.patch The patch for VNC 3.3.7.
Inetd-VNC-wrapper.c A simple wrapper program.
xinetd.conf_template A sample configuration file for Xinetd. Edit it to fit your needs.

Inetd-VNC-wrapper requires at least three parameters. The first shall be the program to run after XVNC has been started, the second shall be a file to send the output from that program to, and the third shall be the full path to the XVNC executable. Any additional parameters will be forwarded unchanged to XVNC. Inetd-VNC-wrapper will find the lowest unused display number and give that as the first parameter to XVNC. The second parameter will be "-inetd". The fourth parameter to Inetd-VNC-wrapper – if there is one – becomes the third parameter to XVNC, and so on. Do not give "-inetd" or a display number as a parameter to Inetd-VNC-wrapper.

When Inetd-VNC-wrapper has started XVNC and it sees that the chosen display number is in use, it assumes that XVNC is ready. It will then set the DISPLAY environment variable to the chosen display number, and then start the program that was given in the first parameter.

Choosing the log directory

XVNC normally writes error messages to the standard error stream, which can be redirected to a suitable log file. When it is started by Xinetd or Inetd the standard error stream is the connection to the viewer, and writing error messages there would only break the protocol. Therefore XVNC closes the standard error stream when it is given the -inetd parameter, and tries to write log messages to a file in /usr/adm. This is not so good, because XVNC should preferably be run as an unprivileged user and normally only Root can write in the /usr tree. Besides, some systems don't even have a /usr/adm directory.

The log directory patch adds a -logdir parameter so that a better log directory can be specified on the command line. XVNC will then create its log file in this directory.

Equipped with IPv6. Valid XHTML 1.1. Valid CSS 2.

published 2003-04-16