Dovecot locking method
authorJamie Cameron <jcameron@webmin.com>
Sun, 20 Apr 2008 20:13:05 +0000 (20:13 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 20 Apr 2008 20:13:05 +0000 (20:13 +0000)
dovecot/CHANGELOG
dovecot/dovecot-lib.pl
dovecot/edit_mail.cgi
dovecot/lang/en
dovecot/save_mail.cgi

index 0ffdd43..1c6e41d 100644 (file)
@@ -12,3 +12,5 @@ Fixed a bug that causes config file corruption in the userdb section with the de
 Added fields for editing the UIDL format and number of login processes.
 ---- Changes since 1.360 ----
 Supported newer versions of Dovecot which use mail_location instead of default_mail_env.
+---- Changes since 1.410 ----
+The locking methods for mailboxes and index files can be configured on the Mail Files page.
index f88af18..b9d536b 100644 (file)
@@ -319,5 +319,11 @@ local $out = `$config{'dovecot'} --version 2>&1`;
 return $out =~ /([0-9\.]+)/ ? $1 : undef;
 }
 
+sub list_lock_methods
+{
+local ($forindex) = @_;
+return ( "dotlock", "fcntl", "flock", $forindex ? ( ) : ( "lockf" ) );
+}
+
 1;
 
index 779cc78..6200348 100755 (executable)
@@ -100,8 +100,42 @@ if (&find("pop3_enable_last", $conf, 2)) {
        @opts = ( [ 'yes', $text{'yes'} ], [ 'no', $text{'no'} ] );
        print &ui_table_row($text{'mail_last'},
                &ui_radio("pop3_enable_last", $last,
-                 [ @opts,
-                   [ '', &getdef("pop3_enable_last", \@opts) ] ]), 3);
+                 [ [ '', &getdef("pop3_enable_last", \@opts) ],
+                   @opts ]), 3);
+       }
+
+# Index lock method
+if (&find("lock_method", $conf, 2)) {
+       $method = &find_value("lock_method", $conf);
+       @opts = map { [ $_, $text{'mail_'.$_} ] } &list_lock_methods(1);
+       print &ui_table_row($text{'mail_lock'},
+               &ui_select("lock_method", $method,
+                          [ @opts,
+                            [ '', &getdef("lock_method", \@opts) ] ],
+                          1, 0, 1), 3);
+       }
+
+# Mailbox lock methods
+@opts = map { [ $_, $text{'mail_'.$_} ] } &list_lock_methods(0);
+foreach $l ("mbox_read_locks", "mbox_write_locks") {
+       next if (!&find($l, $conf, 2));
+       $def = &find_value($l, $conf, 1);
+       $defmsg = join(", ", map { $text{'mail_'.$_} || $_ }
+                                split(/\s+/, $def));
+       $defmsg = " ($defmsg)" if ($defmsg);
+       $method = &find_value($l, $conf);
+       $defsel = &ui_radio($l."_def", $method ? 0 : 1,
+                           [ [ 1, $text{'default'}.$defmsg ],
+                             [ 0, $text{'mail_sel'} ] ]);
+       $methsel = "";
+       @methods = split(/\s+/, $method);
+       for(my $i=0; $i<@opts; $i++) {
+               $methsel .= &ui_select($l."_".$i, $methods[$i],
+                                      [ [ '', "&lt;$text{'mail_none'}&gt;" ],
+                                        @opts ], 1, 0, 1);
+               }
+       print &ui_table_row($text{'mail_'.$l},
+                           $defsel."<br>\n".$methsel, 3);
        }
 
 print &ui_table_end();
index 8dacffb..f6d132c 100644 (file)
@@ -151,6 +151,17 @@ mail_uidl_courier2=Courier verion 2
 mail_uidl_tpop3d=tpop3d
 mail_euidl=Missing or invalid UIDL format
 mail_last=Allow use of POP3 LAST command?
+mail_lock=Index files locking method
+mail_fcntl=fcntl function
+mail_flock=flock function
+mail_dotlock=.lock files
+mail_lockf=lockf function
+mail_mbox_read_locks=Mailbox read locking method
+mail_mbox_write_locks=Mailbox write locking method
+mail_none=None
+mail_sel=Selected below, in order ..
+mail_embox_read_locks=No read locking methods selected
+mail_embox_write_locks=No write locking methods selected
 
 log_net=Changed Networking and Protocols
 log_login=Changed User and Login Options
index 83102eb..dc7a0a6 100755 (executable)
@@ -61,6 +61,28 @@ if (&find("pop3_uidl_format", $conf, 2)) {
 &save_directive($conf, "pop3_enable_last",
                $in{'last'} ? $in{'last'} : undef);
 
+# Index lock method
+if (&find("lock_method", $conf, 2)) {
+       &save_directive($conf, "lock_method",
+                       $in{'lock_method'} ? $in{'lock_method'} : undef);
+       }
+
+# Mailbox lock method
+foreach $l ("mbox_read_locks", "mbox_write_locks") {
+       next if (!&find($l, $conf, 2));
+       if ($in{$l."_def"}) {
+               &save_directive($conf, $l, undef);
+               }
+       else {
+               @methods = ( );
+               for(my $i=0; defined($m = $in{$l."_".$i}); $i++) {
+                       push(@methods, $m) if ($m);
+                       }
+               @methods || &error($text{'mail_e'.$l});
+               &save_directive($conf, $l, join(" ", @methods));
+               }
+       }
+
 &flush_file_lines();
 &unlock_file($config{'dovecot_config'});
 &webmin_log("mail");