update to remoteuseracces, declare DB handles in Custom

This commit is contained in:
Brian Read 2025-05-19 13:03:05 +01:00
parent 386e602958
commit f785f16234
2 changed files with 52 additions and 10 deletions

View File

@ -18,8 +18,8 @@ use constant TRUE => 1;
#The most common ones
#my $cdb
#my $adb
my $cdb
my $adb
#my $ndb
#my $hdb
#my $ddb
@ -114,9 +114,51 @@ use constant TRUE => 1;
);
sub actual_getAllUsers {
my @ret = ();
my $c = shift;
# Actual code for extracting getAllUsers
return @ret;
$cdb = esmith::ConfigDB->open();
$adb = esmith::AccountsDB->open();
my @data = ();
my @users = $adb->users;
return $c->l("ACCOUNT_USER_NONE") if (@users == 0);
for my $user (@users)
{
my $username = $user->key;
# make clearer by only showing yes and localise
my $vpn = $user->prop('VPNClientAccess') || '';
if ($vpn eq 'yes') { $vpn = 'YES'; } else { $vpn = ''; }
my $sudo = $user->prop('Sudoer') || '';
if ($sudo eq 'yes') { $sudo = 'YES'; } else { $sudo = ''; }
my $keys = '';
my $file = "/home/e-smith/files/users/$username/.ssh/authorized_keys2";
if (( -e $file ) && (! -z $file ))
{ $keys = 'YES'; }
my $shell = $user->prop('Shell') || '';
if ($shell eq '/usr/bin/rssh') { $shell = ''; }
my $ChrootDir = $user->prop('ChrootDir') || "";
$ChrootDir =~ s:/home/e-smith/files/ibays/::;
$ChrootDir =~ s:/home/e-smith/files/users/$username/home:home:;
push @data,
{ User => $user->key,
FullName => $user->prop('FirstName') . " " .
$user->prop('LastName'),
Sudoer => $user->prop('Sudoer') || 'no',
VPNClientAccess => $user->prop('VPNClientAccess') || 'no',
shell => $shell,
chroot => $ChrootDir,
ChrootDir => $user->prop('ChrootDir') || "/home/e-smith/files/users/$username/home",
sudo => $c->l($sudo),
keys => $c->l($keys),
vpn => $c->l($vpn),
Modify => $c->l('MODIFY'),
}
}
return @data;
}
sub get_getAllUsers {

View File

@ -17,12 +17,12 @@ use constant FALSE => 0;
use constant TRUE => 1;
#The most common ones
#my $cdb
#my $adb
#my $ndb
#my $hdb
#my $ddb
#The most common ones - open DB when required.
my $cdb;
my $adb;
my $ndb;
my $hdb;
my $ddb;
# Validation routines - parameters for each panel
<tal:block tal:repeat="panel panels">