Skip to content

Commit

Permalink
bnc#800788 - ag_postfix_mastercf process hangs the system, after whic…
Browse files Browse the repository at this point in the history
…h it is killed by kernel, when saving mail server settings with Yast "Mail Server" module
  • Loading branch information
varkoly committed Apr 2, 2013
1 parent a996b40 commit c1800ea
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 140 deletions.
2 changes: 0 additions & 2 deletions agents/Makefile.am
Expand Up @@ -9,7 +9,6 @@ agent_SCRIPTS = ag_fetchmailrc \
ag_mailtable \
setup_dkim_verifying.pl \
ag_mailconfig \
ag_postfix_mastercf \
MasterCFParser.pm \
ag_mail_ldaptable \
ag_cyrus_conf \
Expand All @@ -31,7 +30,6 @@ scrconf_DATA = \
\
mail_maincf.scr \
mail_saslpasswd.scr \
mail_mastercf.scr \
etc_imapd_conf.scr \
mail_ldaptable.scr \
mail_cyrusconf.scr \
Expand Down
31 changes: 12 additions & 19 deletions agents/MasterCFParser.pm
Expand Up @@ -80,26 +80,18 @@ no warnings 'redefine';
=item *
C<new();>
Instantiating a MasterCFParser instance. Optional parameter can be a different
path to master.cf and a reference to a logging function.
Instantiating a MasterCFParser instance.
EXAMPLE:
$_CFINST = new MasterCFParser( $config->{"path"}, \&y2error );
$_CFINST = new MasterCFParser( );
=cut
sub new {
my $this = shift;
my $path = shift || "/etc/postfix";
my $logref = shift;

if( defined $logref && $logref ne "" ) {
*logger = $logref;
}

my $class = ref($this) || $this;
my $self = {};
$self->{cffile} = $path."/master.cf";
$self->{cffile} = "/etc/postfix/master.cf";

bless $self, $class;
return $self;
Expand Down Expand Up @@ -144,7 +136,8 @@ sub readMasterCF {
push @$cfa, line2service($line);
}
}
$this->{MCF} = $cfa;
$this->{MCF} = $cfa;
$this->{SMCF} = scalar(@$cfa);
return 0;
}

Expand Down Expand Up @@ -172,7 +165,7 @@ sub writeMasterCF {
return 1;
}

for(my $c=0; $c<scalar(@{$this->{MCF}}); $c++ ) {
for(my $c=0; $c<$this->{SMCF}; $c++ ) {
print $fd service2line($this->{MCF}->[$c])."\n";
}

Expand Down Expand Up @@ -209,7 +202,7 @@ sub deleteService {
return 1;
}

for(my $c=0; $c<scalar(@{$this->{MCF}}); $c++ ) {
for(my $c=0; $c<$this->{SMCF}; $c++ ) {
next if ! defined $this->{MCF}->[$c]->{service};
if( $this->{MCF}->[$c]->{service} eq $srv->{service} &&
$this->{MCF}->[$c]->{command} eq $srv->{command} ) {
Expand Down Expand Up @@ -299,19 +292,19 @@ sub addService {
push @{$this->{MCF}}, $srv;
} else {
my $newcf;
for(my $c=0; $c<scalar(@{$this->{MCF}}); $c++ ) {
for(my $c=0; $c<$this->{SMCF}; $c++ ) {
if( defined $srv ) {
my ($nc, $cmd) = $this->nextCommand($c);
if( $cmd eq "pipe" ) {
push @$newcf, $srv;
while($c < $nc) {
push @$newcf, $this->{MCF}->[$c++];
}
$srv = undef;
}
}
push @$newcf, $this->{MCF}->[$c];
}
if( defined $srv ) {
push @$newcf, $srv;
}
$this->{MCF} = $newcf;
}
return 0;
Expand Down Expand Up @@ -396,7 +389,7 @@ sub nextCommand {
my $pos = shift;

return ($pos, $this->{MCF}->[$pos]->{command}) if defined $this->{MCF}->[$pos]->{command};
while( ! defined $this->{MCF}->[$pos]->{command} ) {
while( ! defined $this->{MCF}->[$pos]->{command} && $pos < $this->{SMCF} ) {
$pos++;
}

Expand Down
29 changes: 0 additions & 29 deletions agents/mail_mastercf.scr

This file was deleted.

0 comments on commit c1800ea

Please sign in to comment.