* Mon Oct 06 2025 Brian Read <brianr@koozali.org> 11.0.0-4.sme

- Add UTF8 and avoid potential DB caching problems [SME: 13209]
This commit is contained in:
2025-10-06 10:18:38 +01:00
parent 6d5df54c78
commit 1f26e43d09
4 changed files with 52 additions and 40 deletions

View File

@@ -7,11 +7,11 @@
# #
use esmith::util; use esmith::util;
use esmith::util::network; use esmith::util::network;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::HostsDB; use esmith::HostsDB::UTF8;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::DomainsDB; use esmith::DomainsDB::UTF8;
use Encode::IMAPUTF7; use Encode::IMAPUTF7;
use Encode qw(decode); use Encode qw(decode);
@@ -19,9 +19,9 @@ use Encode qw(decode);
use constant FALSE => 0; use constant FALSE => 0;
use constant TRUE => 1; use constant TRUE => 1;
our $cdb = esmith::ConfigDB->open(); #our $cdb = esmith::ConfigDB::UTF8->open();
our $adb = esmith::AccountsDB->open(); #our $adb = esmith::AccountsDB::UTF8->open();
our $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; #our $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
our $PanelUser = $ENV{'REMOTE_USER'} ||''; our $PanelUser = $ENV{'REMOTE_USER'} ||'';
$PanelUser = $1 if ($PanelUser =~ /^([a-z][\.\-a-z0-9]*)$/); $PanelUser = $1 if ($PanelUser =~ /^([a-z][\.\-a-z0-9]*)$/);
@@ -119,7 +119,7 @@ my $pdb;
sub get_data_for_panel_RULES { sub get_data_for_panel_RULES {
# Return a hash with the fields required which will be loaded into the shared data # Return a hash with the fields required which will be loaded into the shared data
my $c = shift; my $c = shift;
my $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
my $key = $c->param('Selected'); my $key = $c->param('Selected');
@@ -154,7 +154,7 @@ sub get_data_for_panel_RULES {
sub get_data_for_panel_REMOVE { sub get_data_for_panel_REMOVE {
# Return a hash with the fields required which will be loaded into the shared data # Return a hash with the fields required which will be loaded into the shared data
my $c = shift; my $c = shift;
my $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
my $key = $c->param('Selected'); my $key = $c->param('Selected');
my %ret = ( my %ret = (
@@ -190,9 +190,9 @@ sub actual_getAllRules {
my @data; my @data;
# Open the required databases # Open the required databases
my $cdb = esmith::ConfigDB->open(); my $cdb = esmith::ConfigDB::UTF8->open();
my $adb = esmith::AccountsDB->open(); my $adb = esmith::AccountsDB::UTF8->open();
my $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
my @rules = $pdb->get_all_by_prop(type => "$PanelUser"); my @rules = $pdb->get_all_by_prop(type => "$PanelUser");
@@ -334,7 +334,7 @@ sub get_getAllRules {
sub remove_rule { sub remove_rule {
my $c = shift; my $c = shift;
my $rule = $c->param('Selected'); my $rule = $c->param('Selected');
my $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
my $rec = $pdb->get($rule); # || return "Rule:$rule not found"; my $rec = $pdb->get($rule); # || return "Rule:$rule not found";
$rec->delete; $rec->delete;
@@ -360,7 +360,7 @@ sub get_panel_user
sub get_full_name{ sub get_full_name{
my $c = shift; my $c = shift;
my $adb = esmith::AccountsDB->open(); my $adb = esmith::AccountsDB::UTF8->open();
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
return $adb->get_prop($PanelUser, "FirstName") . " " . return $adb->get_prop($PanelUser, "FirstName") . " " .
$adb->get_prop($PanelUser, "LastName"); $adb->get_prop($PanelUser, "LastName");
@@ -396,12 +396,19 @@ sub listfolders
my %out_dir; my %out_dir;
$out_dir{"INBOX"} .= "INBOX"; $out_dir{"INBOX"} .= "INBOX";
$out_dir{""} .= ""; $out_dir{""} .= "";
for (sort @dirs) { #for (sort @dirs) {
s/$root\/?\.?//; #s/$root\/?\.?//;
#my @exclu =("cur", "tmp", "new" , "INBOX" );
#next if $_ ~~ @exclu;
#$out_dir{$_} .= GetDisplayName(join('/',split('\.', $_)));
#}
for my $dir (sort @dirs) {
$dir =~ s/$root\/?\.?//;
my @exclu = ("cur", "tmp", "new", "INBOX"); my @exclu = ("cur", "tmp", "new", "INBOX");
next if $_ ~~ @exclu; next if grep { $_ eq $dir } @exclu;
$out_dir{$_} .= GetDisplayName(join('/',split('\.', $_))); $out_dir{$dir} .= GetDisplayName(join('/', split('\.', $dir)));
} }
return \%out_dir; return \%out_dir;
} }
@@ -462,7 +469,7 @@ sub get_rule_from_db{
sub save_rule sub save_rule
{ {
my $c = shift; my $c = shift;
my $pdb = esmith::ConfigDB->open('processmail') or die "Could not open processmail DB\n"; my $pdb = esmith::ConfigDB::UTF8->open('processmail') or die "Could not open processmail DB\n";
my $PanelUser = $c->get_panel_user(); my $PanelUser = $c->get_panel_user();
my $rule = $c->param ('key') || ''; my $rule = $c->param ('key') || '';

View File

@@ -5,9 +5,10 @@ package SrvMngr::Controller::Mailsorting;
# you cannot have get and post on the same name and url. # you cannot have get and post on the same name and url.
# #
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# heading : System # heading : User management
# description : Process Mail # description : Process Mail
# navigation : 6000 1200 # navigation : 6000 1200
# menucat : U
# #
# name : mailsorting, method : get, url : /mailsorting, ctlact : Mailsorting#main # name : mailsorting, method : get, url : /mailsorting, ctlact : Mailsorting#main
# name : mailsortingu, method : post, url : /mailsortingu, ctlact : Mailsorting#do_update # name : mailsortingu, method : post, url : /mailsortingu, ctlact : Mailsorting#do_update
@@ -39,11 +40,11 @@ use Data::Dumper;
use esmith::util; use esmith::util;
use esmith::util::network; use esmith::util::network;
use esmith::ConfigDB; use esmith::ConfigDB::UTF8;
use esmith::AccountsDB; use esmith::AccountsDB::UTF8;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::HostsDB; use esmith::HostsDB::UTF8;
use esmith::DomainsDB; use esmith::DomainsDB::UTF8;
my $cdb; my $cdb;
my $adb; my $adb;
@@ -71,11 +72,11 @@ sub main {
$c->app->log->info( $c->log_req ); $c->app->log->info( $c->log_req );
#The most common ones #The most common ones
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
%ms_data = (); %ms_data = ();
my $title = $c->l('ms_Process_Mail'); my $title = $c->l('ms_Process_Mail');
@@ -123,11 +124,11 @@ sub do_update {
my $modul = ''; my $modul = '';
#The most common ones - you might want to comment out any not used. #The most common ones - you might want to comment out any not used.
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
my $title = $c->l('ms_Process_Mail'); my $title = $c->l('ms_Process_Mail');
@@ -251,11 +252,11 @@ sub do_display {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
#The most common ones - you might want to comment out any not used. #The most common ones - you might want to comment out any not used.
$cdb = esmith::ConfigDB->open() || die("Couldn't open config db"); $cdb = esmith::ConfigDB::UTF8->open() || die("Couldn't open config db");
$adb = esmith::AccountsDB->open() || die("Couldn't open Accounts db"); $adb = esmith::AccountsDB::UTF8->open() || die("Couldn't open Accounts db");
$ndb = esmith::NetworksDB->open() || die("Couldn't open Network db"); $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
$hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db"); $hdb = esmith::HostsDB::UTF8->open() || die("Couldn't open Hosts db");
$ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db"); $ddb = esmith::DomainsDB::UTF8->open() || die("Couldn't open Domains db");
my $title = $c->l('ms_Process_Mail'); my $title = $c->l('ms_Process_Mail');
my $modul = ""; my $modul = "";

View File

@@ -50,4 +50,5 @@
'ms_2nd_action' => '2nd action', 'ms_2nd_action' => '2nd action',
'ms_deliver2_email' => '2nd action Delivery email (if forwarding)', 'ms_deliver2_email' => '2nd action Delivery email (if forwarding)',
'ms_key' => 'Order of rule execution', 'ms_key' => 'Order of rule execution',
'ms_new_record' => 'Select the part of the email to be tested. You can match against part of an email address, header, subject, or the email size. Size is in bytes. Delete, sort or Forward any matches. The second match is optional, but if used both rules must match' 'ms_new_record' => 'Select the part of the email to be tested. You can match against part of an email address, header, subject, or the email size. Size is in bytes. Delete, sort or Forward any matches. The second match is optional, but if used both rules must match',
'ms_ERROR_FORWARD_NO_EMAIL' => 'No email address provided for forwarding',

View File

@@ -6,7 +6,7 @@ Summary: Lets users configure procmail or maildrop rules.
%define name smeserver-mailsorting %define name smeserver-mailsorting
Name: %{name} Name: %{name}
%define version 11.0.0 %define version 11.0.0
%define release 3 %define release 4
Version: %{version} Version: %{version}
Release: %{release}%{?dist} Release: %{release}%{?dist}
License: GPL License: GPL
@@ -32,6 +32,9 @@ SME Server enhancement to enable procmail or maildrop filtering for users.
Optionally provides user panels where users can create mail rules for themselves Optionally provides user panels where users can create mail rules for themselves
%changelog %changelog
* Mon Oct 06 2025 Brian Read <brianr@koozali.org> 11.0.0-4.sme
- Add UTF8 and avoid potential DB caching problems [SME: 13209]
* Wed May 07 2025 Brian Read <brianr@koozali.org> 11.0.0-3.sme * Wed May 07 2025 Brian Read <brianr@koozali.org> 11.0.0-3.sme
- Missed lex file last time, plus extra code for new record [SME:13000] - Missed lex file last time, plus extra code for new record [SME:13000]
- Get validation working. - Get validation working.