mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-24 09:03:30 +01:00
vncserver: guide user to create a KasmVNC user
This commit is contained in:
parent
fa342f624f
commit
93d2c6c716
@ -97,9 +97,10 @@ $kasmAuthEnabled = 1;
|
|||||||
$kasmPasswdFile = "$ENV{HOME}/.kasmpasswd";
|
$kasmPasswdFile = "$ENV{HOME}/.kasmpasswd";
|
||||||
@kasmPasswdUsers = &LoadKasmPasswdUsers();
|
@kasmPasswdUsers = &LoadKasmPasswdUsers();
|
||||||
|
|
||||||
if ($kasmAuthEnabled) {
|
if ($kasmAuthEnabled && !&AtLeastOneUserConfigured()) {
|
||||||
&TellUserToSetupUserAndPassword();
|
&GuideUserToSetupKasmPasswdUser();
|
||||||
}
|
}
|
||||||
|
@kasmPasswdUsers = &LoadKasmPasswdUsers();
|
||||||
|
|
||||||
$desktopLog = "$vncUserDir/$host:$displayNumber.log";
|
$desktopLog = "$vncUserDir/$host:$displayNumber.log";
|
||||||
unlink($desktopLog);
|
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 = <STDIN>;
|
||||||
|
$userInput =~ s/^\s+|\s+$//g;
|
||||||
|
|
||||||
|
return $userInput;
|
||||||
|
}
|
||||||
|
|
||||||
sub AtLeastOneUserConfigured {
|
sub AtLeastOneUserConfigured {
|
||||||
scalar @kasmPasswdUsers > 0;
|
scalar @kasmPasswdUsers > 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user