Skip to content
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

Open
wants to merge 1 commit into
base: 4.4-0
Choose a base branch
from

Conversation

castens
Copy link
Contributor

@castens castens commented Apr 10, 2019

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

  • What kind of change does this PR introduce? (Bugfix, feature, documentation update, cleanup, security issue, performance enhancement)
  • How can we reproduce the issue? (Which environment? Is there a test case? Which commands need to be executed? Which UMC modules are involed?)
  • To which UCS version does the issue apply?
  • Please list relevant screenshots, error messages, logs or tracebacks (If not already in the bugzilla)
  • Are there any breaking or API changes? (if so, please describe them)
  • Are there changes in the documentation necessary?
  • Are there descriptions for newly introduced UCR variables?

@CLAassistant
Copy link

CLAassistant commented Apr 10, 2019

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.


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"]
Copy link
Collaborator

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"])
Copy link
Collaborator

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()
Copy link
Collaborator

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]))
Copy link
Collaborator

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):
Copy link
Collaborator

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
Copy link
Collaborator

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/
Copy link
Collaborator

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/>.
Copy link
Collaborator

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"])
Copy link
Collaborator

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"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Use systemctl try-reload-or-restart … as the service might not exists or currently is not running
  2. spamassass.service should be added (to the same call as systemctl can restart multiple services with one call).

pmhahn pushed a commit that referenced this pull request Dec 15, 2022
pmhahn pushed a commit that referenced this pull request Feb 13, 2023
pmhahn pushed a commit that referenced this pull request May 26, 2023
univention/dist/ucs-ec2-tools#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants