From b7d7ea5d8d6a418b3e1dff4a12806f9b817c3686 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Fri, 15 Sep 2023 22:34:32 +0300 Subject: [PATCH] Fix to simplify code --- dovecot/dovecot-lib.pl | 10 +++++----- dovecot/save_net.cgi | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dovecot/dovecot-lib.pl b/dovecot/dovecot-lib.pl index 12cea9580..4ffc1c23b 100755 --- a/dovecot/dovecot-lib.pl +++ b/dovecot/dovecot-lib.pl @@ -33,18 +33,17 @@ return &get_config_file(); # Returns a list of dovecot config entries sub get_config { -my ($excl_tpl) = @_; if (!@get_config_cache) { - @get_config_cache = &read_config_file(&get_config_file(), undef, $excl_tpl); + @get_config_cache = &read_config_file(&get_config_file()); } return \@get_config_cache; } -# read_config_file(filename, [&include-parent-rv], [exclude-templates]) +# read_config_file(filename, [&include-parent-rv]) # Convert a file into a list od directives sub read_config_file { -local ($file, $incrv, $excl_tpl) = @_; +local ($file, $incrv) = @_; local $filedir = $file; $filedir =~ s/\/[^\/]+$//; local $lnum = 0; @@ -139,7 +138,6 @@ foreach (@lines) { elsif (/^\s*!(include|include_try)\s+(\S+)/) { # Include file(s) local $glob = $2; - $lnum++, next if ($glob =~ /^\/usr\/share/ && $excl_tpl); if ($glob !~ /^\//) { $glob = $filedir."/".$glob; } @@ -218,6 +216,8 @@ return wantarray ? @rv : $rv[0]; sub save_directive { local ($conf, $name, $value, $sname, $svalue) = @_; +$conf = [ grep { $_->{'file'} !~ /^\/usr\/share\/dovecot/ && + $_->{'file'} !~ /^\/opt/ } @$conf ]; local $dir; if (ref($name)) { # Old directive given diff --git a/dovecot/save_net.cgi b/dovecot/save_net.cgi index 6399cbc18..6bb7a9e86 100755 --- a/dovecot/save_net.cgi +++ b/dovecot/save_net.cgi @@ -4,7 +4,7 @@ require './dovecot-lib.pl'; &ReadParse(); &error_setup($text{'net_err'}); -$conf = &get_config(1); +$conf = &get_config(); &lock_dovecot_files($conf); &save_directive($conf, "protocols", join(" ", split(/\0/, $in{'protocols'})));