mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2024-11-24 00:53:39 +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";
|
||||
@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 = <STDIN>;
|
||||
$userInput =~ s/^\s+|\s+$//g;
|
||||
|
||||
return $userInput;
|
||||
}
|
||||
|
||||
sub AtLeastOneUserConfigured {
|
||||
scalar @kasmPasswdUsers > 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user