* Mon Jun 09 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-87.sme

- add datetime getYear_list [SME: 13031]
- use esmith::*DB::UTF8 to access db flat files [SME: 13027]
This commit is contained in:
Jean-Philippe Pialasse 2025-06-09 23:49:25 -04:00
parent fd076895ba
commit c85022c49e
30 changed files with 202 additions and 198 deletions

View File

@ -4,6 +4,7 @@ package SrvMngr;
use strict; use strict;
use warnings; use warnings;
use utf8; use utf8;
binmode(STDOUT);
use Mojo::Base 'Mojolicious'; use Mojo::Base 'Mojolicious';
@ -29,6 +30,8 @@ use SrvMngr::Model::Main;
use SrvMngr::Plugin::WithoutCache; use SrvMngr::Plugin::WithoutCache;
use esmith::I18N; use esmith::I18N;
use esmith::ConfigDB::UTF8;
use esmith::NavigationDB; # no UTF8 raw is ok for ASCII only flat file
# Import the function(s) you need # Import the function(s) you need
use SrvMngr_Auth qw(check_admin_access); use SrvMngr_Auth qw(check_admin_access);
@ -550,9 +553,6 @@ sub theme_list {
#------------------------------------------------------------ #------------------------------------------------------------
sub getNavigation { sub getNavigation {
use esmith::NavigationDB;
my $class = shift; #not the controller as it is called as an external, not part of the controller. my $class = shift; #not the controller as it is called as an external, not part of the controller.
my $lang = shift || 'en-us'; my $lang = shift || 'en-us';
my $menu = shift || 'N'; my $menu = shift || 'N';
@ -573,7 +573,7 @@ sub getNavigation {
# Added: Check if user is non-admin and get their allowed panels # Added: Check if user is non-admin and get their allowed panels
if ($username ne '') { if ($username ne '') {
# Get the AccountsDB to check user permissions # Get the AccountsDB to check user permissions
my $accountsdb = esmith::AccountsDB->open_ro() or my $accountsdb = esmith::AccountsDB::UTF8->open_ro() or
die "Couldn't open AccountsDB\n"; die "Couldn't open AccountsDB\n";
# Check if user has AdminPanels property # Check if user has AdminPanels property
@ -646,8 +646,7 @@ sub getNavigation {
my $navinfo = NAVIGATIONDIR . "/navigation.$lang"; my $navinfo = NAVIGATIONDIR . "/navigation.$lang";
my $navdb = esmith::NavigationDB->open_ro( $navinfo ) or my $navdb = esmith::NavigationDB->open_ro( $navinfo ) or die "Couldn't open $navinfo\n"; # no UTF8
die "Couldn't open $navinfo\n";
# Check the navdb for anything with a UrlPath, which means that it doesn't # Check the navdb for anything with a UrlPath, which means that it doesn't
# have a cgi file to be picked up by the above code. Ideally, only pages # have a cgi file to be picked up by the above code. Ideally, only pages
@ -814,7 +813,7 @@ sub get_routes_list {
my $c = shift; my $c = shift;
my $rtdb = esmith::ConfigDB->open_ro('routes') || die 'Cannot open Routes db'; my $rtdb = esmith::ConfigDB::UTF8->open_ro('routes') || die 'Cannot open Routes db';
my @routes = $rtdb->get_all(); my @routes = $rtdb->get_all();
my @rt; my @rt;
@ -896,7 +895,7 @@ sub gen_locale_date_string
sub get_public_ip_address sub get_public_ip_address
{ {
my $self = shift; my $self = shift;
my $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; my $cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
my $sysconfig = $cdb->get('sysconfig'); my $sysconfig = $cdb->get('sysconfig');
if ($sysconfig) if ($sysconfig)
{ {

View File

@ -27,7 +27,7 @@ use File::Basename;
use File::Find; use File::Find;
use File::Path qw(make_path remove_tree); use File::Path qw(make_path remove_tree);
use esmith::Backup; use esmith::Backup;
use esmith::BackupHistoryDB; use esmith::BackupHistoryDB; #no UTF8 and not in use
use esmith::util; use esmith::util;
use esmith::lockfile; use esmith::lockfile;
use esmith::BlockDevices; use esmith::BlockDevices;

View File

@ -13,9 +13,9 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::ConfigDB::UTF8;
#package esmith::FormMagick::Panel::clamav; our $db;
our $db = esmith::ConfigDB->open() || die "Couldn't open config db";
sub main { sub main {
my $c = shift; my $c = shift;
@ -23,6 +23,7 @@ sub main {
my %clm_datas = (); my %clm_datas = ();
my $title = $c->l('clm_FORM_TITLE'); my $title = $c->l('clm_FORM_TITLE');
my $modul = $c->render_to_string(inline => $c->l('clm_DESC_FILESYSTEM_SCAN_PERIOD')); my $modul = $c->render_to_string(inline => $c->l('clm_DESC_FILESYSTEM_SCAN_PERIOD'));
$db = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
$clm_datas{'FilesystemScan'} = ($db->get_prop('clamav', 'FilesystemScan')) || 'disabled'; $clm_datas{'FilesystemScan'} = ($db->get_prop('clamav', 'FilesystemScan')) || 'disabled';
$clm_datas{'Quarantine'} = ($db->get_prop('clamav', 'Quarantine')) || 'disabled'; $clm_datas{'Quarantine'} = ($db->get_prop('clamav', 'Quarantine')) || 'disabled';
$clm_datas{'clam_versions'} = get_clam_versions(); $clm_datas{'clam_versions'} = get_clam_versions();
@ -53,6 +54,7 @@ sub do_update {
sub change_settings { sub change_settings {
my $c = shift; my $c = shift;
$db = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
my $status = $c->param('status'); my $status = $c->param('status');
my $FilesystemScan = ($c->param('FilesystemScan') || 'disabled'); my $FilesystemScan = ($c->param('FilesystemScan') || 'disabled');
my $Quarantine = ($c->param('Quarantine') || 'disabled'); my $Quarantine = ($c->param('Quarantine') || 'disabled');

View File

@ -14,7 +14,8 @@ use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::util; use esmith::util;
use SrvMngr qw( gen_locale_date_string ); use SrvMngr qw( gen_locale_date_string );
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; use esmith::ConfigDB::UTF8;
our $cdb ;
sub main { sub main {
my $c = shift; my $c = shift;
@ -23,6 +24,7 @@ sub main {
my $title = $c->l('dat_FORM_TITLE'); my $title = $c->l('dat_FORM_TITLE');
my $modul = $c->l('dat_INITIAL_DESC'); my $modul = $c->l('dat_INITIAL_DESC');
$dat_datas{ntpstatus} = 'disabled'; $dat_datas{ntpstatus} = 'disabled';
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
my $rec = $cdb->get('ntpd'); my $rec = $cdb->get('ntpd');
if ($rec) { if ($rec) {
@ -54,6 +56,7 @@ sub do_update {
my $result; my $result;
my $success; my $success;
my $old_ntpstatus = $c->param('Old_ntpstatus'); my $old_ntpstatus = $c->param('Old_ntpstatus');
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
$dat_datas{ntpstatus} = $c->param('Ntpstatus'); $dat_datas{ntpstatus} = $c->param('Ntpstatus');
if ($dat_datas{ntpstatus} ne $old_ntpstatus) { if ($dat_datas{ntpstatus} ne $old_ntpstatus) {
@ -125,6 +128,7 @@ sub do_update {
sub validate_change_datetime { sub validate_change_datetime {
my $c = shift; my $c = shift;
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
#-------------------------------------------------- #--------------------------------------------------
# Untaint parameters and check for validity # Untaint parameters and check for validity
@ -220,15 +224,14 @@ sub validate_change_datetime {
#-------------------------------------------------- #--------------------------------------------------
# Store time zone in configuration database # Store time zone in configuration database
#-------------------------------------------------- #--------------------------------------------------
my $conf = esmith::ConfigDB->open(); my $old = $cdb->get('UnsavedChanges')->value;
my $old = $conf->get('UnsavedChanges')->value; my $rec = $cdb->get('TimeZone');
my $rec = $conf->get('TimeZone');
unless ($rec) { unless ($rec) {
$rec = $conf->new_record('TimeZone', undef); $rec = $cdb->new_record('TimeZone', undef);
} }
$rec->set_value($timezone); $rec->set_value($timezone);
$conf->get('UnsavedChanges')->set_value($old); $cdb->get('UnsavedChanges')->set_value($old);
#-------------------------------------------------- #--------------------------------------------------
# Signal event to change time zone, system time # Signal event to change time zone, system time

View File

@ -13,6 +13,7 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use esmith::ConfigDB::UTF8; use esmith::ConfigDB::UTF8;
use esmith::AccountsDB::UTF8;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
our $db; our $db;
@ -54,7 +55,7 @@ sub do_update {
$db->get('ldap')->set_prop('defaultPhoneNumber', $phonenumber); $db->get('ldap')->set_prop('defaultPhoneNumber', $phonenumber);
if ($existing eq 'update') { if ($existing eq 'update') {
my $ac = esmith::AccountsDB->open() || die "Couldn't open accounts db"; my $ac = esmith::AccountsDB::UTF8->open() || die "Couldn't open accounts db";
my @users = $ac->users(); my @users = $ac->users();
foreach my $user (@users) { foreach my $user (@users) {

View File

@ -13,16 +13,10 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::DomainsDB::UTF8;
use esmith::AccountsDB::UTF8;
#use Data::Dumper; our ($ddb,$cdb,$adb);
#use esmith::FormMagick::Panel::domains;
use esmith::DomainsDB;
use esmith::AccountsDB;
#use URI::Escape;
my ($ddb,$cdb,$adb);
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
our $REGEXP_DOMAIN = qq([a-zA-Z0-9\-\.]+); our $REGEXP_DOMAIN = qq([a-zA-Z0-9\-\.]+);
sub main { sub main {
@ -30,9 +24,9 @@ sub main {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %dom_datas = (); my %dom_datas = ();
my $title = $c->l('dom_FORM_TITLE'); my $title = $c->l('dom_FORM_TITLE');
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db"; $ddb = esmith::DomainsDB::UTF8->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$dom_datas{trt} = 'LST'; $dom_datas{trt} = 'LST';
my @domains; my @domains;
@ -57,9 +51,9 @@ sub do_display {
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = $c->param('trt'); my $trt = $c->param('trt');
my $domain = $c->param('Domain') || ''; my $domain = $c->param('Domain') || '';
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db"; $ddb = esmith::DomainsDB::UTF8->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
#$trt = 'DEL' if ( $rt eq 'domaindel1' ); #$trt = 'DEL' if ( $rt eq 'domaindel1' );
#$trt = 'UPD' if ( $rt eq 'domainupd1' ); #$trt = 'UPD' if ( $rt eq 'domainupd1' );
@ -127,9 +121,9 @@ sub do_update {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = $c->param('trt'); my $trt = $c->param('trt');
$ddb = esmith::DomainsDB->open || die "Couldn't open domains db"; $ddb = esmith::DomainsDB::UTF8->open || die "Couldn't open domains db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
my %dom_datas = (); my %dom_datas = ();
my ($res, $result) = ''; my ($res, $result) = '';
@ -246,6 +240,7 @@ sub create_modify_domain {
. ' Ctl' . ' Ctl'
); );
} ## end unless ($domain) } ## end unless ($domain)
$ddb = esmith::DomainsDB::UTF8->open || die "Couldn't open domains db";
my $rec = $ddb->get($domain); my $rec = $ddb->get($domain);
if ($rec and $action eq 'create') { if ($rec and $action eq 'create') {
@ -375,6 +370,7 @@ sub nameserver_options_list {
sub get_nameserver_value { sub get_nameserver_value {
my $c = shift; my $c = shift;
$ddb = esmith::DomainsDB::UTF8->open || die "Couldn't open domains db";
my $domain = $c->param('Domain') || undef; my $domain = $c->param('Domain') || undef;
return ($ddb->get_prop($domain, 'Nameservers') || 'internet'); return ($ddb->get_prop($domain, 'Nameservers') || 'internet');
} ## end sub get_nameserver_value } ## end sub get_nameserver_value

View File

@ -16,16 +16,18 @@ use constant TRUE => 1;
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session ip_number_or_blank); use SrvMngr qw(theme_list init_session ip_number_or_blank);
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use esmith::util; use esmith::util;
use File::Basename; use File::Basename;
our $pattern_db = esmith::ConfigDB->open("mailpatterns"); our $pattern_db;
our $cdb = esmith::ConfigDB->open || die "Couldn't open config db"; our $cdb;
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
$pattern_db = esmith::ConfigDB::UTF8->open("mailpatterns");
$cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my %mai_datas = (); my %mai_datas = ();
my $title = $c->l('mai_FORM_TITLE'); my $title = $c->l('mai_FORM_TITLE');
$mai_datas{'trt'} = 'LIST'; $mai_datas{'trt'} = 'LIST';
@ -42,7 +44,7 @@ sub do_display {
my $title = $c->l('mai_FORM_TITLE'); my $title = $c->l('mai_FORM_TITLE');
my ($notif, $dest) = ''; my ($notif, $dest) = '';
$mai_datas{'trt'} = $trt; $mai_datas{'trt'} = $trt;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
if ($trt eq 'ACC') { if ($trt eq 'ACC') {
$dest = 'emailaccess'; $dest = 'emailaccess';
@ -94,7 +96,7 @@ sub do_update {
my $trt = $c->param('trt'); my $trt = $c->param('trt');
my %mai_datas = (); my %mai_datas = ();
$mai_datas{trt} = $trt; $mai_datas{trt} = $trt;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my $title = $c->l('mai_FORM_TITLE'); my $title = $c->l('mai_FORM_TITLE');
my ($dest, $res, $result) = ''; my ($dest, $res, $result) = '';
@ -231,7 +233,7 @@ sub get_patterns_status {
sub adjust_patterns { sub adjust_patterns {
my $c = shift; my $c = shift;
my @selected = @{ $c->every_param('BlockExecutableContent') }; my @selected = @{ $c->every_param('BlockExecutableContent') };
$pattern_db = esmith::ConfigDB::UTF8->open("mailpatterns");
foreach my $pattern ($pattern_db->get_all_by_prop(type => "pattern")) { foreach my $pattern ($pattern_db->get_all_by_prop(type => "pattern")) {
my $status my $status
= (grep $pattern->key eq $_, @selected) = (grep $pattern->key eq $_, @selected)
@ -284,7 +286,7 @@ sub get_current_imap_access {
sub get_current_smtp_ssl_auth { sub get_current_smtp_ssl_auth {
my ($c, $localise, $soru, $debug) = @_; my ($c, $localise, $soru, $debug) = @_;
die "Error: \$soru must be either 's' or 'u':$soru.\n" unless $soru eq 's' || $soru eq 'u'; die "Error: \$soru must be either 's' or 'u':$soru.\n" unless $soru eq 's' || $soru eq 'u';
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
# Initialize variables with default values # Initialize variables with default values
my $smtpStatus = 'none'; my $smtpStatus = 'none';
@ -485,7 +487,7 @@ sub get_retrieval_opt {
sub get_emailunknownuser_options { sub get_emailunknownuser_options {
my $c = shift; my $c = shift;
my $accounts = esmith::AccountsDB->open_ro(); my $accounts = esmith::AccountsDB::UTF8->open_ro();
my %existingAccounts = ( my %existingAccounts = (
'admin' => $c->l("mai_FORWARD_TO_ADMIN"), 'admin' => $c->l("mai_FORWARD_TO_ADMIN"),
'returntosender' => $c->l("mai_RETURN_TO_SENDER") 'returntosender' => $c->l("mai_RETURN_TO_SENDER")
@ -503,7 +505,7 @@ sub get_emailunknownuser_options {
sub get_emailunknownuser_opt { sub get_emailunknownuser_opt {
my $c = shift; my $c = shift;
my $accounts = esmith::AccountsDB->open_ro(); my $accounts = esmith::AccountsDB::UTF8->open_ro();
my @existingAccounts my @existingAccounts
= ([ $c->l("mai_FORWARD_TO_ADMIN") => 'admin' ], [ $c->l("mai_RETURN_TO_SENDER") => 'returntosender' ]); = ([ $c->l("mai_FORWARD_TO_ADMIN") => 'admin' ], [ $c->l("mai_RETURN_TO_SENDER") => 'returntosender' ]);
@ -580,14 +582,13 @@ sub display_multidrop {
sub change_settings_reception { sub change_settings_reception {
my $c = shift; my $c = shift;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDBi::UTF8->open || die "Couldn't open config db";
my $FetchmailMethod = ($c->param('FetchmailMethod') || 'standard'); my $FetchmailMethod = ($c->param('FetchmailMethod') || 'standard');
my $FetchmailFreqOffice = ($c->param('FreqOffice') || 'every15min'); my $FetchmailFreqOffice = ($c->param('FreqOffice') || 'every15min');
my $FetchmailFreqOutside = ($c->param('FreqOutside') || 'everyhour'); my $FetchmailFreqOutside = ($c->param('FreqOutside') || 'everyhour');
my $FetchmailFreqWeekend = ($c->param('FreqWeekend') || 'everyhour'); my $FetchmailFreqWeekend = ($c->param('FreqWeekend') || 'everyhour');
my $SpecifyHeader = ($c->param('SpecifyHeader') || 'off'); my $SpecifyHeader = ($c->param('SpecifyHeader') || 'off');
my $fetchmail my $fetchmail = $cdb->get('fetchmail') || $cdb->new_record("fetchmail", { type => "service", status => "disabled" });
= $cdb->get('fetchmail') || $cdb->new_record("fetchmail", { type => "service", status => "disabled" });
if ($FetchmailMethod eq 'standard') { if ($FetchmailMethod eq 'standard') {
$fetchmail->set_prop('status', 'disabled'); $fetchmail->set_prop('status', 'disabled');
@ -662,7 +663,7 @@ sub change_settings_reception {
sub change_settings_delivery { sub change_settings_delivery {
my ($c) = shift; my ($c) = shift;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my $EmailUnknownUser = ($c->param('EmailUnknownUser') || 'returntosender'); my $EmailUnknownUser = ($c->param('EmailUnknownUser') || 'returntosender');
$cdb->set_value('SMTPSmartHost', $c->param('SMTPSmartHost')); $cdb->set_value('SMTPSmartHost', $c->param('SMTPSmartHost'));
$cdb->set_value('DelegateMailServer', $c->param('DelegateMailServer')); $cdb->set_value('DelegateMailServer', $c->param('DelegateMailServer'));
@ -683,7 +684,7 @@ sub change_settings_delivery {
sub change_settings_access { sub change_settings_access {
my $c = shift; my $c = shift;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my $pop3Access = ($c->param('POPAccess') || 'private'); my $pop3Access = ($c->param('POPAccess') || 'private');
if ($pop3Access eq 'disabled') { if ($pop3Access eq 'disabled') {
@ -757,7 +758,7 @@ sub change_settings_access {
sub change_settings_filtering { sub change_settings_filtering {
my $c = shift; my $c = shift;
$cdb = esmith::ConfigDB->open || die "Couldn't open config db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my $virus_status = ($c->param('VirusStatus') || 'disabled'); my $virus_status = ($c->param('VirusStatus') || 'disabled');
$cdb->set_prop("qpsmtpd", 'VirusScan', $virus_status); $cdb->set_prop("qpsmtpd", 'VirusScan', $virus_status);

View File

@ -14,21 +14,18 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::AccountsDB::UTF8;
use esmith::ConfigDB::UTF8;
#use Data::Dumper; our ($cdb,$adb);
#use esmith::FormMagick::Panel::groups;
use esmith::AccountsDB;
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my ($cdb,$adb);
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %grp_datas = (); my %grp_datas = ();
my $title = $c->l('grp_FORM_TITLE'); my $title = $c->l('grp_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$grp_datas{trt} = 'LST'; $grp_datas{trt} = 'LST';
my @groups; my @groups;
@ -47,8 +44,8 @@ sub do_display {
my $group = $c->param('group'); my $group = $c->param('group');
my %grp_datas = (); my %grp_datas = ();
my $title = $c->l('grp_FORM_TITLE'); my $title = $c->l('grp_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$grp_datas{'trt'} = $trt; $grp_datas{'trt'} = $trt;
if ($trt eq 'ADD') { if ($trt eq 'ADD') {
@ -104,8 +101,8 @@ sub do_update {
my $title = $c->l('grp_FORM_TITLE'); my $title = $c->l('grp_FORM_TITLE');
my ($res, $result) = ''; my ($res, $result) = '';
my %grp_datas = (); my %grp_datas = ();
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$grp_datas{'trt'} = $trt; $grp_datas{'trt'} = $trt;
$grp_datas{'group'} = $groupName; $grp_datas{'group'} = $groupName;
my @members = (); my @members = ();

View File

@ -14,22 +14,14 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
#use Data::Dumper;
#use esmith::FormMagick::Panel::hostentries;
use esmith::DomainsDB;
use esmith::AccountsDB;
use esmith::HostsDB;
use esmith::NetworksDB;
use HTML::Entities; use HTML::Entities;
use Net::IPv4Addr qw(ipv4_in_network); use Net::IPv4Addr qw(ipv4_in_network);
use esmith::DomainsDB::UTF8;
use esmith::ConfigDB::UTF8
use esmith::HostsDB::UTF8;
use esmith::NetworksDB::UTF8;
#use URI::Escape; our ($ddb,$cdb,$hdb,$ndb);
#our $ddb = esmith::DomainsDB->open || die "Couldn't open hostentries db";
#our $cdb = esmith::ConfigDB->open || die "Couldn't open configuration db";
#our $hdb = esmith::HostsDB->open || die "Couldn't open hosts db";
#our $ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
my ($ddb,$cdb,$hdb,$ndb);
sub main { sub main {
my $c = shift; my $c = shift;
@ -37,10 +29,9 @@ sub main {
my %hos_datas = (); my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE'); my $title = $c->l('hos_FORM_TITLE');
my $notif = ''; my $notif = '';
#my $ddb = esmith::DomainsDB->open || die "Couldn't open hostentries db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $hdb = esmith::HostsDB::UTF8->open || die "Couldn't open hosts db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db"; $ndb = esmith::NetworksDB::UTF8->open || die "Couldn't open networks db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db";
$hos_datas{trt} = 'LIST'; $hos_datas{trt} = 'LIST';
my %dom_hosts = (); my %dom_hosts = ();
@ -73,9 +64,9 @@ sub do_display {
$trt = 'LST' if ($trt ne 'DEL' && $trt ne 'UPD' && $trt ne 'ADD'); $trt = 'LST' if ($trt ne 'DEL' && $trt ne 'UPD' && $trt ne 'ADD');
my %hos_datas = (); my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE'); my $title = $c->l('hos_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db"; $hdb = esmith::HostsDB::UTF8->open || die "Couldn't open hosts db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db"; $ndb = esmith::NetworksDB::UTF8->open || die "Couldn't open networks db";
my $notif = ''; my $notif = '';
$hos_datas{'trt'} = $trt; $hos_datas{'trt'} = $trt;
@ -120,9 +111,9 @@ sub do_update {
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
my %hos_datas = (); my %hos_datas = ();
my $title = $c->l('hos_FORM_TITLE'); my $title = $c->l('hos_FORM_TITLE');
$cdb = esmith::ConfigDB->open || die "Couldn't open configuration db"; $cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open configuration db";
$hdb = esmith::HostsDB->open || die "Couldn't open hosts db"; $hdb = esmith::HostsDB::UTF8->open || die "Couldn't open hosts db";
$ndb = esmith::NetworksDB->open || die "Couldn't open networks db"; $ndb = esmith::NetworksDB::UTF8->open || die "Couldn't open networks db";
my $notif = ''; my $notif = '';
my $result = ''; my $result = '';
$hos_datas{'name'} = lc $c->param('Name'); $hos_datas{'name'} = lc $c->param('Name');
@ -379,7 +370,7 @@ sub delete_hostentry {
} ## end sub delete_hostentry } ## end sub delete_hostentry
sub domains_list { sub domains_list {
my $d = esmith::DomainsDB->open_ro() or die "Couldn't open DomainsDB"; $ddb = esmith::DomainsDB::UTF8->open_ro() or die "Couldn't open DomainsDB";
my @domains; my @domains;
for ($d->domains) { for ($d->domains) {
@ -516,7 +507,7 @@ sub must_be_local {
my $localip = shift; my $localip = shift;
# Make sure that the IP is indeed local. # Make sure that the IP is indeed local.
#my $ndb = esmith::NetworksDB->open_ro; #$ndb = esmith::NetworksDB::UTF8->open_ro;
my @local_list = $ndb->local_access_spec; my @local_list = $ndb->local_access_spec;
foreach my $spec (@local_list) { foreach my $spec (@local_list) {

View File

@ -13,13 +13,12 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session subnet_mask get_reg_mask ip_number); use SrvMngr qw(theme_list init_session subnet_mask get_reg_mask ip_number);
#use Data::Dumper;
use esmith::util; use esmith::util;
use esmith::HostsDB; use esmith::HostsDB::UTF8;
#my $network_db = esmith::NetworksDB->open() || die("Couldn't open networks db"); use esmith::NetworksDB::UTF8;
use esmith::ConfigDB::UTF8;
my $ret = "OK"; my $ret = "OK";
my ($network_db); our ($network_db,$config_db);
sub main { sub main {
my $c = shift; my $c = shift;
@ -27,7 +26,7 @@ sub main {
my %ln_datas = (); my %ln_datas = ();
$ln_datas{return} = ""; $ln_datas{return} = "";
my $title = $c->l('ln_LOCAL NETWORKS'); my $title = $c->l('ln_LOCAL NETWORKS');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db"); $network_db = esmith::NetworksDB::UTF8->open() || die("Couldn't open networks db");
my $modul = ''; my $modul = '';
$ln_datas{trt} = 'LIST'; $ln_datas{trt} = 'LIST';
my @localnetworks; my @localnetworks;
@ -49,7 +48,7 @@ sub do_display {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
$network_db = esmith::NetworksDB->open() || die("Couldn't open networks db"); $network_db = esmith::NetworksDB::UTF8->open() || die("Couldn't open networks db");
$trt = 'DEL' if ($rt eq 'localnetworksdel'); $trt = 'DEL' if ($rt eq 'localnetworksdel');
$trt = 'ADD' if ($rt eq 'localnetworksadd'); $trt = 'ADD' if ($rt eq 'localnetworksadd');
$trt = 'ADD1' if ($rt eq 'localnetworksadd1'); $trt = 'ADD1' if ($rt eq 'localnetworksadd1');
@ -77,14 +76,14 @@ sub do_display {
#Error - return to Add page #Error - return to Add page
$trt = "ADD"; $trt = "ADD";
} }
$network_db = esmith::NetworksDB->open() || die("Failed to open Networkdb-3"); #Refresh the network DB #$network_db = esmith::NetworksDB::UTF8->open() || die("Failed to open Networkdb-3"); #Refresh the network DB
$c->stash(ret => \%ret); #stash it away for the template $c->stash(ret => \%ret); #stash it away for the template
} ## end if ($trt eq 'ADD1') } ## end if ($trt eq 'ADD1')
if ($trt eq 'DEL1') { if ($trt eq 'DEL1') {
#After Remove clicked on Delete network panel #After Remove clicked on Delete network panel
$network_db = esmith::NetworksDB->open() || die("Failed to open Networkdb-1"); #$network_db = esmith::NetworksDB::UTF8->open() || die("Failed to open Networkdb-1");
my $localnetwork = $c->param("localnetwork"); my $localnetwork = $c->param("localnetwork");
my $delete_hosts = $c->param("deletehost") || "1"; #default to deleting them. my $delete_hosts = $c->param("deletehost") || "1"; #default to deleting them.
my $rec = $network_db->get($localnetwork) || die("Failed to find network on db:$localnetwork"); my $rec = $network_db->get($localnetwork) || die("Failed to find network on db:$localnetwork");
@ -93,7 +92,7 @@ sub do_display {
$ln_datas{localnetwork} = $localnetwork; $ln_datas{localnetwork} = $localnetwork;
} }
my %ret = remove_network($localnetwork, $delete_hosts); my %ret = remove_network($localnetwork, $delete_hosts);
$network_db = esmith::NetworksDB->open() || die("Failed to open Networkdb-2"); #Refresh the network DB #$network_db = esmith::NetworksDB::UTF8->open() || die("Failed to open Networkdb-2"); #Refresh the network DB
my @localnetworks; my @localnetworks;
if ($network_db) { if ($network_db) {
@ -138,7 +137,7 @@ sub do_display {
sub remove_network { sub remove_network {
my $network = shift; my $network = shift;
$network_db = esmith::NetworksDB->open(); $network_db = esmith::NetworksDB::UTF8->open();
my $record = $network_db->get($network); my $record = $network_db->get($network);
my $delete_hosts = shift; my $delete_hosts = shift;
@ -174,7 +173,7 @@ sub hosts_on_network {
my $netmask = shift; my $netmask = shift;
die if not $network and $netmask; die if not $network and $netmask;
my $cidr = "$network/$netmask"; my $cidr = "$network/$netmask";
my $hosts = esmith::HostsDB->open() || die("Couldn't open hosts db"); my $hosts = esmith::HostsDB::UTF8->open() || die("Couldn't open hosts db");
my @localhosts = grep { $_->prop('HostType') eq 'Local' } $hosts->hosts; my @localhosts = grep { $_->prop('HostType') eq 'Local' } $hosts->hosts;
my @hosts_on_network = (); my @hosts_on_network = ();
@ -207,9 +206,9 @@ sub add_network {
# we transform bit mask to regular mask # we transform bit mask to regular mask
$networkMask = get_reg_mask($networkAddress, $networkMask); $networkMask = get_reg_mask($networkAddress, $networkMask);
my $network_db = esmith::NetworksDB->open() my $network_db = esmith::NetworksDB::UTF8->open()
|| esmith::NetworksDB->create(); || esmith::NetworksDB::UTF8->create();
my $config_db = esmith::ConfigDB->open(); my $config_db = esmith::ConfigDB::UTF8->open();
my $localIP = $config_db->get('LocalIP'); my $localIP = $config_db->get('LocalIP');
my $localNetmask = $config_db->get('LocalNetmask'); my $localNetmask = $config_db->get('LocalNetmask');
my ($localNetwork, $localBroadcast) my ($localNetwork, $localBroadcast)

View File

@ -18,7 +18,7 @@ use strict;
use warnings; use warnings;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr::Model::Main; use SrvMngr::Model::Main;
use SrvMngr qw( theme_list init_session ); use SrvMngr qw( theme_list init_session );
@ -26,7 +26,7 @@ my $MAX_LOGIN_ATTEMPTS = 3;
my $DURATION_BLOCKED = 30 * 60; # access blocked for 30 min my $DURATION_BLOCKED = 30 * 60; # access blocked for 30 min
my $TIMEOUT_FAILED_LOGIN = 1; my $TIMEOUT_FAILED_LOGIN = 1;
my $RESET_DURATION = 2 * 60 * 60; # 2 hours for resetting my $RESET_DURATION = 2 * 60 * 60; # 2 hours for resetting
our $adb = esmith::AccountsDB->open() or die "Couldn't open DB Accounts\n"; our $adb;
my $allowed_user_re = qr/^\w{5,10}$/; my $allowed_user_re = qr/^\w{5,10}$/;
my %Login_Attempts; my %Login_Attempts;
@ -39,6 +39,7 @@ sub main {
sub login { sub login {
my $c = shift; my $c = shift;
my $trt = $c->param('Trt'); my $trt = $c->param('Trt');
$adb = esmith::AccountsDB::UTF8->open() or die "Couldn't open DB Accounts\n";
# password reset request # password reset request
if ($trt eq 'RESET') { if ($trt eq 'RESET') {
@ -85,13 +86,13 @@ sub login {
$c->session(logged_in => 1); # set the logged_in flag $c->session(logged_in => 1); # set the logged_in flag
$c->session(username => $name); # keep a copy of the username $c->session(username => $name); # keep a copy of the username
# if ( $name eq 'admin' || $adb->is_user_in_group($name, 'AdmiN') ) # for futur use # if ( $name eq 'admin' || $adb->is_user_in_group($name, 'Admin') ) # for futur use
if ($name eq 'admin') { if ($name eq 'admin') {
$c->session(is_admin => 1); $c->session(is_admin => 1);
} else { } else {
$c->session(is_admin => 0); $c->session(is_admin => 0);
} }
$c->session(expiration => 600); # expire this session in 10 minutes $c->session(expiration => $c->config->{timeout} ); # expire this session in the time set in config
$c->flash(success => $c->l('use_WELCOME')); $c->flash(success => $c->l('use_WELCOME'));
record_login_attempt($c, 'SUCCESS'); record_login_attempt($c, 'SUCCESS');
} else { } else {
@ -114,6 +115,7 @@ sub mail_rescue {
my $c = shift; my $c = shift;
my $name = $c->param('Username'); my $name = $c->param('Username');
my $from = $c->param('From'); my $from = $c->param('From');
$adb = esmith::AccountsDB::UTF8->open() or die "Couldn't open DB Accounts\n";
my $res; my $res;
$res .= $c->l('use_TOO_MANY_LOGIN') if (is_denied($c)); $res .= $c->l('use_TOO_MANY_LOGIN') if (is_denied($c));

View File

@ -13,11 +13,8 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
#use Regexp::Common qw /net/; #use Regexp::Common qw /net/;
#use Data::Dumper;
use esmith::util; use esmith::util;
#use esmith::HostsDB;
use esmith::ConfigDB::UTF8; use esmith::ConfigDB::UTF8;
my ($cdb,$tcp_db,$udp_db); my ($cdb,$tcp_db,$udp_db);

View File

@ -14,15 +14,15 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; use esmith::AccountsDB::UTF8;
my $adb; our $adb;
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %prt_datas = (); my %prt_datas = ();
my $title = $c->l('prt_FORM_TITLE'); my $title = $c->l('prt_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$prt_datas{'trt'} = 'LIST'; $prt_datas{'trt'} = 'LIST';
my @printerDrivers; my @printerDrivers;
@ -38,7 +38,7 @@ sub do_display {
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
my $printer = $c->param('printer') || ''; my $printer = $c->param('printer') || '';
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
#$trt = 'DEL' if ( $printer ); #$trt = 'DEL' if ( $printer );
#$trt = 'ADD' if ( $rt eq 'printeradd' ); #$trt = 'ADD' if ( $rt eq 'printeradd' );
@ -79,7 +79,7 @@ sub do_update {
my $trt = ($c->param('trt') || 'LIST'); my $trt = ($c->param('trt') || 'LIST');
my %prt_datas = (); my %prt_datas = ();
my $title = $c->l('prt_FORM_TITLE'); my $title = $c->l('prt_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$prt_datas{'trt'} = $trt; $prt_datas{'trt'} = $trt;
my ($res, $result) = ''; my ($res, $result) = '';

View File

@ -14,11 +14,14 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
our $db = esmith::ConfigDB->open || die "Couldn't open config db"; use esmith::ConfigDB::UTF8;
our $db;
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
$db = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my %prx_datas = (); my %prx_datas = ();
my $title = $c->l('prx_TITLE'); my $title = $c->l('prx_TITLE');
my $modul = $c->render_to_string(inline => $c->l('prx_FIRST_PAGE_DESCRIPTION')); my $modul = $c->render_to_string(inline => $c->l('prx_FIRST_PAGE_DESCRIPTION'));

View File

@ -16,8 +16,8 @@ use Scalar::Util qw(looks_like_number);
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::AccountsDB::UTF8;
#our $adb = esmith::AccountsDB->open || die "Couldn't open accounts db";
my $adb; my $adb;
sub main { sub main {
@ -25,7 +25,7 @@ sub main {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %quo_datas = (); my %quo_datas = ();
my $title = $c->l('quo_FORM_TITLE'); my $title = $c->l('quo_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$quo_datas{'trt'} = 'LIST'; $quo_datas{'trt'} = 'LIST';
my @userAccounts; my @userAccounts;
@ -44,7 +44,7 @@ sub do_display {
$trt = 'UPD' if ($user); $trt = 'UPD' if ($user);
my %quo_datas = (); my %quo_datas = ();
my $title = $c->l('quo_FORM_TITLE'); my $title = $c->l('quo_FORM_TITLE');
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
$quo_datas{'trt'} = $trt; $quo_datas{'trt'} = $trt;
if ($trt eq 'UPD') { if ($trt eq 'UPD') {
@ -73,7 +73,7 @@ sub do_update {
$quo_datas{trt} = $trt; $quo_datas{trt} = $trt;
my $result = ''; my $result = '';
my $res; my $res;
$adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
if ($trt eq 'UPD') { if ($trt eq 'UPD') {
$quo_datas{user} = ($c->param('user') || ''); $quo_datas{user} = ($c->param('user') || '');

View File

@ -14,7 +14,7 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session ip_number subnet_mask get_reg_mask); use SrvMngr qw(theme_list init_session ip_number subnet_mask get_reg_mask);
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::util; use esmith::util;
use File::Basename; use File::Basename;
use Exporter; use Exporter;
@ -30,7 +30,7 @@ our @EXPORT = qw( networkAccess_list passwordLogin_list get_ssh_permit_root_logi
); );
# get_pptp_sessions # get_pptp_sessions
my $db; # = esmith::ConfigDB->open || warn "Couldn't open configuration database"; our $db;
sub main { sub main {
my $c = shift; my $c = shift;
@ -38,7 +38,7 @@ sub main {
my $title = $c->l('rma_FORM_TITLE'); my $title = $c->l('rma_FORM_TITLE');
my $notif = ''; my $notif = '';
my %rma_datas = (); my %rma_datas = ();
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
#$rma_datas{ipsecrwSess} = $c->get_ipsecrw_sessions(); #$rma_datas{ipsecrwSess} = $c->get_ipsecrw_sessions();
#$rma_datas{pptpSessions} = $c->get_pptp_sessions(); #$rma_datas{pptpSessions} = $c->get_pptp_sessions();
@ -60,7 +60,7 @@ sub do_action {
my $title = $c->l('rma_FORM_TITLE'); my $title = $c->l('rma_FORM_TITLE');
my ($result, $res, $trt) = ''; my ($result, $res, $trt) = '';
my %rma_datas = (); my %rma_datas = ();
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
$rma_datas{ipsecrwSess} = ($c->param('IpsecrwSess') || ''); $rma_datas{ipsecrwSess} = ($c->param('IpsecrwSess') || '');
$rma_datas{ipsecrwReset} = ($c->param('IpsecrwReset') || ''); $rma_datas{ipsecrwReset} = ($c->param('IpsecrwReset') || '');
@ -144,7 +144,7 @@ sub passwordLogin_list {
} }
sub get_prop { sub get_prop {
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my ($c, $item, $prop) = @_; my ($c, $item, $prop) = @_;
warn "You must specify a record key" unless $item; warn "You must specify a record key" unless $item;
warn "You must specify a property name" unless $prop; warn "You must specify a property name" unless $prop;
@ -155,8 +155,7 @@ sub get_prop {
sub get_value { sub get_value {
my $c = shift; my $c = shift;
my $item = shift; my $item = shift;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database";
return ($db->get($item)->value()); return ($db->get($item)->value());
} ## end sub get_value } ## end sub get_value
@ -205,7 +204,7 @@ sub get_ftp_password_login_access {
} ## end sub get_ftp_password_login_access } ## end sub get_ftp_password_login_access
sub get_telnet_mode { sub get_telnet_mode {
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my $telnet = $db->get('telnet'); my $telnet = $db->get('telnet');
return ('off') unless $telnet; return ('off') unless $telnet;
my $status = $telnet->prop('status') || 'disabled'; my $status = $telnet->prop('status') || 'disabled';
@ -215,7 +214,7 @@ sub get_telnet_mode {
} ## end sub get_telnet_mode } ## end sub get_telnet_mode
sub get_ipsecrw_sessions { sub get_ipsecrw_sessions {
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my $status = $db->get('ipsec')->prop('RoadWarriorStatus'); my $status = $db->get('ipsec')->prop('RoadWarriorStatus');
if (defined($status) && ($status eq 'enabled')) { if (defined($status) && ($status eq 'enabled')) {
return ($db->get('ipsec')->prop('RoadWarriorSessions') || '0'); return ($db->get('ipsec')->prop('RoadWarriorSessions') || '0');
@ -225,7 +224,7 @@ sub get_ipsecrw_sessions {
} ## end sub get_ipsecrw_sessions } ## end sub get_ipsecrw_sessions
sub get_ipsecrw_status { sub get_ipsecrw_status {
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
return undef unless ($db->get('ipsec')); return undef unless ($db->get('ipsec'));
return $db->get('ipsec')->prop('RoadWarriorStatus'); return $db->get('ipsec')->prop('RoadWarriorStatus');
} }
@ -233,7 +232,7 @@ sub get_ipsecrw_status {
sub pptp_and_dhcp_range { sub pptp_and_dhcp_range {
my $c = shift; my $c = shift;
my $val = shift || 0; my $val = shift || 0;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my $dhcp_status = $db->get_prop('dhcpd', 'status') || 'disabled'; my $dhcp_status = $db->get_prop('dhcpd', 'status') || 'disabled';
my $dhcp_end = $db->get_prop('dhcpd', 'end') || ''; my $dhcp_end = $db->get_prop('dhcpd', 'end') || '';
my $dhcp_start = $db->get_prop('dhcpd', 'start') || ''; my $dhcp_start = $db->get_prop('dhcpd', 'start') || '';
@ -251,7 +250,7 @@ sub pptp_and_dhcp_range {
sub _get_valid_from { sub _get_valid_from {
my $c = shift; my $c = shift;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my $rec = $db->get('httpd-admin'); my $rec = $db->get('httpd-admin');
return undef unless ($rec); return undef unless ($rec);
my @vals = (split ',', ($rec->prop('ValidFrom') || '')); my @vals = (split ',', ($rec->prop('ValidFrom') || ''));
@ -294,11 +293,11 @@ sub validate_network_and_mask {
sub change_settings { sub change_settings {
my ($c, %rma_datas) = @_; my ($c, %rma_datas) = @_;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
#------------------------------------------------------------ #------------------------------------------------------------
# good; go ahead and change the access. # good; go ahead and change the access.
#------------------------------------------------------------ #------------------------------------------------------------
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
my $rec = $db->get('telnet'); my $rec = $db->get('telnet');
if ($rec) { if ($rec) {
if ($rma_datas{telnetAccess} eq "off") { if ($rma_datas{telnetAccess} eq "off") {
@ -370,7 +369,7 @@ sub change_settings {
sub set_ipsecrw_sessions { sub set_ipsecrw_sessions {
my $c = shift; my $c = shift;
my $sessions = shift; my $sessions = shift;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
if (defined $sessions) { if (defined $sessions) {
$db->get('ipsec')->set_prop('RoadWarriorSessions', $sessions); $db->get('ipsec')->set_prop('RoadWarriorSessions', $sessions);
@ -385,7 +384,7 @@ sub add_new_valid_from {
my $c = shift; my $c = shift;
my $net = shift; my $net = shift;
my $mask = shift; my $mask = shift;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
# we transform bit mask to regular mask # we transform bit mask to regular mask
$mask = get_reg_mask($net, $mask); $mask = get_reg_mask($net, $mask);
@ -408,7 +407,7 @@ sub remove_valid_from {
my $c = shift; my $c = shift;
my $remove_nets = shift; my $remove_nets = shift;
my @remove = split /,/, $remove_nets; my @remove = split /,/, $remove_nets;
$db = esmith::ConfigDB->open || warn "Couldn't open configuration database"; $db = esmith::ConfigDB::UTF8->open || warn "Couldn't open configuration database";
# my @remove = $c->param('Remove_nets'); # my @remove = $c->param('Remove_nets');
my @vals = $c->_get_valid_from(); my @vals = $c->_get_valid_from();

View File

@ -13,17 +13,20 @@ use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use SrvMngr qw(gen_locale_date_string); use SrvMngr qw(gen_locale_date_string);
use esmith::ConfigDB::UTF8;
use esmith::DomainsDB::UTF8;
use esmith::NetworksDB::UTF8;
#use SrvMngr::Review_sub qw(print_page); #use SrvMngr::Review_sub qw(print_page);
#use smeserver::Panel::review; #use smeserver::Panel::review;
our $db = esmith::ConfigDB->open_ro || die "Couldn't open config db"; our $db;
our $domains = esmith::DomainsDB->open_ro || die "Couldn't open domains"; our $domains ;
our $networks = esmith::NetworksDB->open_ro || die "Couldn't open networks"; our $networks;
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn't open config db";
my $title = $c->l('rvw_FORM_TITLE'); my $title = $c->l('rvw_FORM_TITLE');
my $modul = $c->render_to_string(inline => $c->l('rvw_DESCRIPTION')); my $modul = $c->render_to_string(inline => $c->l('rvw_DESCRIPTION'));
my %rvw_datas = (); my %rvw_datas = ();
@ -97,6 +100,7 @@ sub gen2_email_addresses {
sub gen2_domains { sub gen2_domains {
my $c = shift; my $c = shift;
$domains = esmith::DomainsDB::UTF8->open_ro || die "Couldn't open domains";
my @virtual = $domains->get_all_by_prop(type => 'domain'); my @virtual = $domains->get_all_by_prop(type => 'domain');
my $numvirtual = @virtual; my $numvirtual = @virtual;
@ -125,6 +129,7 @@ serving. (mojo ver)
sub get2_local_networks { sub get2_local_networks {
my $c = shift; my $c = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die "Couldn't open networks";
my @nets = $networks->get_all_by_prop('type' => 'network'); my @nets = $networks->get_all_by_prop('type' => 'network');
my $numNetworks = @nets; my $numNetworks = @nets;
@ -151,7 +156,7 @@ sub get_net_prop {
my $fm = shift; my $fm = shift;
my $item = shift; my $item = shift;
my $prop = shift; my $prop = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die "Couldn't open networks";
my $record = $networks->get($item); my $record = $networks->get($item);
if ($record) { if ($record) {
return $record->prop($prop); return $record->prop($prop);
@ -165,7 +170,7 @@ sub get_net_prop {
sub get_local_networks { sub get_local_networks {
my $fm = shift; my $fm = shift;
$networks = esmith::NetworksDB::UTF8->open_ro || die "Couldn't open networks";
my @nets = $networks->get_all_by_prop('type' => 'network'); my @nets = $networks->get_all_by_prop('type' => 'network');
my $numNetworks = @nets; my $numNetworks = @nets;
@ -265,6 +270,7 @@ sub print2_dhcp_stanza {
sub get_value { sub get_value {
my $fm = shift; my $fm = shift;
my $item = shift; my $item = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn't open config db";
my $record = $db->get($item); my $record = $db->get($item);
if ($record) { if ($record) {
return $record->value(); return $record->value();
@ -281,7 +287,7 @@ sub get_prop {
#otherwise, we don't want to grab it #otherwise, we don't want to grab it
my $item = shift; my $item = shift;
my $prop = shift; my $prop = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn't open config db";
my $record = $db->get($item); my $record = $db->get($item);
if ($record) { if ($record) {
return $record->prop($prop); return $record->prop($prop);
@ -295,6 +301,7 @@ sub get_prop {
sub get_public_ip_address sub get_public_ip_address
{ {
my $self = shift; my $self = shift;
$db = esmith::ConfigDB::UTF8->open_ro || die "Couldn't open config db";
my $sysconfig = $db->get('sysconfig'); my $sysconfig = $db->get('sysconfig');
if ($sysconfig) if ($sysconfig)
{ {

View File

@ -355,10 +355,10 @@ sub lock_account {
$user = $1; $user = $1;
if (system("/sbin/e-smith/signal-event", "user-lock", $user)) { if (system("/sbin/e-smith/signal-event", "user-lock", $user)) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l("usr_ERR_OCCURRED_LOCKING"); return $c->l("usr_ERR_OCCURRED_LOCKING");
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return 'OK'; return 'OK';
} else { } else {
return $c->l('NO_SUCH_USER', $user); return $c->l('NO_SUCH_USER', $user);
@ -379,10 +379,10 @@ sub remove_account {
$user = $1; $user = $1;
if (system("/sbin/e-smith/signal-event", "user-delete", $user)) { if (system("/sbin/e-smith/signal-event", "user-delete", $user)) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l("ERR_OCCURRED_DELETING"); return $c->l("ERR_OCCURRED_DELETING");
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
$adb->get($user)->delete; $adb->get($user)->delete;
return 'OK'; return 'OK';
} else { } else {
@ -398,7 +398,7 @@ sub reset_password {
return $c->l('usr_TAINTED_USER'); return $c->l('usr_TAINTED_USER');
} }
$user = $1; $user = $1;
my $adb = esmith::AccountsDB->open || die "Couldn't open accounts db"; my $adb = esmith::AccountsDB::UTF8->open || die "Couldn't open accounts db";
my $acct = $adb->get($user); my $acct = $adb->get($user);
if ($acct->prop('type') eq "user") { if ($acct->prop('type') eq "user") {
@ -407,10 +407,10 @@ sub reset_password {
undef $adb; undef $adb;
if (system("/sbin/e-smith/signal-event", "password-modify", $user)) { if (system("/sbin/e-smith/signal-event", "password-modify", $user)) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l("usr_ERR_OCCURRED_MODIFYING_PASSWORD"); return $c->l("usr_ERR_OCCURRED_MODIFYING_PASSWORD");
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return 'OK'; return 'OK';
} else { } else {
return $c->l('NO_SUCH_USER', $user); return $c->l('NO_SUCH_USER', $user);
@ -663,10 +663,10 @@ sub modify_user {
undef $adb; undef $adb;
unless (system("/sbin/e-smith/signal-event", "user-modify", $acctName) == 0) { unless (system("/sbin/e-smith/signal-event", "user-modify", $acctName) == 0) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l('usr_CANNOT_MODIFY_USER'); return $c->l('usr_CANNOT_MODIFY_USER');
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
} ## end if ($acctType eq "user") } ## end if ($acctType eq "user")
return 'OK'; return 'OK';
} ## end sub modify_user } ## end sub modify_user
@ -699,10 +699,10 @@ sub create_user {
$acctName = $1; $acctName = $1;
if (system("/sbin/e-smith/signal-event", "user-create", $acctName)) { if (system("/sbin/e-smith/signal-event", "user-create", $acctName)) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l("usr_ERR_OCCURRED_CREATING"); return $c->l("usr_ERR_OCCURRED_CREATING");
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
$c->set_groups(); $c->set_groups();
return 'OK'; return 'OK';
} ## end sub create_user } ## end sub create_user
@ -727,7 +727,7 @@ sub modify_admin {
$acct->merge_props(%newProperties); $acct->merge_props(%newProperties);
undef $adb; undef $adb;
my $status = system("/sbin/e-smith/signal-event", "user-modify-admin", 'admin'); my $status = system("/sbin/e-smith/signal-event", "user-modify-admin", 'admin');
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
if ($status == 0) { if ($status == 0) {
return 'OK'; return 'OK';

View File

@ -12,12 +12,11 @@ use strict;
use warnings; use warnings;
use Mojo::Base 'Mojolicious::Controller'; use Mojo::Base 'Mojolicious::Controller';
use esmith::util; use esmith::util;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw( theme_list init_session validate_password ); use SrvMngr qw( theme_list init_session validate_password );
#our $cdb = esmith::ConfigDB->open_ro || die "Couldn't open configuration db";
sub main { sub main {
my $c = shift; my $c = shift;
@ -161,7 +160,7 @@ sub reset_password {
my $ret; my $ret;
return $c->l('usr_TAINTED_USER') unless (($user) = ($user =~ /^(\w[\-\w_\.]*)$/)); return $c->l('usr_TAINTED_USER') unless (($user) = ($user =~ /^(\w[\-\w_\.]*)$/));
$user = $1; $user = $1;
my $adb = esmith::AccountsDB->open(); my $adb = esmith::AccountsDB::UTF8->open();
my $acct = $adb->get($user); my $acct = $adb->get($user);
return $c->l('NO_SUCH_USER', $user) unless ($acct->prop('type') eq 'user'); return $c->l('NO_SUCH_USER', $user) unless ($acct->prop('type') eq 'user');
$ret = esmith::util::setUserPasswordRequirePrevious($user, $oldpassword, $password) if $trt ne 'RESET'; $ret = esmith::util::setUserPasswordRequirePrevious($user, $oldpassword, $password) if $trt ne 'RESET';
@ -171,10 +170,10 @@ sub reset_password {
undef $adb; undef $adb;
if (system("/sbin/e-smith/signal-event", "password-modify", $user)) { if (system("/sbin/e-smith/signal-event", "password-modify", $user)) {
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return $c->l("usr_ERR_OCCURRED_MODIFYING_PASSWORD"); return $c->l("usr_ERR_OCCURRED_MODIFYING_PASSWORD");
} }
$adb = esmith::AccountsDB->open(); $adb = esmith::AccountsDB::UTF8->open();
return 'OK'; return 'OK';
} ## end sub reset_password } ## end sub reset_password
@ -194,7 +193,7 @@ sub check_password {
my $c = shift; my $c = shift;
my $password = shift; my $password = shift;
my $strength; my $strength;
my $cdb = esmith::ConfigDB->open_ro || die "Couldn't open configuration db"; my $cdb = esmith::ConfigDB::UTF8->open_ro || die "Couldn't open configuration db";
my $rec = $cdb->get('passwordstrength'); my $rec = $cdb->get('passwordstrength');
$strength = ($rec ? ($rec->prop('Users') || 'none') : 'none'); $strength = ($rec ? ($rec->prop('Users') || 'none') : 'none');
return validate_password($c, $strength, $password); return validate_password($c, $strength, $password);

View File

@ -15,14 +15,15 @@ use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext; use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session); use SrvMngr qw(theme_list init_session);
use esmith::ConfigDB;
use File::Basename; use File::Basename;
use HTML::Entities; use HTML::Entities;
use SrvMngr qw(gen_locale_date_string); use SrvMngr qw(gen_locale_date_string);
use File::Temp qw(tempfile); use File::Temp qw(tempfile);
use constant TRUE => 1; use constant TRUE => 1;
use constant FALSE => 0; use constant FALSE => 0;
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; use esmith::ConfigDB::UTF8;
our $cdb;
our @logfiles = (); # with array our @logfiles = (); # with array
sub main { sub main {
@ -31,6 +32,7 @@ sub main {
my %log_datas = (); my %log_datas = ();
my $title = $c->l('log_FORM_TITLE'); my $title = $c->l('log_FORM_TITLE');
my $notif = ''; my $notif = '';
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
my $viewlog = $cdb->get('viewlogfiles'); my $viewlog = $cdb->get('viewlogfiles');
$log_datas{default_op} = ($viewlog ? $viewlog->prop('DefaultOperation') : undef) || 'view'; $log_datas{default_op} = ($viewlog ? $viewlog->prop('DefaultOperation') : undef) || 'view';
$c->stash(title => $title, notif => $notif, log_datas => \%log_datas); $c->stash(title => $title, notif => $notif, log_datas => \%log_datas);
@ -231,6 +233,7 @@ sub showlogFile {
sub download_logFile { sub download_logFile {
my ($c, %log_datas) = @_; my ($c, %log_datas) = @_;
my $fullpath = "/var/log/$log_datas{filename}"; my $fullpath = "/var/log/$log_datas{filename}";
$cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
# Save this information for later. # Save this information for later.
$cdb->get('viewlogfiles')->merge_props('DefaultOperation', $log_datas{operation}); $cdb->get('viewlogfiles')->merge_props('DefaultOperation', $log_datas{operation});

View File

@ -14,29 +14,29 @@ use Locale::gettext;
use SrvMngr::I18N; use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session ip_number_or_blank); use SrvMngr qw(theme_list init_session ip_number_or_blank);
# dnf_* should remain ASCII; yum_repositories do not need to be UTF-8 # dnf_* should remain ASCII; yum_repositories do not need to be UTF-8
# leavig raw read/write esmith::ConfigDB use esmith::ConfigDB::UTF8;
use esmith::ConfigDB;
use esmith::util; use esmith::util;
use File::Basename; use File::Basename;
our $cdb = esmith::ConfigDB->open || die "Couldn't open config db"; our $cdb;
my $dnf_status_file = '/var/cache/dnf/dnf.status'; my $dnf_status_file = '/var/cache/dnf/dnf.status';
#use File::stat; #use File::stat;
our %dbs; our %dbs;
for (qw(available installed updates)) { for (qw(available installed updates)) {
$dbs{$_} = esmith::ConfigDB->open_ro("dnf_$_") $dbs{$_} = esmith::ConfigDB::UTF8->open_ro("dnf_$_")
or die "Couldn't open dnf_$_ DB\n"; or die "Couldn't open dnf_$_ DB\n";
} }
for (qw(repositories)) { for (qw(repositories)) {
$dbs{$_} = esmith::ConfigDB->open("yum_$_") $dbs{$_} = esmith::ConfigDB::UTF8->open("yum_$_")
or die "Couldn't open yum_$_ DB\n"; or die "Couldn't open yum_$_ DB\n";
} }
sub main { sub main {
my $c = shift; my $c = shift;
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
$cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my %yum_datas = (); my %yum_datas = ();
my $title = $c->l('yum_FORM_TITLE'); my $title = $c->l('yum_FORM_TITLE');
my $dest = 'yum'; my $dest = 'yum';
@ -62,6 +62,7 @@ sub do_display {
my $c = shift; my $c = shift;
my $rt = $c->current_route; my $rt = $c->current_route;
my $trt = ($c->param('trt') || 'STAT'); my $trt = ($c->param('trt') || 'STAT');
$cdb = esmith::ConfigDB::UTF8->open || die "Couldn't open config db";
my %yum_datas = (); my %yum_datas = ();
my $title = $c->l('yum_FORM_TITLE'); my $title = $c->l('yum_FORM_TITLE');
my ($notif, $dest) = ''; my ($notif, $dest) = '';

View File

@ -4,19 +4,19 @@ use strict;
use warnings; use warnings;
use utf8; use utf8;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use esmith::util; use esmith::util;
use Net::LDAP qw/LDAP_INVALID_CREDENTIALS/; use Net::LDAP qw/LDAP_INVALID_CREDENTIALS/;
our ($cdb,$adb);
sub init_data { sub init_data {
my %datas = (); my %datas = ();
my $cdb = esmith::ConfigDB->open_ro() or die("can't open Config DB"); $cdb = esmith::ConfigDB::UTF8->open_ro() or die("can't open Config DB");
my $sysconfig = $cdb->get("sysconfig"); my $sysconfig = $cdb->get("sysconfig");
$datas{'lang'} = $sysconfig->prop('Language') || 'en_US'; $datas{'lang'} = $sysconfig->prop('Language') || 'en_US';
@ -42,7 +42,7 @@ sub init_data {
sub reconf_needed { sub reconf_needed {
my $cdb = esmith::ConfigDB->open_ro() or die("can't open Config DB"); $cdb = esmith::ConfigDB::UTF8->open_ro() or die("can't open Config DB");
#my $unsafe = ($cdb->get('bootstrap-console') and $cdb->get('bootstrap-console')->prop('Run') eq 'yes') || #my $unsafe = ($cdb->get('bootstrap-console') and $cdb->get('bootstrap-console')->prop('Run') eq 'yes') ||
# ($cdb->get('UnsavedChanges') and $cdb->get('UnsavedChanges')->value eq 'yes') || '0'; # ($cdb->get('UnsavedChanges') and $cdb->get('UnsavedChanges')->value eq 'yes') || '0';
my $unsafe = ($cdb->get('UnsavedChanges') and $cdb->get('UnsavedChanges')->value eq 'yes') || '0'; my $unsafe = ($cdb->get('UnsavedChanges') and $cdb->get('UnsavedChanges')->value eq 'yes') || '0';
@ -55,7 +55,7 @@ sub check_credentials {
my ($c, $username, $password) = @_; my ($c, $username, $password) = @_;
return unless $username || $password; return unless $username || $password;
my $cdb = esmith::ConfigDB->open_ro() or die("can't open Configuration DB"); $cdb = esmith::ConfigDB::UTF8->open_ro() or die("can't open Configuration DB");
my $l = $cdb->get('ldap'); my $l = $cdb->get('ldap');
my $status = $l->prop('status') || "disabled"; my $status = $l->prop('status') || "disabled";
unless ($status eq "enabled" ) { unless ($status eq "enabled" ) {
@ -88,13 +88,13 @@ sub check_adminalias {
my $c = shift; my $c = shift;
my $alias; my $alias;
my $cdb = esmith::ConfigDB->open_ro() or die("can't open Configuration DB"); $cdb = esmith::ConfigDB::UTF8->open_ro() or die("can't open Configuration DB");
if (defined $cdb->get('AdminAlias')) { if (defined $cdb->get('AdminAlias')) {
$alias = $cdb->get('AdminAlias')->value; $alias = $cdb->get('AdminAlias')->value;
} }
return undef unless $alias; return undef unless $alias;
my $adb = esmith::AccountsDB->open_ro() or die("can't open Accounts DB"); $adb = esmith::AccountsDB::UTF8->open_ro() or die("can't open Accounts DB");
my $arec = $adb->get( $alias ); my $arec = $adb->get( $alias );
return undef unless $arec; return undef unless $arec;

View File

@ -5,7 +5,7 @@ package SrvMngr_Auth;
use strict; use strict;
use warnings; use warnings;
use Exporter qw(import); # Import the Exporter module use Exporter qw(import); # Import the Exporter module
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
# Define functions to be exported upon request # Define functions to be exported upon request
our @EXPORT_OK = qw(check_admin_access load_user_auth_info has_panel_access get_panel_from_path); our @EXPORT_OK = qw(check_admin_access load_user_auth_info has_panel_access get_panel_from_path);
@ -42,7 +42,7 @@ sub load_user_auth_info {
# If not admin, get allowed panels # If not admin, get allowed panels
if (!$auth_info{is_admin} && $auth_info{username}) { if (!$auth_info{is_admin} && $auth_info{username}) {
my $accountsdb = esmith::AccountsDB->open_ro(); my $accountsdb = esmith::AccountsDB::UTF8->open_ro();
if ($accountsdb) { if ($accountsdb) {
my $user_rec = $accountsdb->get($auth_info{username}); my $user_rec = $accountsdb->get($auth_info{username});
# Check if the property exists before trying to get its value # Check if the property exists before trying to get its value

View File

@ -5,11 +5,11 @@
use strict; use strict;
use warnings; use warnings;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use constant WEBFUNCTIONS => '/usr/share/smanager/lib/SrvMngr/Controller/'; use constant WEBFUNCTIONS => '/usr/share/smanager/lib/SrvMngr/Controller/';
my $rtdb = esmith::ConfigDB->open('routes') or my $rtdb = esmith::ConfigDB::UTF8->open('routes') or
die "Couldn't access Routes database\n"; die "Couldn't access Routes database\n";
my @routes = $rtdb->get_all_by_prop( type => 'route' ); my @routes = $rtdb->get_all_by_prop( type => 'route' );

View File

@ -7,7 +7,7 @@
use strict; use strict;
use warnings; use warnings;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
sub gen_pwd { sub gen_pwd {
use MIME::Base64 qw(encode_base64); use MIME::Base64 qw(encode_base64);
@ -29,7 +29,7 @@ sub gen_pwd {
return $p; return $p;
} }
my $cdb = esmith::ConfigDB->open() || die "Couldn't open config db"; my $cdb = esmith::ConfigDB::UTF8->open() || die "Couldn't open config db";
my $pwds = $cdb->get_prop('smanager','Secrets'); my $pwds = $cdb->get_prop('smanager','Secrets');

View File

@ -14,6 +14,10 @@ BEGIN
$ENV{'HOME'} = '/usr/share/smanager'; $ENV{'HOME'} = '/usr/share/smanager';
delete $ENV{'ENV'}; delete $ENV{'ENV'};
esmith::util::setRealToEffective(); esmith::util::setRealToEffective();
#to help debug UTF8, see perlrun and perlvar -CSAD or -CLSD
#print '$ENV{PERL_UNICODE}='.$ENV{'PERL_UNICODE'}."\n" if $ENV{'PERL_UNICODE'};
#print '${^UNICODE}='.${^UNICODE}.' ; ${^UTF8LOCALE}='.${^UTF8LOCALE} ."\n";
#print '${^OPEN}'.${^OPEN}."\n" if ${^OPEN} ;
} }

View File

@ -6,8 +6,8 @@ use Test::Mojo;
use FindBin; use FindBin;
use lib "$FindBin::Bin/../lib"; use lib "$FindBin::Bin/../lib";
eval "use esmith::ConfigDB"; eval "use esmith::ConfigDB::UTF8";
plan skip_all => 'esmith::ConfigDB (and others) required for testing 002_basic' if $@; plan skip_all => 'esmith::ConfigDB::UTF8 (and others) required for testing 002_basic' if $@;
plan tests => 3; plan tests => 3;

View File

@ -6,8 +6,8 @@ use Test::Mojo;
use FindBin; use FindBin;
use lib "$FindBin::Bin/../lib"; use lib "$FindBin::Bin/../lib";
eval "use esmith::ConfigDB"; eval "use esmith::ConfigDB::UTF8";
plan skip_all => 'esmith::ConfigDB (and others) required for testing 004_panels' if $@; plan skip_all => 'esmith::ConfigDB::UTF8 (and others) required for testing 004_panels' if $@;
my $tests; my $tests;
plan tests => $tests; plan tests => $tests;
@ -17,8 +17,8 @@ BEGIN { $tests += 2 * 3 };
my $t = Test::Mojo->new('SrvMngr'); my $t = Test::Mojo->new('SrvMngr');
$t->ua->max_redirects(1); $t->ua->max_redirects(1);
$t->get_ok('/')->status_is(200)->content_like(qr/SME Server 10/); $t->get_ok('/')->status_is(200)->content_like(qr/SME Server 11/);
$t->get_ok('/manual')->status_is(200)->content_like(qr/SME Server 10/); $t->get_ok('/manual')->status_is(200)->content_like(qr/SME Server 11/);
BEGIN { $tests += 5 * 2 }; BEGIN { $tests += 5 * 2 };
my @panels = qw/ Initial Login Manual Support Request /; my @panels = qw/ Initial Login Manual Support Request /;

View File

@ -1,6 +1,6 @@
<% <%
my $backups = esmith::BackupHistoryDB->open; my $backups = esmith::BackupHistoryDB->open; # no UTF8
my $now = time(); my $now = time();
my $backup_rec = $backups->new_record($now, { my $backup_rec = $backups->new_record($now, {
type => 'backup_record', BackupType => 'desktop', type => 'backup_record', BackupType => 'desktop',

View File

@ -145,7 +145,7 @@ true
%changelog %changelog
* Mon Jun 09 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-87.sme * Mon Jun 09 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-87.sme
- add datetime getYear_list [SME: 13031] - add datetime getYear_list [SME: 13031]
- WIP use esmith::*DB::UTF8 to access db flat files [SME: 13027] - use esmith::*DB::UTF8 to access db flat files [SME: 13027]
* Mon Jun 09 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.00.0-86.sme * Mon Jun 09 2025 John Crisp <jcrisp@safeandsoundit.co.uk> 11.00.0-86.sme
- Fix datetime gen_locale_date_string reference [SME: 13017] - Fix datetime gen_locale_date_string reference [SME: 13017]