summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Parent <math.parent@gmail.com>2009-12-10 17:43:37 (GMT)
committerMathieu Parent <math.parent@gmail.com>2009-12-10 17:43:37 (GMT)
commite4ccdc80f078f713070d0c7f6326fba9a82cfd91 (patch)
treeab1e98e21df2e518e0d6cf4716c1605df808b01e
parentcbc8f5541635438aec8dfcf06add6996397cabde (diff)
downloadperl-Kolab-e4ccdc80f078f713070d0c7f6326fba9a82cfd91.tar.gz
Reindent and remove old comments
-rw-r--r--lib/Kolab/Conf.pm164
1 files changed, 80 insertions, 84 deletions
diff --git a/lib/Kolab/Conf.pm b/lib/Kolab/Conf.pm
index 9d12855..ce2e479 100644
--- a/lib/Kolab/Conf.pm
+++ b/lib/Kolab/Conf.pm
@@ -128,11 +128,11 @@ sub build {
my $templatedir = $Kolab::config{"templatedir"};
my %special_templates = (
- "$templatedir/transport.template" => 1,
- "$templatedir/virtual.template" => 1,
- "$templatedir/imapd.group.template" => 1,
- "$templatedir/slapd.access.template" => 1,
- "$templatedir/slapd.replicas.template" => 1
+ "$templatedir/transport.template" => 1,
+ "$templatedir/virtual.template" => 1,
+ "$templatedir/imapd.group.template" => 1,
+ "$templatedir/slapd.access.template" => 1,
+ "$templatedir/slapd.replicas.template" => 1
);
my $oldmask = umask 077;
@@ -142,44 +142,40 @@ sub build {
Kolab::log('T', "`$cfg' creation detected", KOLAB_DEBUG );
}
copy($cfg, $oldcfg);
- #chown($Kolab::config{'kolab_uid'}, $Kolab::config{'kolab_gid'}, $oldcfg);
# To avoid warnings, the backup files must be owned by root
chown(0, 0, $oldcfg);
umask $oldmask;
#chmod(0600, $oldcfg) if ($oldcfg =~ /openldap/);
Kolab::log('T', "Creating new configuration file `$cfg' from template `$tmpl'", KOLAB_DEBUG );
- #print STDERR "Creating new configuration file `$cfg' from template `$tmpl'\n";
my $template;
if (!($template = IO::File->new($tmpl, 'r'))) {
Kolab::log('T', "Unable to open template file `$tmpl': $!", KOLAB_ERROR);
- # Error, fail gracefully
- return;
+ # Error, fail gracefully
+ return;
}
my $config;
if (!($config = new File::Temp( TEMPLATE => 'tmpXXXXX',
- DIR => $Kolab::config{"kolabdir"},
- SUFFIX => '.kolabtmp',
- UNLINK => 0 ))) {
+ DIR => $Kolab::config{"kolabdir"},
+ SUFFIX => '.kolabtmp',
+ UNLINK => 0 ))) {
Kolab::log('T', "Unable to open configuration file `$cfg': $!", KOLAB_ERROR);
exit(1);
}
- #Kolab::log('T', "Using temporary file '".$config->filename."'", KOLAB_DEBUG );
-
my $skip = 0;
my $keep = 0;
while (<$template>) {
- #Eat the meta data sections
- if (/^KOLAB_META_START$/) {
- my $found_end;
- while (!$found_end) {
- $_ = <$template>;
- $found_end = /^KOLAB_META_END$/;
- }
- $_ = <$template>;
- }
+ #Eat the meta data sections
+ if (/^KOLAB_META_START$/) {
+ my $found_end;
+ while (!$found_end) {
+ $_ = <$template>;
+ $found_end = /^KOLAB_META_END$/;
+ }
+ $_ = <$template>;
+ }
if (/\@{3}if\s+exists\(\s*(\S+?)\s*\)\@{3}/) {
# @@@if exists(/full/path/to/file)@@@
@@ -198,82 +194,82 @@ sub build {
# its value set to either 'false' or 'true'
if ($Kolab::config{$1} && lc($Kolab::config{$1}) ne "false" ) {
# Keep text
- $keep = 1;
+ $keep = 1;
} else {
# Skip text
$skip++;
- $keep = 0;
+ $keep = 0;
}
s/\@{3}if (\S+?)\@{3}\n?//;
- } elsif (/\@{3}else\@{3}/) {
- if( $keep == 0 ) {
- # Now keep
- $keep = 1;
- $skip--;
- } else {
- # Now skip
- $keep = 0;
- $skip++;
- }
- s/\@{3}else\@{3}\n?//;
+ } elsif (/\@{3}else\@{3}/) {
+ if( $keep == 0 ) {
+ # Now keep
+ $keep = 1;
+ $skip--;
+ } else {
+ # Now skip
+ $keep = 0;
+ $skip++;
+ }
+ s/\@{3}else\@{3}\n?//;
} elsif (/\@{3}endif\@{3}/) {
($skip > 0) && $skip--;
s/\@{3}endif\@{3}\n?//;
- } elsif (/\@{3}warning\@{3}/) {
+ } elsif (/\@{3}warning\@{3}/) {
printWarning($config, $tmpl, $cchr);
} else {
while (/\@{3}([^\s\@]+?)(\|(.+?)\((.*)\))?\@{3}/) {
- my $attr = $1;
- my $fct = $3;
- my $args = $4;
- #print STDERR "attr=\"$attr\", fct=\"$fct\", args=\"$args\"\n";
- if ($Kolab::config{$attr}) {
- my $val = "";
- if( !$fct ) {
- if (ref $Kolab::config{$attr} eq "ARRAY") {
- $val = $Kolab::config{$attr}->[0];
- } else {
- $val = $Kolab::config{$attr};
- }
- } else {
- # Modifier functions
- SWITCH: {
- # Join function
- $fct eq 'join' && do {
- if (ref $Kolab::config{$attr} eq "ARRAY") {
- my @vals = @{$Kolab::config{$attr}} ;
- # We want to make sure subdomain.domain.tld comes before domain.tld
- my @length_sorted_vals = sort {length $b cmp length $a} @vals;
- $val = join ($args, @length_sorted_vals) ;
- } else {
- $val = $Kolab::config{$attr};
- }
- last SWITCH;
- };
- # Quote function
- $fct eq 'quote' && do {
- # slapd.conf compatible quoting
- $val = $Kolab::config{$attr};
- $val =~ s/"/\"/g;
- $val = '"'.$val.'"';
- last SWITCH;
- }
- }
- }
- s/\@{3}([^\s\@]+?)(\|.+?)?\@{3}/$val/;
- last if ( $val eq "\@\@\@$attr\@\@\@" ); # prevent endless loop
- } else {
- # Only warn the user in case we are not skipping the section
- ($skip == 0) && Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
- s/\@{3}([^\s\@]+?)\@{3}//;
- }
- }
- ($skip == 0) && print $config $_;
- }
+ my $attr = $1;
+ my $fct = $3;
+ my $args = $4;
+ #print STDERR "attr=\"$attr\", fct=\"$fct\", args=\"$args\"\n";
+ if ($Kolab::config{$attr}) {
+ my $val = "";
+ if( !$fct ) {
+ if (ref $Kolab::config{$attr} eq "ARRAY") {
+ $val = $Kolab::config{$attr}->[0];
+ } else {
+ $val = $Kolab::config{$attr};
+ }
+ } else {
+ # Modifier functions
+ SWITCH: {
+ # Join function
+ $fct eq 'join' && do {
+ if (ref $Kolab::config{$attr} eq "ARRAY") {
+ my @vals = @{$Kolab::config{$attr}} ;
+ # We want to make sure subdomain.domain.tld comes before domain.tld
+ my @length_sorted_vals = sort {length $b cmp length $a} @vals;
+ $val = join ($args, @length_sorted_vals) ;
+ } else {
+ $val = $Kolab::config{$attr};
+ }
+ last SWITCH;
+ };
+ # Quote function
+ $fct eq 'quote' && do {
+ # slapd.conf compatible quoting
+ $val = $Kolab::config{$attr};
+ $val =~ s/"/\"/g;
+ $val = '"'.$val.'"';
+ last SWITCH;
+ }
+ }
+ }
+ s/\@{3}([^\s\@]+?)(\|.+?)?\@{3}/$val/;
+ last if ( $val eq "\@\@\@$attr\@\@\@" ); # prevent endless loop
+ } else {
+ # Only warn the user in case we are not skipping the section
+ ($skip == 0) && Kolab::log('T', "No configuration variable corresponding to `$1' exists", KOLAB_WARN);
+ s/\@{3}([^\s\@]+?)\@{3}//;
+ }
+ }
+ ($skip == 0) && print $config $_;
+ }
}
$template->close;