diff --git a/unix/vncserver b/unix/vncserver index 41ec69d..7cde166 100755 --- a/unix/vncserver +++ b/unix/vncserver @@ -97,9 +97,10 @@ $kasmAuthEnabled = 1; $kasmPasswdFile = "$ENV{HOME}/.kasmpasswd"; @kasmPasswdUsers = &LoadKasmPasswdUsers(); -if ($kasmAuthEnabled) { - &TellUserToSetupUserAndPassword(); +if ($kasmAuthEnabled && !&AtLeastOneUserConfigured()) { + &GuideUserToSetupKasmPasswdUser(); } +@kasmPasswdUsers = &LoadKasmPasswdUsers(); $desktopLog = "$vncUserDir/$host:$displayNumber.log"; unlink($desktopLog); @@ -854,6 +855,34 @@ sub TellUserToSetupUserAndPassword { } } +sub GuideUserToSetupKasmPasswdUser { + my $defaultUser = $ENV{USER}; + print(<<"NEEDTOCREATEUSER"); +In order to access your desktop, at least one KasmVNC user must be setup. +Let's create a user. + +NEEDTOCREATEUSER + + my $username = &Prompt("Enter username (default: $defaultUser): "); + $username ||= $defaultUser; + + system($exedir."kasmvncpasswd -u \"$username\" -w $kasmPasswdFile"); + if ($?) { + die("\nFailed to setup user \"$username\"\n"); + } + print("Created user \"$username\"\n"); +} + +sub Prompt { + my $prompt = shift; + + print($prompt); + my $userInput = ; + $userInput =~ s/^\s+|\s+$//g; + + return $userInput; +} + sub AtLeastOneUserConfigured { scalar @kasmPasswdUsers > 0; }