Skip to content

Commit

Permalink
Merge pull request #5 from modoboa/simpler-file-check
Browse files Browse the repository at this point in the history
Few fixes, locals, simpler file checking
  • Loading branch information
tonioo authored Sep 12, 2023
2 parents 15f6932 + ac0c6dc commit 02b8e75
Show file tree
Hide file tree
Showing 36 changed files with 1,854 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var/
.installed.cfg
*.egg
*.eggs
test_project/sitestatic/*

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -54,3 +55,4 @@ docs/_build/
# PyBuilder
target/
test_project/modoboa.sql
*.kdev4
19 changes: 6 additions & 13 deletions modoboa_rspamd/api/v2/serializers.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
"""Modoboa rspamd serializer for api v2."""

import os

from django.utils.translation import gettext_lazy as _

from rest_framework import serializers

from modoboa_rspamd import handlers


def validate_file_path(value):
if value:
if os.path.isdir(value):
raise serializers.ValidationError(
_("Path provided is a directory")
)
condition = (os.path.exists(value) and os.access(value))\
or\
(not os.path.exists(value) and os.access(os.path.dirname(value),
os.W_OK))
if not condition:
if not os.path.isabs(value):
# We only check if it is absolute,
# since it shouldn't be accessible to modoboa user.
# Only to _rspamd
raise serializers.ValidationError(
_("File or directory is not writable")
_("Path provided is not absolute.")
)


class RspamdSettingsSerializer(serializers.Serializer):
"""A serializer for global parameters."""

Expand Down
3 changes: 2 additions & 1 deletion modoboa_rspamd/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ def update_rspamd_dkim_maps(sender, instance, created, **kwargs):
"""Update config maps."""
# Modify or create
condition = (instance._loaded_values.get("dkim_private_key_path") != instance.dkim_private_key_path or
instance._loaded_values.get("dkim_key_selector") != instance.dkim_key_selector
instance._loaded_values.get("dkim_key_selector") != instance.dkim_key_selector or
instance._loaded_values.get("enable_dkim") != instance.enable_dkim
)
if condition:
queue = django_rq.get_queue('dkim')
Expand Down
62 changes: 62 additions & 0 deletions modoboa_rspamd/locale/br/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-11 17:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=5; plural=((n%10 == 1) && (n%100 != 11) && (n%100 !"
"=71) && (n%100 !=91) ? 0 :(n%10 == 2) && (n%100 != 12) && (n%100 !=72) && (n"
"%100 !=92) ? 1 :(n%10 ==3 || n%10==4 || n%10==9) && (n%100 < 10 || n% 100 > "
"19) && (n%100 < 70 || n%100 > 79) && (n%100 < 90 || n%100 > 99) ? 2 :(n != 0 "
"&& n % 1000000 == 0) ? 3 : 4);\n"
#: api/v2/serializers.py:17
msgid "Path provided is not absolute."
msgstr ""

#: app_settings.py:15 app_settings.py:42
msgid "DKIM signing settings"
msgstr ""

#: app_settings.py:18 app_settings.py:45
msgid "Key map path"
msgstr ""

#: app_settings.py:20 app_settings.py:48
msgid ""
"Absolute path of the file which contains paths to DKIM private keys. Must be "
"readable by _rspamd group or user."
msgstr ""

#: app_settings.py:25 app_settings.py:55
msgid "Selector map path"
msgstr ""

#: app_settings.py:27 app_settings.py:58
msgid ""
"Absolute path of the file which contains names of DKIM selectors. Must be "
"readable by _rspamd group or user."
msgstr ""

#: apps.py:19 apps.py:21
msgid "Rspamd"
msgstr ""

#: modo_extension.py:19
msgid "Rspamd frontend"
msgstr ""

#: modo_extension.py:20
msgid "Rspamd management frontend"
msgstr ""
59 changes: 59 additions & 0 deletions modoboa_rspamd/locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-11 17:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n "
"<= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
#: api/v2/serializers.py:17
msgid "Path provided is not absolute."
msgstr ""

#: app_settings.py:15 app_settings.py:42
msgid "DKIM signing settings"
msgstr ""

#: app_settings.py:18 app_settings.py:45
msgid "Key map path"
msgstr ""

#: app_settings.py:20 app_settings.py:48
msgid ""
"Absolute path of the file which contains paths to DKIM private keys. Must be "
"readable by _rspamd group or user."
msgstr ""

#: app_settings.py:25 app_settings.py:55
msgid "Selector map path"
msgstr ""

#: app_settings.py:27 app_settings.py:58
msgid ""
"Absolute path of the file which contains names of DKIM selectors. Must be "
"readable by _rspamd group or user."
msgstr ""

#: apps.py:19 apps.py:21
msgid "Rspamd"
msgstr ""

#: modo_extension.py:19
msgid "Rspamd frontend"
msgstr ""

#: modo_extension.py:20
msgid "Rspamd management frontend"
msgstr ""
58 changes: 58 additions & 0 deletions modoboa_rspamd/locale/cs_CZ/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-11 17:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: api/v2/serializers.py:17
msgid "Path provided is not absolute."
msgstr ""

#: app_settings.py:15 app_settings.py:42
msgid "DKIM signing settings"
msgstr ""

#: app_settings.py:18 app_settings.py:45
msgid "Key map path"
msgstr ""

#: app_settings.py:20 app_settings.py:48
msgid ""
"Absolute path of the file which contains paths to DKIM private keys. Must be "
"readable by _rspamd group or user."
msgstr ""

#: app_settings.py:25 app_settings.py:55
msgid "Selector map path"
msgstr ""

#: app_settings.py:27 app_settings.py:58
msgid ""
"Absolute path of the file which contains names of DKIM selectors. Must be "
"readable by _rspamd group or user."
msgstr ""

#: apps.py:19 apps.py:21
msgid "Rspamd"
msgstr ""

#: modo_extension.py:19
msgid "Rspamd frontend"
msgstr ""

#: modo_extension.py:20
msgid "Rspamd management frontend"
msgstr ""
58 changes: 58 additions & 0 deletions modoboa_rspamd/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-11 17:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: api/v2/serializers.py:17
msgid "Path provided is not absolute."
msgstr ""

#: app_settings.py:15 app_settings.py:42
msgid "DKIM signing settings"
msgstr ""

#: app_settings.py:18 app_settings.py:45
msgid "Key map path"
msgstr ""

#: app_settings.py:20 app_settings.py:48
msgid ""
"Absolute path of the file which contains paths to DKIM private keys. Must be "
"readable by _rspamd group or user."
msgstr ""

#: app_settings.py:25 app_settings.py:55
msgid "Selector map path"
msgstr ""

#: app_settings.py:27 app_settings.py:58
msgid ""
"Absolute path of the file which contains names of DKIM selectors. Must be "
"readable by _rspamd group or user."
msgstr ""

#: apps.py:19 apps.py:21
msgid "Rspamd"
msgstr ""

#: modo_extension.py:19
msgid "Rspamd frontend"
msgstr ""

#: modo_extension.py:20
msgid "Rspamd management frontend"
msgstr ""
58 changes: 58 additions & 0 deletions modoboa_rspamd/locale/de_DE/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-11 17:55+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

#: api/v2/serializers.py:17
msgid "Path provided is not absolute."
msgstr ""

#: app_settings.py:15 app_settings.py:42
msgid "DKIM signing settings"
msgstr ""

#: app_settings.py:18 app_settings.py:45
msgid "Key map path"
msgstr ""

#: app_settings.py:20 app_settings.py:48
msgid ""
"Absolute path of the file which contains paths to DKIM private keys. Must be "
"readable by _rspamd group or user."
msgstr ""

#: app_settings.py:25 app_settings.py:55
msgid "Selector map path"
msgstr ""

#: app_settings.py:27 app_settings.py:58
msgid ""
"Absolute path of the file which contains names of DKIM selectors. Must be "
"readable by _rspamd group or user."
msgstr ""

#: apps.py:19 apps.py:21
msgid "Rspamd"
msgstr ""

#: modo_extension.py:19
msgid "Rspamd frontend"
msgstr ""

#: modo_extension.py:20
msgid "Rspamd management frontend"
msgstr ""
Loading

0 comments on commit 02b8e75

Please sign in to comment.