Handle different dovecot config locations on CentOS 6
authorJamie Cameron <jcameron@webmin.com>
Thu, 11 Aug 2011 19:47:15 +0000 (12:47 -0700)
committerJamie Cameron <jcameron@webmin.com>
Thu, 11 Aug 2011 19:47:15 +0000 (12:47 -0700)
dovecot/CHANGELOG
dovecot/config-redhat-linux-11.0-*
dovecot/dovecot-lib.pl
dovecot/edit_manual.cgi
dovecot/index.cgi
dovecot/install_check.pl

index dc620d5..4516fa7 100644 (file)
@@ -21,3 +21,5 @@ Added fields to the SSL page for an optional CA certificate file and private key
 Added support for Dovecot 2.0, which renames many configuration directives and splits up the config using include files.
 ---- Changes since 1.550 ----
 The Edit Config Files page can now be used to edit any of the Dovecot configuration files, for the case where there are many included configs.
+---- Changes since 1.560 ----
+Fixed support for CentOS 6 and related distributions, which move the Dovecot config to /etc/dovecot/dovecot.conf.
index 25b7c7c..2396a17 100644 (file)
@@ -1,4 +1,4 @@
 dovecot=/usr/sbin/dovecot
-dovecot_config=/etc/dovecot.conf
+dovecot_config=/etc/dovecot/dovecot.conf /etc/dovecot.conf
 init_script=dovecot
 pid_file=/var/run/dovecot/master.pid
index 81fc860..e04d607 100755 (executable)
@@ -9,12 +9,22 @@ use WebminCore;
 @mail_envs = ( undef, "maildir:~/Maildir", "mbox:~/mail/:INBOX=/var/mail/%u",
               "maildir:~/Maildir:mbox:~/mail/" );
 
+# get_config_file()
+# Returns the full path to the first valid config file
+sub get_config_file
+{
+foreach my $f (split(/\s+/, $config{'dovecot_config'})) {
+       return $f if (-r $f);
+       }
+return undef;
+}
+
 # get_config()
 # Returns a list of dovecot config entries
 sub get_config
 {
 if (!scalar(@get_config_cache)) {
-       @get_config_cache = &read_config_file($config{'dovecot_config'});
+       @get_config_cache = &read_config_file(&get_config_file());
        }
 return \@get_config_cache;
 }
@@ -201,7 +211,7 @@ elsif (!$dir && defined($value)) {
                }
        else {
                # Need to put at end of main config
-               local $lref = &read_file_lines($config{'dovecot_config'});
+               local $lref = &read_file_lines(&get_config_file());
                push(@$lref, $newline);
                push(@$conf, { 'name' => $name,
                               'value' => $value,
index b1d3f9f..65654b4 100755 (executable)
@@ -4,7 +4,7 @@
 require './dovecot-lib.pl';
 &ui_print_header(undef, $text{'manual_title'}, "");
 &ReadParse();
-$file = $in{'file'} || $config{'dovecot_config'};
+$file = $in{'file'} || &get_config_file();
 $conf = &get_config();
 @files = &unique(map { $_->{'file'} } @$conf);
 &indexof($file, @files) >= 0 || &error($text{'manual_efile'});
index 491fcec..78e5cd5 100755 (executable)
@@ -24,7 +24,7 @@ if (!&has_command($config{'dovecot'})) {
        }
 
 # Check for config file
-if (!-r $config{'dovecot_config'}) {
+if (!&get_config_file()) {
        print &ui_config_link('index_econf',
                [ "<tt>$config{'dovecot_config'}</tt>", undef ]),"<p>\n";
        &ui_print_footer("/", $text{'index'});
index a8f0289..a77ed33 100755 (executable)
@@ -9,7 +9,7 @@ do 'dovecot-lib.pl';
 sub is_installed
 {
 return 0 if (!&has_command($config{'dovecot'}) ||
-            !-r $config{'dovecot_config'});
+            !&get_config_file());
 return $_[0] ? 2 : 1;
 }