From 6a52e99d10f92b766d543f22f04f372ff50074fc Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 29 Sep 2014 12:22:45 +0000 Subject: [PATCH] Mail backend fixes --- TODO.md | 14 +++++++++++++- orchestra/apps/mails/admin.py | 2 +- orchestra/apps/mails/backends.py | 6 +++--- orchestra/apps/mails/models.py | 2 ++ orchestra/apps/mails/settings.py | 2 +- orchestra/apps/users/roles/posix/models.py | 1 + scripts/services/postfix.md | 10 ++++++++++ 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index ebc7b47b..a12ff9fa 100644 --- a/TODO.md +++ b/TODO.md @@ -16,7 +16,7 @@ TODO * move invoice contact to invoices app? * PHPbBckendMiixin with get_php_ini * Apache: `IncludeOptional /etc/apache2/extra-vhos[t]/account-site-custom.con[f]` -* rename account.user to primary_user +* rename account.user to main_user * webmail identities and addresses * cached -> cached_property * user.roles.mailbox its awful when combined with addresses: @@ -115,3 +115,15 @@ Remember that, as always with QuerySets, any subsequent chained methods which im - system users are independent users, so they can have different passwords and all. * take a look icons from ajenti ;) + + +* Disable services is_active should be computed on the fly in order to distinguish account.is_active from service.is_active when reactivation. + * Perhaps it is time to create a ServiceModel ? + + +* COpy account.main_user.username to account.name for performance + +* service backend execution dependency? first create user on NIS master then create directories on service server + +* prevent deletion of main user by the user itself + diff --git a/orchestra/apps/mails/admin.py b/orchestra/apps/mails/admin.py index c00656ae..6b165644 100644 --- a/orchestra/apps/mails/admin.py +++ b/orchestra/apps/mails/admin.py @@ -29,7 +29,7 @@ class MailboxAdmin(AccountAdminMixin, ExtendedModelAdmin): list_filter = ('use_custom_filtering', HasAddressListFilter) add_fieldsets = ( (None, { - 'fields': ('account', 'name'), + 'fields': ('account', 'name', 'password'), }), (_("Filtering"), { 'fields': ('use_custom_filtering', 'custom_filtering'), diff --git a/orchestra/apps/mails/backends.py b/orchestra/apps/mails/backends.py index b8724c27..c4306d4c 100644 --- a/orchestra/apps/mails/backends.py +++ b/orchestra/apps/mails/backends.py @@ -55,10 +55,10 @@ class MailSystemUserBackend(ServiceController): self.append("rm -fr %(home)s" % context) def get_context(self, mailbox): - user = mailbox.user context = { - 'username': user.username, - 'password': user.password if user.is_active else '*%s' % user.password, + 'name': mailbox.nam, + 'username': mailbox.name, + 'password': mailbox.password if mailbox.is_active else '*%s' % mailbox.password, 'group': self.DEFAULT_GROUP } context['home'] = settings.EMAILS_HOME % context diff --git a/orchestra/apps/mails/models.py b/orchestra/apps/mails/models.py index 70d5778c..12ba771a 100644 --- a/orchestra/apps/mails/models.py +++ b/orchestra/apps/mails/models.py @@ -13,6 +13,7 @@ class Mailbox(models.Model): "@/./+/-/_ only."), validators=[RegexValidator(r'^[\w.@+-]+$', _("Enter a valid mailbox name."), 'invalid')]) + password = models.CharField(_("password"), max_length=128) account = models.ForeignKey('accounts.Account', verbose_name=_("account"), related_name='mailboxes') use_custom_filtering = models.BooleanField(_("Use custom filtering"), @@ -20,6 +21,7 @@ class Mailbox(models.Model): custom_filtering = models.TextField(_("filtering"), blank=True, validators=[validators.validate_sieve], help_text=_("Arbitrary email filtering in sieve language.")) + is_active = models.BooleanField(_("is active"), default=True) # addresses = models.ManyToManyField('mails.Address', # verbose_name=_("addresses"), # related_name='mailboxes', blank=True) diff --git a/orchestra/apps/mails/settings.py b/orchestra/apps/mails/settings.py index 30473edb..fcca1e32 100644 --- a/orchestra/apps/mails/settings.py +++ b/orchestra/apps/mails/settings.py @@ -3,7 +3,7 @@ from django.conf import settings EMAILS_DOMAIN_MODEL = getattr(settings, 'EMAILS_DOMAIN_MODEL', 'domains.Domain') -EMAILS_HOME = getattr(settings, 'EMAILS_HOME', '/var/vmail/%(account)s/%(name)s/') +EMAILS_HOME = getattr(settings, 'EMAILS_HOME', '/home/%(username)s/') EMAILS_SIEVETEST_PATH = getattr(settings, 'EMAILS_SIEVETEST_PATH', '/dev/shm') diff --git a/orchestra/apps/users/roles/posix/models.py b/orchestra/apps/users/roles/posix/models.py index a9a4590a..3639afc9 100644 --- a/orchestra/apps/users/roles/posix/models.py +++ b/orchestra/apps/users/roles/posix/models.py @@ -17,5 +17,6 @@ class POSIX(models.Model): def __unicode__(self): return str(self.user) +# TODO groups roles.register('posix', POSIX) diff --git a/scripts/services/postfix.md b/scripts/services/postfix.md index 084167ab..51eae45d 100644 --- a/scripts/services/postfix.md +++ b/scripts/services/postfix.md @@ -21,3 +21,13 @@ wget -O - http://apt.baruwa.org/baruwa-apt-keys.gpg | apt-key add - apt-get update apt-get install mailscanner + + + + +apt-get install dovecot-core dovecot-imapd dovecot-pop3d dovecot-sieve +apt-get install postfix + + +mail_location = maildir:~/Maildir +