mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
Merge branch '1.x'
This commit is contained in:
@@ -145,14 +145,6 @@ class AdminParametersForm(param_forms.AdminParametersForm):
|
||||
)
|
||||
)
|
||||
|
||||
mailboxes_owner = forms.CharField(
|
||||
label=ugettext_lazy("Mailboxes owner"),
|
||||
initial="vmail",
|
||||
help_text=ugettext_lazy(
|
||||
"The UNIX account who owns mailboxes on the filesystem"
|
||||
)
|
||||
)
|
||||
|
||||
default_mailbox_quota = forms.IntegerField(
|
||||
label=ugettext_lazy("Default mailbox quota"),
|
||||
initial=0,
|
||||
@@ -198,8 +190,7 @@ class AdminParametersForm(param_forms.AdminParametersForm):
|
||||
# Visibility rules
|
||||
visibility_rules = {
|
||||
"valid_mxs": "enable_mx_checks=True",
|
||||
"domains_must_have_authorized_mx": "enable_mx_checks=True",
|
||||
"mailboxes_owner": "handle_mailboxes=True",
|
||||
"domains_must_have_authorized_mx": "enable_mx_checks=True"
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -234,7 +225,6 @@ class AdminParametersForm(param_forms.AdminParametersForm):
|
||||
hide_fields = True
|
||||
if hide_fields:
|
||||
del self.fields["handle_mailboxes"]
|
||||
del self.fields["mailboxes_owner"]
|
||||
|
||||
def clean_default_domain_quota(self):
|
||||
"""Ensure quota is a positive integer."""
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.2.12 on 2020-12-04 08:35
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('admin', '0017_alarm'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='alarm',
|
||||
name='title',
|
||||
field=models.TextField(),
|
||||
),
|
||||
]
|
||||
@@ -33,7 +33,7 @@ class Alarm(models.Model):
|
||||
db_index=True
|
||||
)
|
||||
|
||||
title = models.CharField(max_length=150)
|
||||
title = models.TextField()
|
||||
internal_name = models.CharField(max_length=120)
|
||||
|
||||
objects = models.Manager.from_queryset(AlarmQuerySet)()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
"""Models related to mailboxes management."""
|
||||
|
||||
import os
|
||||
import pwd
|
||||
|
||||
from reversion import revisions as reversion
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
@@ -153,14 +150,7 @@ class Mailbox(mixins.MessageLimitMixin, AdminObject):
|
||||
if not admin_params.get("handle_mailboxes"):
|
||||
return None
|
||||
if self.__mail_home is None:
|
||||
curuser = pwd.getpwuid(os.getuid()).pw_name
|
||||
mbowner = admin_params["mailboxes_owner"]
|
||||
options = {}
|
||||
if curuser != mbowner:
|
||||
options["sudo_user"] = mbowner
|
||||
code, output = doveadm_cmd(
|
||||
"user -f home %s" % self.full_address, **options
|
||||
)
|
||||
code, output = doveadm_cmd("user -f home %s" % self.full_address)
|
||||
if code:
|
||||
raise lib_exceptions.InternalError(
|
||||
_("Failed to retrieve mailbox location (%s)") % output)
|
||||
|
||||
@@ -49,9 +49,7 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
|
||||
|
||||
password_scheme = forms.ChoiceField(
|
||||
label=ugettext_lazy("Default password scheme"),
|
||||
choices=[(hasher.name, ugettext_lazy(hasher.label))
|
||||
for hasher in PasswordHasher.get_password_hashers()
|
||||
if hasher().scheme in get_dovecot_schemes()],
|
||||
choices=[],
|
||||
initial="sha512crypt",
|
||||
help_text=ugettext_lazy("Scheme used to crypt mailbox passwords"),
|
||||
)
|
||||
@@ -528,6 +526,11 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
|
||||
self._add_visibilty_rules(
|
||||
sms_backends.get_all_backend_visibility_rules()
|
||||
)
|
||||
self.fields["password_scheme"].choices = [
|
||||
(hasher.name, ugettext_lazy(hasher.label))
|
||||
for hasher in PasswordHasher.get_password_hashers()
|
||||
if hasher().scheme in get_dovecot_schemes()
|
||||
]
|
||||
|
||||
def _add_dynamic_fields(self):
|
||||
new_fields = OrderedDict()
|
||||
|
||||
@@ -212,6 +212,8 @@ SPECTACULAR_SETTINGS = {
|
||||
# List of supported schemes if doveadm is not available, given by: doveadm pw -l
|
||||
#DOVECOT_SUPPORTED_SCHEMES = 'SHA512-CRYPT SHA256-CRYPT'
|
||||
|
||||
# DOVECOT_USER = 'vmail'
|
||||
|
||||
MODOBOA_API_URL = 'https://api.modoboa.org/1/'
|
||||
|
||||
DISABLE_DASHBOARD_EXTERNAL_QUERIES = False
|
||||
|
||||
@@ -5,6 +5,7 @@ This module extra functions/shortcuts to communicate with the system
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import pwd
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
@@ -42,8 +43,7 @@ def exec_cmd(cmd, sudo_user=None, pinput=None, capture_output=True, **kwargs):
|
||||
return process.returncode, output
|
||||
|
||||
|
||||
def doveadm_cmd(params, sudo_user=None, pinput=None,
|
||||
capture_output=True, **kwargs):
|
||||
def doveadm_cmd(params, pinput=None, capture_output=True, **kwargs):
|
||||
"""Execute doveadm command.
|
||||
|
||||
Run doveadm command using the current user. Set :keyword:`sudo_user` if
|
||||
@@ -69,14 +69,17 @@ def doveadm_cmd(params, sudo_user=None, pinput=None,
|
||||
if os.path.isfile(fpath) and os.access(fpath, os.X_OK):
|
||||
dpath = fpath
|
||||
break
|
||||
dovecot_user = getattr(settings, "DOVECOT_USER", "vmail")
|
||||
curuser = pwd.getpwuid(os.getuid()).pw_name
|
||||
sudo_user = dovecot_user if curuser != dovecot_user else None
|
||||
if dpath:
|
||||
return exec_cmd("{} {}".format(dpath, params),
|
||||
sudo_user=sudo_user,
|
||||
pinput=pinput,
|
||||
capture_output=capture_output,
|
||||
**kwargs)
|
||||
else:
|
||||
raise OSError("doveadm command not found")
|
||||
|
||||
raise OSError("doveadm command not found")
|
||||
|
||||
|
||||
def guess_extension_name():
|
||||
|
||||
Reference in New Issue
Block a user