From: Pierre Ossman Date: Tue, 31 Jul 2018 14:06:17 +0000 (+0200) Subject: Start the sessions using xinit X-Git-Tag: v1.10.90~40^2~7 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c67a5f2557b00f570be20fef12273e872a5cc06e;p=tigervnc.git Start the sessions using xinit It keeps much better track of the X server and startup files than we can do. --- diff --git a/unix/vncserver/vncserver b/unix/vncserver/vncserver index 24f65248..4a1a58b2 100755 --- a/unix/vncserver/vncserver +++ b/unix/vncserver/vncserver @@ -109,8 +109,8 @@ my %config; # We set some reasonable defaults. Config file settings # override these where present. -$default_opts{desktop} = "edString($desktopName); -$default_opts{auth} = "edString($xauthorityFile); +$default_opts{desktop} = $desktopName; +$default_opts{auth} = $xauthorityFile; $default_opts{rfbwait} = 30000; $default_opts{rfbauth} = "$vncUserDir/passwd"; $default_opts{rfbport} = $vncPort; @@ -242,76 +242,42 @@ print XAUTH "add $host:$displayNumber . $cookie\n"; print XAUTH "add $host/unix:$displayNumber . $cookie\n"; close(XAUTH); +$ENV{XAUTHORITY} = $xauthorityFile; + # Now start the X VNC Server +@cmd = ("xinit"); + +push(@cmd, $Xsession, $session{'Exec'}); + +push(@cmd, '--'); + # We build up our Xvnc command with options -$cmd = $exedir."Xvnc :$displayNumber"; +push(@cmd, $exedir."Xvnc", ":$displayNumber"); foreach my $k (sort keys %config) { - $cmd .= " -$k $config{$k}"; + push(@cmd, "-$k"); + push(@cmd, $config{$k}) if $config{$k}; delete $default_opts{$k}; # file options take precedence } foreach my $k (sort keys %default_opts) { - $cmd .= " -$k $default_opts{$k}"; -} - -# Run $cmd and record the process ID. -$pidFile = "$vncUserDir/$host:$displayNumber.pid"; -system("$cmd & echo \$! >$pidFile"); - -# Give Xvnc a chance to start up - -sleep(3); -if ($fontPath ne $defFontPath) { - unless (kill 0, `cat $pidFile`) { - 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 font\n"; - warn "catalog is not properly configured. Attempting to determine an appropriate\n"; - warn "font path for this system and restart Xvnc using that font path ...\n"; - } - $cmd =~ s@-fp [^ ]+@@; - $cmd .= " -fp $defFontPath" if ($defFontPath); - system("$cmd & echo \$! >$pidFile"); - sleep(3); - } -} -unless (kill 0, `cat $pidFile`) { - warn "Could not start Xvnc.\n\n"; - unlink $pidFile; - open(LOG, "<$desktopLog"); - while () { print; } - close(LOG); - die "\n"; + push(@cmd, "-$k"); + push(@cmd, $default_opts{$k}) if $default_opts{$k}; } warn "\nNew '$desktopName' desktop is $host:$displayNumber\n\n"; -# Run the X startup script. warn "Starting desktop session $sessionname\n"; warn "Log file is $desktopLog\n\n"; -# If the unix domain socket exists then use that (DISPLAY=:n) otherwise use -# TCP (DISPLAY=host:n) - -if (-e "/tmp/.X11-unix/X$displayNumber" || - -e "/usr/spool/sockets/X11/$displayNumber") -{ - $ENV{DISPLAY}= ":$displayNumber"; -} else { - $ENV{DISPLAY}= "$host:$displayNumber"; -} -$ENV{VNCDESKTOP}= $desktopName; +open STDOUT, "> $desktopLog" +open STDERR, ">&STDOUT" -system("$Xsession $session{'Exec'} >> " . "edString($desktopLog) . " 2>&1"); +exec(@cmd); -exit; +die "Failed to start session.\n"; ############################################################################### # Functions @@ -473,35 +439,6 @@ sub CheckDisplayNumber return 1; } -# -# quotedString returns a string which yields the original string when parsed -# by a shell. -# - -sub quotedString -{ - local ($in) = @_; - - $in =~ s/\'/\'\"\'\"\'/g; - - return "'$in'"; -} - - -# -# removeSlashes turns slashes into underscores for use as a file name. -# - -sub removeSlashes -{ - local ($in) = @_; - - $in =~ s|/|_|g; - - return "$in"; -} - - # # Usage # @@ -525,7 +462,7 @@ sub SanityCheck # cmd: - foreach $cmd ("uname","xauth") { + foreach $cmd ("uname","xauth","xinit") { for (split(/:/,$ENV{PATH})) { if (-x "$_/$cmd") { next cmd; diff --git a/unix/vncserver/vncserver.man b/unix/vncserver/vncserver.man index 17c16b92..8398ed04 100644 --- a/unix/vncserver/vncserver.man +++ b/unix/vncserver/vncserver.man @@ -66,11 +66,6 @@ The VNC password file. .TP $HOME/.vnc/\fIhost\fP:\fIdisplay#\fP.log The log file for Xvnc and the session. -.TP -$HOME/.vnc/\fIhost\fP:\fIdisplay#\fP.pid -Identifies the Xvnc process ID, used by the -.B \-kill -option. .SH SEE ALSO .BR vncviewer (1),