From 1f12f73a2aacd2c259c592df4737d23a07da53fc Mon Sep 17 00:00:00 2001
From: Brian Read
Date: Tue, 20 May 2025 11:34:43 +0100
Subject: [PATCH] * Mon May 19 2025 Brian Read
11.0.0-1.sme - Add in SM2 panels
---
.../Controller/Remoteuseraccess-Custom.pm | 93 ++++++++++++-------
.../templates/partials/_rua_PARAMS.html.ep | 4 +-
2 files changed, 59 insertions(+), 38 deletions(-)
diff --git a/root/usr/share/smanager/lib/SrvMngr/Controller/Remoteuseraccess-Custom.pm b/root/usr/share/smanager/lib/SrvMngr/Controller/Remoteuseraccess-Custom.pm
index faec316..52bfc36 100644
--- a/root/usr/share/smanager/lib/SrvMngr/Controller/Remoteuseraccess-Custom.pm
+++ b/root/usr/share/smanager/lib/SrvMngr/Controller/Remoteuseraccess-Custom.pm
@@ -20,9 +20,9 @@ use constant TRUE => 1;
#The most common ones
my $cdb;
my $adb;
-#my $ndb
-#my $hdb
-#my $ddb
+#my $ndb;
+#my $hdb;
+#my $ddb;
# Validation routines - parameters for each panel
@@ -42,22 +42,24 @@ my $adb;
# Validation for each field
my $ret = "";
- if (! TRUE) #validate $c->param('Account')
- {$ret .= 'Validation for Account failed';}
- if (! TRUE) #validate $c->param('User_Name')
- {$ret .= 'Validation for User_Name failed';}
- if (! TRUE) #validate $c->param('Shell')
- {$ret .= 'Validation for Shell failed';}
- if (! TRUE) #validate $c->param('Sudoer')
- {$ret .= 'Validation for Sudoer failed';}
- if (! TRUE) #validate $c->param('VPNClientAccess')
- {$ret .= 'Validation for VPNClientAccess failed';}
- if (! TRUE) #validate $c->param('ChrootDir2')
- {$ret .= 'Validation for ChrootDir2 failed';}
- if (! TRUE) #validate $c->param('ChrootDir')
- {$ret .= 'Validation for ChrootDir failed';}
- if (! TRUE) #validate $c->param('sshKeys')
- {$ret .= 'Validation for sshKeys failed';}
+ #if (! TRUE) #validate $c->param('Account')
+ #{$ret .= 'Validation for Account failed';}
+ #if (! TRUE) #validate $c->param('User_Name')
+ #{$ret .= 'Validation for User_Name failed';}
+ #if (! TRUE) #validate $c->param('Shell')
+ #{$ret .= 'Validation for Shell failed';}
+ #if (! TRUE) #validate $c->param('Sudoer')
+ #{$ret .= 'Validation for Sudoer failed';}
+ #if (! TRUE) #validate $c->param('VPNClientAccess')
+ #{$ret .= 'Validation for VPNClientAccess failed';}
+ #if (! TRUE) #validate $c->param('ChrootDir2')
+ #{$ret .= 'Validation for ChrootDir2 failed';}
+ #if (! TRUE) #validate $c->param('ChrootDir')
+ #{$ret .= 'Validation for ChrootDir failed';}
+ #if (! TRUE) #validate $c->param('sshKeys')
+ #{$ret .= 'Validation for sshKeys failed';}
+ #just check chroot in place
+ $ret = $c->CheckChrootDirExists();
if ($ret eq "") {$ret = 'ok';}
return $ret;
}
@@ -81,7 +83,8 @@ my $adb;
my $c = shift;
my $user = $c->param('Selected');
$adb = esmith::AccountsDB->open();
- $userrec = $adb->get_record($user) || return {};
+ #die("$user");
+ $userrec = $adb->get($user) || return ('Account' => "$user not found");
my %ret = (
# fields from Inputs in PARAMS $fields['PARAMS']
@@ -105,11 +108,11 @@ my $adb;
# Define a constant hash for field name mapping
use constant getAllUsers_FIELD_MAPPING => (
'Account' => 'User',
- 'User_Name' => 'Full_Name',
- 'Shell_Access' => 'Shell',
+ 'User_Name' => 'User_Name',
+ 'Shell_Access' => 'shell',
'Sudo' => 'Sudoer',
- 'SSH_Keys' => 'Keys',
- 'Chroot_Path' => 'Chroot',
+ 'SSH_Keys' => 'SSH_Keys',
+ 'Chroot_Path' => 'Chroot_Path',
'RSSH_+_VPN_Access' => 'VPNClientAccess',
'Modify' => 'Modify'
#'target_field2' => 'source_field2',
@@ -149,15 +152,14 @@ sub actual_getAllUsers {
push @data,
{ User => $user->key,
- FullName => $user->prop('FirstName') . " " .
- $user->prop('LastName'),
+ User_Name => $user->prop('FirstName') . " " .$user->prop('LastName'),
Sudoer => $user->prop('Sudoer') || 'no',
VPNClientAccess => $user->prop('VPNClientAccess') || 'no',
shell => $shell,
- chroot => $ChrootDir,
+ Chroot_Path => $ChrootDir,
ChrootDir => $user->prop('ChrootDir') || "/home/e-smith/files/users/$username/home",
sudo => $c->l($sudo),
- keys => $c->l($keys),
+ SSH_Keys => $c->l($keys),
vpn => $c->l($vpn),
Modify => "".$c->l('MODIFY')."",
}
@@ -267,13 +269,6 @@ sub get_full_name {
$adb->get_prop($user, "LastName");
}
-sub get_chroot_options {
- my $c = shift;
- my $user = $c->params('Selected');
- return [ [] ];
-}
-
-
sub get_ssh_keys{
my $c = shift;
@@ -336,7 +331,7 @@ sub userpanel_change_settings
$user = $1;
}
- my $sshKeys = $c->param ('sshKeys');
+ my $sshKeys = $c->param ('ssh_keys');
if ($sshKeys ne '')
{
my $file = "/home/e-smith/files/users/$user/.ssh/authorized_keys2";
@@ -397,5 +392,31 @@ sub userpanel_change_settings
return 'ok'; #$self->success("SUCCESS");
}
+sub CheckChrootDirExists
+{
+ my $c = shift;
+
+ my $ChrootDir = $c->param ('ChrootDir') || '';
+ my $ChrootDir2 = $c->param ('ChrootDir2') || '';
+
+ if ($ChrootDir2 eq '')
+ {
+ if ($ChrootDir eq '')
+ {
+ return "CHROOT_PATH_NOT_GIVEN";
+ }
+ else
+ {
+ if ((-e $ChrootDir ) || ($ChrootDir eq 'home'))
+ { return "OK"; }
+ else
+ { return "CHROOT_PATH_NON_EXISTANT"; }
+ }
+ }
+ else
+ { return "ok"; }
+}
+
+
1;
\ No newline at end of file
diff --git a/root/usr/share/smanager/themes/default/templates/partials/_rua_PARAMS.html.ep b/root/usr/share/smanager/themes/default/templates/partials/_rua_PARAMS.html.ep
index bf206bf..25e3536 100644
--- a/root/usr/share/smanager/themes/default/templates/partials/_rua_PARAMS.html.ep
+++ b/root/usr/share/smanager/themes/default/templates/partials/_rua_PARAMS.html.ep
@@ -50,14 +50,14 @@
%=l('rua_Account')
% param 'Account' => $rua_data->{Account} unless param 'Account';
- %= text_field 'Account', size => '50', class => 'textinput Account' , pattern=>'.*' , placeholder=>'Account', title =>'Pattern regex mismatch', id => 'Account_text'
+ %= text_field 'Account', size => '50', class => 'textinput Account' , pattern=>'.*' , placeholder=>'Account', title =>'Pattern regex mismatch', id => 'Account_text', readonly => 1
%=l('rua_User_Name')
% param 'User_Name' => $rua_data->{User_Name} unless param 'User_Name';
- %= text_field 'User_Name', size => '50', class => 'textinput User_Name' , pattern=>'.*' , placeholder=>'User_Name', title =>'Pattern regex mismatch', id => 'User_Name_text'
+ %= text_field 'User_Name', size => '50', class => 'textinput User_Name' , pattern=>'.*' , placeholder=>'User_Name', title =>'Pattern regex mismatch', id => 'User_Name_text', readonly => 1