chop($host = `uname -n`);
+if (CheckXFS(1)) {
+ $fontPath = "unix/:7100";
+} else {
+ if (CheckXFS(0)) {
+ $fontPath = "inet/:7100"; # Some Solaris systems require this
+ }
+}
+
@fontpaths = ('/usr/share/X11/fonts', '/usr/share/fonts', '/usr/share/fonts/X11/');
if (! -l "/usr/lib/X11") {push(@fontpaths, '/usr/lib/X11/fonts');}
if (! -l "/usr/X11") {push(@fontpaths, '/usr/X11/lib/X11/fonts');}
foreach $_ftype (@fonttypes) {
if (-f "$_fpath/$_ftype/fonts.dir") {
if (! -l "$_fpath/$_ftype") {
- $fontPath .= "$_fpath/$_ftype,";
+ $defFontPath .= "$_fpath/$_ftype,";
}
}
}
}
-if ($fontPath) {
- if (substr($fontPath, -1, 1) == ',') {
- chop $fontPath;
+if ($defFontPath) {
+ if (substr($defFontPath, -1, 1) == ',') {
+ chop $defFontPath;
}
}
-$defFontPath = "unix/:7100";
-
# Check command line options
&ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,"-kill",1,
}
if ($opt{'-fp'}) {
$fontPath = $opt{'-fp'};
+ $fpArgSpecified = 1;
}
&CheckGeometryAndDepth();
sleep(3);
unless (kill 0, `cat $pidFile`) {
- warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the vncserver\n";
- warn "script was not able to figure out an appropriate X11 font path for this system\n";
- warn "or because the font path you specified with the -fp argument was not valid.\n";
- warn "Attempting to restart Xvnc using the X Font Server (xfs) ...\n";
+ if ($fpArgSpecified) {
+ warn "\nWARNING: The first attempt to start Xvnc failed, probably because the font\n";
+ warn "path you specified using the -fp argument is incorrect. Attempting to\n";
+ warn "determine an appropriate font path for this system and restart Xvnc using\n";
+ warn "that font path ...\n";
+ } else {
+ warn "\nWARNING: The first attempt to start Xvnc failed, possibly because the X Font\n";
+ warn "Server is not running and this system does not use a font catalog. Attempting\n";
+ warn "to determine an appropriate font path for this system and restart Xvnc using\n";
+ warn "that font path ...\n";
+ }
$cmd =~ s@-fp [^ ]+@@;
$cmd .= " -fp $defFontPath" if ($defFontPath);
system("$cmd & echo \$! >$pidFile");
}
+#
+# CheckXFS checks if the X Font Server is running on the default port (7100)
+#
+
+sub CheckXFS
+{
+ if (@_ == 1) {
+ socket(S, $AF_UNIX, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
+ eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))';
+ if (!bind(S, pack('S a108', $AF_UNIX, 7100))) {
+ close(S);
+ return 0;
+ }
+ } else {
+ socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
+ eval 'setsockopt(S, &SOL_SOCKET, &SO_REUSEADDR, pack("l", 1))';
+ if (!bind(S, pack('S n a4 x8', $AF_INET, 7100))) {
+ close(S);
+ return 0;
+ }
+ }
+ close(S);
+ return 1;
+}
+
+
#
# GetXDisplayDefaults uses xdpyinfo to find out the geometry, depth and pixel
# format of the current X display being used. If successful, it sets the
if (($os eq "SunOS") && ($osrev !~ /^4/)) {
$AF_INET = 2;
$SOCK_STREAM = 2;
+ $AF_UNIX = 1;
} else {
$AF_INET = 2;
$SOCK_STREAM = 1;
+ $AF_UNIX = 1;
}
} else {
$AF_INET = &AF_INET;
$SOCK_STREAM = &SOCK_STREAM;
+ $AF_UNIX = &AF_UNIX;
}
} else {
$AF_INET = &AF_INET;
$SOCK_STREAM = &SOCK_STREAM;
+ $AF_UNIX = &AF_UNIX;
}
}
-.TH vncserver 1 "26 Mar 2009" "TigerVNC" "Virtual Network Computing"
+.TH vncserver 1 "15 Apr 2009" "TigerVNC" "Virtual Network Computing"
.SH NAME
vncserver \- start or stop a VNC server
.SH SYNOPSIS
.TP
.B \-fp \fIfont-path\fP
-The vncserver script will normally examine your system to figure out where it
-stores its X11 fonts and then generate an appropriate font path argument for
-Xvnc based on this. If your system stores its X11 fonts in a location that
-vncserver does not know about, however, then this may fail. In that case,
-vncserver will then try to contact the local X Font Server (xfs) on port 7100.
-Not all systems have xfs installed and running, so this may fail as well. In
-that case, you can manually specify a font path by using the
+If the vncserver script detects that the X Font Server (XFS) is running, it
+will attempt to start Xvnc and configure Xvnc to use XFS for font handling.
+Otherwise, if XFS is not running, the vncserver script will attempt to start
+Xvnc and allow Xvnc to use its own preferred method of font handling (which may
+be a hard-coded font path or, on more recent systems, a font catalog.) In
+any case, if Xvnc fails to start, the vncserver script will then attempt to
+determine an appropriate X font path for this system and start Xvnc using
+that font path.
+
+The
.B \-fp
-argument to vncserver.
-
-If you prefer to use the X Font Server by default rather than a static font
-path, then you can run
-
-.RS
-.RS
-vncserver -fp unix/:7100
-.RE
-.RE
+argument allows you to override the above fallback logic and specify a font
+path for Xvnc to use.
.SH FILES
Several VNC-related files are found in the directory $HOME/.vnc: