diff --git a/.gitignore b/.gitignore index 0bca9ea5..c6d1a57c 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ local_settings.py build *.egg-info +/.Trash* +/.git +/.idea diff --git a/orchestra/contrib/databases/forms.py b/orchestra/contrib/databases/forms.py index f35f00c7..cba56642 100644 --- a/orchestra/contrib/databases/forms.py +++ b/orchestra/contrib/databases/forms.py @@ -58,12 +58,12 @@ class DatabaseForm(forms.ModelForm): class DatabaseCreationForm(DatabaseUserCreationForm): - username = forms.CharField(label=_("Username"), max_length=16, + username = forms.CharField(label=_("Username"), max_length=32, required=False, validators=[validators.validate_name], - help_text=_("Required. 16 characters or fewer. Letters, digits and " + help_text=_("Required. 32 characters or fewer. Letters, digits and " "@/./+/-/_ only."), error_messages={ - 'invalid': _("This value may contain 16 characters or fewer, only letters, numbers and " + 'invalid': _("This value may contain 32 characters or fewer, only letters, numbers and " "@/./+/-/_ characters.")}) user = forms.ModelChoiceField(required=False, queryset=DatabaseUser.objects) diff --git a/orchestra/contrib/mailboxes/admin.py b/orchestra/contrib/mailboxes/admin.py index 09924dd6..5315a86c 100644 --- a/orchestra/contrib/mailboxes/admin.py +++ b/orchestra/contrib/mailboxes/admin.py @@ -213,6 +213,8 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo old = Mailbox.objects.get(pk=obj.pk) if old.custom_filtering != obj.custom_filtering: messages.warning(request, msg) + # pass var to the backend so you don't change the password + obj.changepass = None elif obj.custom_filtering: messages.warning(request, msg) super(MailboxAdmin, self).save_model(request, obj, form, change) diff --git a/orchestra/contrib/mailboxes/backends.py b/orchestra/contrib/mailboxes/backends.py index c15c42fb..8de35114 100644 --- a/orchestra/contrib/mailboxes/backends.py +++ b/orchestra/contrib/mailboxes/backends.py @@ -69,13 +69,15 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController): self.append(textwrap.dedent(""" # Update/create %(user)s user state if id %(user)s ; then - old_password=$(getent shadow %(user)s | cut -d':' -f2) - usermod %(user)s \\ - --shell %(initial_shell)s \\ - --password '%(password)s' - if [[ "$old_password" != '%(password)s' ]]; then - # Postfix SASL caches passwords - RESTART_POSTFIX=1 + if [[ "%(changepass)s" == "True" ]]; then + old_password=$(getent shadow %(user)s | cut -d':' -f2) + usermod %(user)s \\ + --shell %(initial_shell)s \\ + --password '%(password)s' + if [[ "$old_password" != '%(password)s' ]]; then + # Postfix SASL caches passwords + RESTART_POSTFIX=1 + fi fi else useradd %(user)s \\ @@ -135,6 +137,11 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController): super().commit() def get_context(self, mailbox): + # Check if you have to change password + try: + changepass = mailbox.changepass + except: + changepass = True context = { 'user': mailbox.name, 'group': mailbox.name, @@ -144,6 +151,7 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController): 'maildir': os.path.join(mailbox.get_home(), 'Maildir'), 'initial_shell': self.SHELL, 'banner': self.get_banner(), + 'changepass': changepass, } context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context return context diff --git a/orchestra/contrib/saas/backends/nextcloud.py b/orchestra/contrib/saas/backends/nextcloud.py index 17df098f..3c3ef0a1 100644 --- a/orchestra/contrib/saas/backends/nextcloud.py +++ b/orchestra/contrib/saas/backends/nextcloud.py @@ -19,7 +19,7 @@ class NextCloudAPIMixin(object): def validate_response(self, response): request = response.request context = (request.method, response.url, request.body, response.status_code) - sys.stderr.write("%s %s '%s' HTTP %s\n" % context) + # sys.stderr.write("%s %s '%s' HTTP %s\n" % context) if response.status_code != requests.codes.ok: raise RuntimeError("%s %s '%s' HTTP %s" % context) root = ET.fromstring(response.text) diff --git a/orchestra/contrib/systemusers/migrations/0001_initial.py b/orchestra/contrib/systemusers/migrations/0001_initial.py index 30ea85fe..5cd524ff 100644 --- a/orchestra/contrib/systemusers/migrations/0001_initial.py +++ b/orchestra/contrib/systemusers/migrations/0001_initial.py @@ -11,7 +11,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), + # migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ @@ -25,7 +25,7 @@ class Migration(migrations.Migration): ('directory', models.CharField(blank=True, help_text="Optional directory relative to user's home.", max_length=256, verbose_name='directory')), ('shell', models.CharField(choices=[('/dev/null', 'No shell, FTP only'), ('/bin/rssh', 'No shell, SFTP/RSYNC only'), ('/usr/bin/git-shell', 'No shell, GIT only'), ('/bin/bash', '/bin/bash')], default='/dev/null', max_length=32, verbose_name='shell')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this account should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), - ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='systemusers', to=settings.AUTH_USER_MODEL, verbose_name='Account')), + # ('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='systemusers', to=settings.AUTH_USER_MODEL, verbose_name='Account')), ('groups', models.ManyToManyField(blank=True, help_text='A new group will be created for the user. Which additional groups would you like them to be a member of?', to='systemusers.SystemUser')), ], ), diff --git a/orchestra/contrib/tasks/admin.py b/orchestra/contrib/tasks/admin.py index d245a5f6..878c71f5 100644 --- a/orchestra/contrib/tasks/admin.py +++ b/orchestra/contrib/tasks/admin.py @@ -6,5 +6,4 @@ from orchestra.admin.utils import admin_date display_last_run_at = admin_date('last_run_at', short_description=_("Last run")) - -PeriodicTaskAdmin.list_display = ('__unicode__', display_last_run_at, 'total_run_count', 'enabled') +PeriodicTaskAdmin.list_display = ('__unicode__', display_last_run_at, 'total_run_count', 'enabled') \ No newline at end of file