-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug #49274: Added check for spamassassin rules #11
base: 4.4-0
Are you sure you want to change the base?
Conversation
|
|
||
from univention.lib.i18n import Translation | ||
_ = Translation('univention-management-console-module-diagnostic').translate | ||
run_descr = ["Trying to authenticate with machine password against LDAP Similar to running: univention-ldapsearch -LLLs base dn"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a copy-pasted-text from the check used as a template for this new check. This must be updated.
except subprocess.CalledProcessError: | ||
raise Success('Spamassassin is not installed') | ||
|
||
sa_version = subprocess.check_output(["spamassassin", "-V"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple blanks here → pep8
Also use
perl -M'Mail::SpamAssassin' -e 'print($Mail::SpamAssassin::VERSION);'
to get the version in the right format, so you can remove the following 3 lines to parse and format the version number.
'label': 'update spamassassin rules' | ||
}] | ||
raise Critical('spamassassin rules could not be found', buttons=buttons) | ||
if retest: raise ProblemFixed() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line-break please
sa_version = subprocess.check_output(["spamassassin", "-V"]) | ||
sa_version = sa_version.split()[2] | ||
sa_version = sa_version.split('.') | ||
folder_name = '%s.%03d%03d' % (int(sa_version[0]), int(sa_version[1]), int(sa_version[2])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe build the complete path here once, e.g.
folder_path = "/var/lib/spamassassin/%s.%03d%03d" % (…)
and use it below both times,
sa_version = sa_version.split()[2] | ||
sa_version = sa_version.split('.') | ||
folder_name = '%s.%03d%03d' % (int(sa_version[0]), int(sa_version[1]), int(sa_version[2])) | ||
if not os.path.exists("/var/lib/spamassassin/"+folder_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concatenating strings with +
is considered bad style in Python. See comment above.
# Univention Management Console module: | ||
# System Diagnosis UMC module | ||
# | ||
# Copyright 2016-2019 Univention GmbH |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only 2019-2020
# | ||
# Copyright 2016-2019 Univention GmbH | ||
# | ||
# http://www.univention.de/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://
# You should have received a copy of the GNU Affero General Public | ||
# License with the Debian GNU/Linux or Univention distribution in file | ||
# /usr/share/common-licenses/AGPL-3; if not, see | ||
# <http://www.gnu.org/licenses/>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://
def run(_umc_instance, retest=False): | ||
buttons = [] | ||
try: | ||
subprocess.check_call(["dpkg", "-s", "spamassassin"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use dpkg-query -W spamassassin
here please.
|
||
def update_and_restart(umc_instance): | ||
subprocess.check_call(["sa-update"]) | ||
subprocess.check_call(["systemctl", "restart", "amavis.service"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use
systemctl try-reload-or-restart …
as the service might not exists or currently is not running spamassass.service
should be added (to the same call assystemctl
can restart multiple services with one call).
univention/dist/ucs-ec2-tools#11
Thank you for providing a pull request!
Please make sure you considered the following things
Link to the issue in Bugzilla
https://forge.univention.org/bugzilla/show_bug.cgi?id=49274
Description of the changes
Added check for spamassassin rules