mirror of
https://github.com/webmin/webmin.git
synced 2025-07-21 23:40:34 +00:00
Fix to simplify code
This commit is contained in:
@ -33,18 +33,17 @@ return &get_config_file();
|
|||||||
# Returns a list of dovecot config entries
|
# Returns a list of dovecot config entries
|
||||||
sub get_config
|
sub get_config
|
||||||
{
|
{
|
||||||
my ($excl_tpl) = @_;
|
|
||||||
if (!@get_config_cache) {
|
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;
|
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
|
# Convert a file into a list od directives
|
||||||
sub read_config_file
|
sub read_config_file
|
||||||
{
|
{
|
||||||
local ($file, $incrv, $excl_tpl) = @_;
|
local ($file, $incrv) = @_;
|
||||||
local $filedir = $file;
|
local $filedir = $file;
|
||||||
$filedir =~ s/\/[^\/]+$//;
|
$filedir =~ s/\/[^\/]+$//;
|
||||||
local $lnum = 0;
|
local $lnum = 0;
|
||||||
@ -139,7 +138,6 @@ foreach (@lines) {
|
|||||||
elsif (/^\s*!(include|include_try)\s+(\S+)/) {
|
elsif (/^\s*!(include|include_try)\s+(\S+)/) {
|
||||||
# Include file(s)
|
# Include file(s)
|
||||||
local $glob = $2;
|
local $glob = $2;
|
||||||
$lnum++, next if ($glob =~ /^\/usr\/share/ && $excl_tpl);
|
|
||||||
if ($glob !~ /^\//) {
|
if ($glob !~ /^\//) {
|
||||||
$glob = $filedir."/".$glob;
|
$glob = $filedir."/".$glob;
|
||||||
}
|
}
|
||||||
@ -218,6 +216,8 @@ return wantarray ? @rv : $rv[0];
|
|||||||
sub save_directive
|
sub save_directive
|
||||||
{
|
{
|
||||||
local ($conf, $name, $value, $sname, $svalue) = @_;
|
local ($conf, $name, $value, $sname, $svalue) = @_;
|
||||||
|
$conf = [ grep { $_->{'file'} !~ /^\/usr\/share\/dovecot/ &&
|
||||||
|
$_->{'file'} !~ /^\/opt/ } @$conf ];
|
||||||
local $dir;
|
local $dir;
|
||||||
if (ref($name)) {
|
if (ref($name)) {
|
||||||
# Old directive given
|
# Old directive given
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
require './dovecot-lib.pl';
|
require './dovecot-lib.pl';
|
||||||
&ReadParse();
|
&ReadParse();
|
||||||
&error_setup($text{'net_err'});
|
&error_setup($text{'net_err'});
|
||||||
$conf = &get_config(1);
|
$conf = &get_config();
|
||||||
&lock_dovecot_files($conf);
|
&lock_dovecot_files($conf);
|
||||||
|
|
||||||
&save_directive($conf, "protocols", join(" ", split(/\0/, $in{'protocols'})));
|
&save_directive($conf, "protocols", join(" ", split(/\0/, $in{'protocols'})));
|
||||||
|
Reference in New Issue
Block a user