Compare commits

..

No commits in common. "880991984f50bee25cd7d5480744e064af73a5dc" and "49c63921b82c3690bb2c4cb6706b6e5c292448a2" have entirely different histories.

14 changed files with 32 additions and 83 deletions

6
.gitignore vendored
View File

@ -7,9 +7,3 @@
local_settings.py local_settings.py
build build
*.egg-info *.egg-info
/.Trash*
/.git
/.idea
.idea
.Trash-1000/

View File

@ -89,12 +89,20 @@ class MySQLUserController(ServiceController):
if user.type != user.MYSQL: if user.type != user.MYSQL:
return return
context = self.get_context(user) context = self.get_context(user)
if user.target_server.name != "mysql.pangea.lan":
self.append(textwrap.dedent("""\ self.append(textwrap.dedent("""\
# Create user %(username)s # Create user %(username)s
mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";' mysql -e 'CREATE USER IF NOT EXISTS "%(username)s"@"%(host)s";'
mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\ mysql -e 'ALTER USER IF EXISTS "%(username)s"@"%(host)s" IDENTIFIED BY PASSWORD "%(password)s";'\
""") % context """) % context
) )
else:
self.append(textwrap.dedent("""\
# Create user %(username)s
mysql -e 'CREATE USER "%(username)s"@"%(host)s";' || true # User already exists
mysql -e 'UPDATE mysql.user SET Password="%(password)s" WHERE User="%(username)s";'\
""") % context
)
def delete(self, user): def delete(self, user):
if user.type != user.MYSQL: if user.type != user.MYSQL:

View File

@ -58,12 +58,12 @@ class DatabaseForm(forms.ModelForm):
class DatabaseCreationForm(DatabaseUserCreationForm): class DatabaseCreationForm(DatabaseUserCreationForm):
username = forms.CharField(label=_("Username"), max_length=32, username = forms.CharField(label=_("Username"), max_length=16,
required=False, validators=[validators.validate_name], required=False, validators=[validators.validate_name],
help_text=_("Required. 32 characters or fewer. Letters, digits and " help_text=_("Required. 16 characters or fewer. Letters, digits and "
"@/./+/-/_ only."), "@/./+/-/_ only."),
error_messages={ error_messages={
'invalid': _("This value may contain 32 characters or fewer, only letters, numbers and " 'invalid': _("This value may contain 16 characters or fewer, only letters, numbers and "
"@/./+/-/_ characters.")}) "@/./+/-/_ characters.")})
user = forms.ModelChoiceField(required=False, queryset=DatabaseUser.objects) user = forms.ModelChoiceField(required=False, queryset=DatabaseUser.objects)

View File

@ -213,8 +213,6 @@ class MailboxAdmin(ChangePasswordAdminMixin, SelectAccountAdminMixin, ExtendedMo
old = Mailbox.objects.get(pk=obj.pk) old = Mailbox.objects.get(pk=obj.pk)
if old.custom_filtering != obj.custom_filtering: if old.custom_filtering != obj.custom_filtering:
messages.warning(request, msg) messages.warning(request, msg)
# pass var to the backend so you don't change the password
obj.changepass = None
elif obj.custom_filtering: elif obj.custom_filtering:
messages.warning(request, msg) messages.warning(request, msg)
super(MailboxAdmin, self).save_model(request, obj, form, change) super(MailboxAdmin, self).save_model(request, obj, form, change)

View File

@ -69,7 +69,6 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
self.append(textwrap.dedent(""" self.append(textwrap.dedent("""
# Update/create %(user)s user state # Update/create %(user)s user state
if id %(user)s ; then if id %(user)s ; then
if [[ "%(changepass)s" == "True" ]]; then
old_password=$(getent shadow %(user)s | cut -d':' -f2) old_password=$(getent shadow %(user)s | cut -d':' -f2)
usermod %(user)s \\ usermod %(user)s \\
--shell %(initial_shell)s \\ --shell %(initial_shell)s \\
@ -78,7 +77,6 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
# Postfix SASL caches passwords # Postfix SASL caches passwords
RESTART_POSTFIX=1 RESTART_POSTFIX=1
fi fi
fi
else else
useradd %(user)s \\ useradd %(user)s \\
--home %(home)s \\ --home %(home)s \\
@ -137,11 +135,6 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
super().commit() super().commit()
def get_context(self, mailbox): def get_context(self, mailbox):
# Check if you have to change password
try:
changepass = mailbox.changepass
except:
changepass = True
context = { context = {
'user': mailbox.name, 'user': mailbox.name,
'group': mailbox.name, 'group': mailbox.name,
@ -151,7 +144,6 @@ class UNIXUserMaildirController(SieveFilteringMixin, ServiceController):
'maildir': os.path.join(mailbox.get_home(), 'Maildir'), 'maildir': os.path.join(mailbox.get_home(), 'Maildir'),
'initial_shell': self.SHELL, 'initial_shell': self.SHELL,
'banner': self.get_banner(), 'banner': self.get_banner(),
'changepass': changepass,
} }
context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context context['deleted_home'] = settings.MAILBOXES_MOVE_ON_DELETE_PATH % context
return context return context

View File

@ -32,12 +32,7 @@ class Last(Aggregation):
verbose_name = _("Last value") verbose_name = _("Last value")
def filter(self, dataset, date=None): def filter(self, dataset, date=None):
dataset = dataset.order_by('object_id', '-id').distinct('monitor')
# dataset = dataset.order_by('object_id', '-id').distinct('monitor')
now = timezone.now()
epoch = now - datetime.timedelta(minutes=2)
dataset = dataset.filter( created_at__range=(epoch, now ))
if date is not None: if date is not None:
dataset = dataset.filter(created_at__lte=date) dataset = dataset.filter(created_at__lte=date)
return dataset return dataset

View File

@ -19,7 +19,7 @@ class NextCloudAPIMixin(object):
def validate_response(self, response): def validate_response(self, response):
request = response.request request = response.request
context = (request.method, response.url, request.body, response.status_code) 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: if response.status_code != requests.codes.ok:
raise RuntimeError("%s %s '%s' HTTP %s" % context) raise RuntimeError("%s %s '%s' HTTP %s" % context)
root = ET.fromstring(response.text) root = ET.fromstring(response.text)

View File

@ -700,6 +700,7 @@ class UNIXUserControllerNewServers(ServiceController):
def get_groups(self, user): def get_groups(self, user):
groups = [] groups = []
if user.is_main: if user.is_main:
groups = list(user.account.systemusers.exclude(username=user.username).values_list('username', flat=True))
groups.append("main-systemusers") groups.append("main-systemusers")
return groups return groups

View File

@ -11,7 +11,7 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
# migrations.swappable_dependency(settings.AUTH_USER_MODEL), migrations.swappable_dependency(settings.AUTH_USER_MODEL),
] ]
operations = [ 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')), ('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')), ('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')), ('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')), ('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')),
], ],
), ),

View File

@ -1,14 +0,0 @@
# Generated by Django 2.2.28 on 2023-11-26 09:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('systemusers', '0002_auto_20150429_1413_squashed_0004_auto_20210330_1049'),
('systemusers', '0004_auto_20230813_0920'),
]
operations = [
]

View File

@ -6,4 +6,5 @@ from orchestra.admin.utils import admin_date
display_last_run_at = admin_date('last_run_at', short_description=_("Last run")) 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')

View File

@ -25,6 +25,7 @@ class PluginForm(forms.ModelForm):
class PluginDataForm(PluginForm): class PluginDataForm(PluginForm):
data = forms.CharField(widget=forms.HiddenInput, required=False) data = forms.CharField(widget=forms.HiddenInput, required=False)
target_server = forms.ModelChoiceField(queryset=Server.objects.filter(name__in=WEB_SERVERS),)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -99,8 +100,6 @@ class ExtendedPluginDataForm(PluginDataForm):
widget=forms.PasswordInput, widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification.")) help_text=_("Enter the same password as above, for verification."))
target_server = forms.ModelChoiceField(queryset=Server.objects.filter(name__in=WEB_SERVERS),)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ExtendedPluginDataForm, self).__init__(*args, **kwargs) super(ExtendedPluginDataForm, self).__init__(*args, **kwargs)
self.fields['sftpuser'].widget = forms.HiddenInput() self.fields['sftpuser'].widget = forms.HiddenInput()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,25 +0,0 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="225.000000pt" height="225.000000pt" viewBox="0 0 225.000000 225.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,225.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1020 2240 c-441 -44 -804 -329 -953 -747 -80 -222 -80 -515 0 -736
117 -328 364 -574 690 -690 221 -80 515 -80 736 0 382 136 658 457 733 850 22
114 22 302 0 416 -75 393 -352 714 -733 850 -134 48 -328 72 -473 57z m237
-832 c59 -28 122 -90 147 -145 l18 -41 32 35 c99 114 273 87 337 -52 76 -163
-102 -341 -266 -266 -22 10 -54 34 -71 54 l-32 35 -18 -41 c-25 -56 -87 -117
-149 -147 -73 -35 -180 -34 -256 1 -64 30 -129 93 -154 149 l-17 38 -32 -35
c-99 -114 -273 -87 -337 52 -76 163 102 341 266 266 22 -10 54 -34 71 -54 l32
-35 17 38 c67 149 262 219 412 148z"/>
<path d="M1045 1294 c-126 -66 -142 -234 -30 -320 65 -49 170 -45 232 9 44 38
63 82 63 141 0 111 -75 186 -187 186 -26 0 -61 -7 -78 -16z"/>
<path d="M590 1180 c-12 -12 -20 -33 -20 -55 0 -45 29 -75 73 -75 51 0 77 24
77 71 0 50 -27 79 -75 79 -22 0 -43 -8 -55 -20z"/>
<path d="M1550 1182 c-16 -13 -22 -29 -22 -57 0 -48 28 -75 78 -75 45 0 74 30
74 75 0 45 -29 75 -74 75 -19 0 -44 -8 -56 -18z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB