From: DRC Date: Wed, 15 Apr 2009 06:47:23 +0000 (+0000) Subject: Change font path logic such that XFS is used if it is available and running, otherwis... X-Git-Tag: v0.0.90~12 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36546c1e5f5139c710b41dc172ed7bfb294a4cff;p=tigervnc.git Change font path logic such that XFS is used if it is available and running, otherwise Xvnc is started with no -fp argument. If this fails, then Xvnc is restarted using the automatically-generated font path. git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3779 3789f03b-4d11-0410-bbf8-ca57d06f2519 --- diff --git a/unix/vncserver b/unix/vncserver index 07c3bec5..1578a5e0 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -81,6 +81,14 @@ $defaultXStartup 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');} @@ -97,19 +105,17 @@ foreach $_fpath (@fontpaths) { 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, @@ -135,6 +141,7 @@ if ($opt{'-pixelformat'}) { } if ($opt{'-fp'}) { $fontPath = $opt{'-fp'}; + $fpArgSpecified = 1; } &CheckGeometryAndDepth(); @@ -231,10 +238,17 @@ system("$cmd & echo \$! >$pidFile"); 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"); @@ -383,6 +397,32 @@ sub CheckDisplayNumber } +# +# 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 @@ -674,16 +714,20 @@ sub SanityCheck 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; } } diff --git a/unix/vncserver.man b/unix/vncserver.man index 1c283a7c..1c93107b 100644 --- a/unix/vncserver.man +++ b/unix/vncserver.man @@ -1,4 +1,4 @@ -.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 @@ -91,24 +91,19 @@ end of your xstartup file after a particular application exits. .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: