diff --git a/createlinks b/createlinks index 77e3c14..2195d62 100644 --- a/createlinks +++ b/createlinks @@ -4,6 +4,10 @@ use esmith::Build::CreateLinks qw(:all); event_link("dovecot-acl", "email-update", "85"); event_link("dovecot-acl", "user-create", "85"); +event_link("dovecot-acl", "post-upgrade", "85"); + event_link("dovecot-compile-sieve", "email-update", "86"); safe_touch("root/etc/dovecot/sharedmailbox/dict.db"); + +templates2events("/home/e-smith/files/public/dovecot-acl", "email-update"); diff --git a/root/etc/e-smith/events/actions/dovecot-acl b/root/etc/e-smith/events/actions/dovecot-acl index fea20ca..ca83b13 100644 --- a/root/etc/e-smith/events/actions/dovecot-acl +++ b/root/etc/e-smith/events/actions/dovecot-acl @@ -14,6 +14,14 @@ die "couldn't find dovecot service\n" unless ($dovecot); my $event = $ARGV[0]; +# If PublicMailbox is enabled +if (($dovecot->prop('PublicMailbox') || 'disabled') eq 'enabled'){ + system('/bin/mkdir' ,'-p', "/home/e-smith/files/public") unless (-d '/home/e-smith/files/public'); + system('/bin/chmod', "770", "/home/e-smith/files/public"); + system('/bin/chmod', 'g+s', "/home/e-smith/files/public"); + system('/bin/chown', 'root.sharedmailbox', "/home/e-smith/files/public"); +} + # SharedMailboxes disabled ? if (($dovecot->prop('SharedMailbox') || 'disabled') eq 'disabled'){ if (($dovecot->prop('SharedMailboxAcl') || 'yes') ne 'no'){ diff --git a/root/etc/e-smith/templates.metadata/home/e-smith/files/public/dovecot-acl b/root/etc/e-smith/templates.metadata/home/e-smith/files/public/dovecot-acl new file mode 100644 index 0000000..501c14f --- /dev/null +++ b/root/etc/e-smith/templates.metadata/home/e-smith/files/public/dovecot-acl @@ -0,0 +1 @@ +GID="sharedmailbox" diff --git a/root/etc/e-smith/templates/etc/dovecot/dovecot.conf/65pluginAcl b/root/etc/e-smith/templates/etc/dovecot/dovecot.conf/65pluginAcl index 947b4b8..463a3fd 100644 --- a/root/etc/e-smith/templates/etc/dovecot/dovecot.conf/65pluginAcl +++ b/root/etc/e-smith/templates/etc/dovecot/dovecot.conf/65pluginAcl @@ -1,10 +1,11 @@ { -return "" if (($dovecot{'SharedMailbox'} || 'disabled') eq 'disabled'); +return "# Mailbox sharing is not enabled" + if (($dovecot{'SharedMailbox'} || 'disabled') eq 'disabled') && (($dovecot{'PublicMailbox'} || 'disabled') eq 'disabled'); push @plugins, 'acl'; push @imap_plugins, 'imap_acl'; -my $string =<<'HERE'; +my $common =<<'_EOF'; mail_access_groups = sharedmailbox @@ -39,7 +40,13 @@ namespace { prefix = inbox = yes } +_EOF +{ +my $shared_mb = "\n# SharedMailbox is disabled\n"; +my $public_mb = "\n# PublicMailbox is disabled\n"; +if (($dovecot{'SharedMailbox'} || 'disabled') eq 'enabled'){ + $shared_mb =<<'_EOF'; namespace { type = shared separator = / @@ -48,7 +55,22 @@ namespace { subscriptions = no list = children } +_EOF +} +if (($dovecot{'PublicMailbox'} || 'disabled') eq 'enabled'){ + $public_mb =<<'_EOF'; +namespace { + type = public + separator = / + prefix = public/ + location = maildir:/home/e-smith/files/public + subscriptions = no + list = children +} +_EOF +} +my $acl =<<'_EOF'; plugin { acl_shared_dict = file:/home/e-smith/db/dovecot/sharedmailbox.db } @@ -61,8 +83,8 @@ plugin { acl_anyone = allow } -HERE +_EOF -push @conf, $string; +push @conf, $common, $shared_mb, $public_mb, $acl; $OUT .= ''; } diff --git a/root/etc/e-smith/templates/home/e-smith/files/public/dovecot-acl/10All b/root/etc/e-smith/templates/home/e-smith/files/public/dovecot-acl/10All new file mode 100644 index 0000000..71b39c0 --- /dev/null +++ b/root/etc/e-smith/templates/home/e-smith/files/public/dovecot-acl/10All @@ -0,0 +1,12 @@ +{ + +if (($dovecot{'PublicMailbox'} || 'disabled') eq 'enabled'){ + my @PublicMailboxAdmins = split /[,:]/, ($dovecot{PublicMailboxAdmins} || ''); + $OUT .= "authenticated lrwsie" . "\n"; + $OUT .= "user=admin lrswtipekxa" . "\n"; + foreach my $PublicMailboxAdmins (sort @PublicMailboxAdmins){ + $OUT .= 'user=' . "$PublicMailboxAdmins " . 'lrswtipekxa' . "\n"; + } +} + +}