|
|
|
@ -96,42 +96,13 @@ my %config;
|
|
|
|
|
$kasmAuthEnabled = 1;
|
|
|
|
|
|
|
|
|
|
if ($kasmAuthEnabled) {
|
|
|
|
|
if (!(-e "$ENV{HOME}/.kasmpasswd")) {
|
|
|
|
|
warn "\nYou will require a password to access your desktops.\n\n";
|
|
|
|
|
system($exedir."kasmvncpasswd $ENV{HOME}/.kasmpasswd");
|
|
|
|
|
if (($? >> 8) != 0) {
|
|
|
|
|
exit 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
&TellUserToSetupUserAndPassword();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$desktopLog = "$vncUserDir/$host:$displayNumber.log";
|
|
|
|
|
unlink($desktopLog);
|
|
|
|
|
|
|
|
|
|
# Make an X server cookie and set up the Xauthority file
|
|
|
|
|
# mcookie is a part of util-linux, usually only GNU/Linux systems have it.
|
|
|
|
|
$cookie = `mcookie`;
|
|
|
|
|
# Fallback for non GNU/Linux OS - use /dev/urandom on systems that have it,
|
|
|
|
|
# otherwise use perl's random number generator, seeded with the sum
|
|
|
|
|
# of the current time, our PID and part of the encrypted form of the password.
|
|
|
|
|
if ($cookie eq "" && open(URANDOM, '<', '/dev/urandom')) {
|
|
|
|
|
my $randata;
|
|
|
|
|
if (sysread(URANDOM, $randata, 16) == 16) {
|
|
|
|
|
$cookie = unpack 'h*', $randata;
|
|
|
|
|
}
|
|
|
|
|
close(URANDOM);
|
|
|
|
|
}
|
|
|
|
|
if ($cookie eq "") {
|
|
|
|
|
srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
|
|
|
|
|
for (1..16) {
|
|
|
|
|
$cookie .= sprintf("%02x", int(rand(256)) % 256);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
open(XAUTH, "|xauth -f $xauthorityFile source -");
|
|
|
|
|
print XAUTH "add $host:$displayNumber . $cookie\n";
|
|
|
|
|
print XAUTH "add $host/unix:$displayNumber . $cookie\n";
|
|
|
|
|
close(XAUTH);
|
|
|
|
|
&SetupXauthorityFile();
|
|
|
|
|
|
|
|
|
|
# Now start the X VNC Server
|
|
|
|
|
|
|
|
|
@ -919,3 +890,46 @@ sub DisableVncAuth() {
|
|
|
|
|
# Disable vnc auth, kasmvnc uses https basic auth
|
|
|
|
|
system("echo 'WrLNwLrcrxM=' | base64 -d > $vncUserDir/passwd");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub TellUserToSetupUserAndPassword {
|
|
|
|
|
if (!(-e "$ENV{HOME}/.kasmpasswd")) {
|
|
|
|
|
warn "\nYou will require a password to access your desktops.\n\n";
|
|
|
|
|
system($exedir."kasmvncpasswd $ENV{HOME}/.kasmpasswd");
|
|
|
|
|
if (($? >> 8) != 0) {
|
|
|
|
|
exit 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub MakeXCookie {
|
|
|
|
|
# Make an X server cookie and set up the Xauthority file
|
|
|
|
|
# mcookie is a part of util-linux, usually only GNU/Linux systems have it.
|
|
|
|
|
my $cookie = `mcookie`;
|
|
|
|
|
# Fallback for non GNU/Linux OS - use /dev/urandom on systems that have it,
|
|
|
|
|
# otherwise use perl's random number generator, seeded with the sum
|
|
|
|
|
# of the current time, our PID and part of the encrypted form of the password.
|
|
|
|
|
if ($cookie eq "" && open(URANDOM, '<', '/dev/urandom')) {
|
|
|
|
|
my $randata;
|
|
|
|
|
if (sysread(URANDOM, $randata, 16) == 16) {
|
|
|
|
|
$cookie = unpack 'h*', $randata;
|
|
|
|
|
}
|
|
|
|
|
close(URANDOM);
|
|
|
|
|
}
|
|
|
|
|
if ($cookie eq "") {
|
|
|
|
|
srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
|
|
|
|
|
for (1..16) {
|
|
|
|
|
$cookie .= sprintf("%02x", int(rand(256)) % 256);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $cookie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub SetupXauthorityFile {
|
|
|
|
|
my $cookie = &MakeXCookie();
|
|
|
|
|
|
|
|
|
|
open(XAUTH, "|xauth -f $xauthorityFile source -");
|
|
|
|
|
print XAUTH "add $host:$displayNumber . $cookie\n";
|
|
|
|
|
print XAUTH "add $host/unix:$displayNumber . $cookie\n";
|
|
|
|
|
close(XAUTH);
|
|
|
|
|
}
|
|
|
|
|