From 7b4ea6895c232f28708edbe25b27587b9748bb71dafe7c3e1db837161c621d46 Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Tue, 29 Sep 2020 07:54:08 +0000 Subject: [PATCH 1/3] Accepting request 837918 from home:gladiac:mailman3 - Create mailman user and group - Create directories for mailman and use FHS directory layout - Create initial /etc/mailman.cfg - Create /etc/mailman.d/ directory for extensions - Add systemd files OBS-URL: https://build.opensuse.org/request/show/837918 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-mailman?expand=0&rev=27 --- README.SUSE.md | 15 ++++++++ mailman-digests.service | 8 ++++ mailman-digests.timer | 10 +++++ mailman-tmpfiles.conf | 2 + mailman.cfg | 26 +++++++++++++ mailman.logrotate | 9 +++++ mailman.service | 25 ++++++++++++ python-mailman.changes | 9 +++++ python-mailman.spec | 84 ++++++++++++++++++++++++++++++++++++++++- 9 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 README.SUSE.md create mode 100644 mailman-digests.service create mode 100644 mailman-digests.timer create mode 100644 mailman-tmpfiles.conf create mode 100644 mailman.cfg create mode 100644 mailman.logrotate create mode 100644 mailman.service diff --git a/README.SUSE.md b/README.SUSE.md new file mode 100644 index 0000000..8642510 --- /dev/null +++ b/README.SUSE.md @@ -0,0 +1,15 @@ +Mailman on SUSE +=============== + +To run the mailman command use: + + sudo -u mailman mailman info + +## Configuration + +The main config file can be found at `/etc/mailman.cfg`. It is important to add +new sections only below the [path.fhs] section! + +## Plugins + +The directory for mailman plugins is `/etc/mailman.d`. diff --git a/mailman-digests.service b/mailman-digests.service new file mode 100644 index 0000000..dacf6ee --- /dev/null +++ b/mailman-digests.service @@ -0,0 +1,8 @@ +[Unit] +Description=Sends Mailman digests + +[Service] +Type=oneshot +ExecStart=/usr/bin/mailman digests --send +User=mailman +Group=mailman diff --git a/mailman-digests.timer b/mailman-digests.timer new file mode 100644 index 0000000..774a3ce --- /dev/null +++ b/mailman-digests.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Run mailman-digests.service every day + +[Timer] +OnCalendar=*-*-* 04:00:00 +RandomizedDelaySec=3600 +Persistent=true + +[Install] +WantedBy=basic.target diff --git a/mailman-tmpfiles.conf b/mailman-tmpfiles.conf new file mode 100644 index 0000000..5f07e0d --- /dev/null +++ b/mailman-tmpfiles.conf @@ -0,0 +1,2 @@ +d /run/lock/mailman 0755 mailman mailman +d /run/mailman 0755 mailman mailman diff --git a/mailman.cfg b/mailman.cfg new file mode 100644 index 0000000..7e9ab52 --- /dev/null +++ b/mailman.cfg @@ -0,0 +1,26 @@ +# This is the absolute bare minimum base configuration file. User supplied +# configurations are pushed onto this. + +[mailman] +# This address is the "site owner" address. Certain messages which must be +# delivered to a human, but which can't be delivered to a list owner (e.g. a +# bounce from a list owner), will be sent to this address. It should point to +# a human. +site_owner: root@localhost + +# Set the paths to be fhs compliant +layout: fhs +[paths.fhs] +ext_dir: /etc/mailman.d +bin_dir: /usr/bin +var_dir: /var/lib/mailman +queue_dir: /var/spool/mailman +log_dir: /var/log/mailman +lock_dir: /run/lock/mailman +pid_file: /run/mailman/master.pid + +### ADD NEW SECTIONS AFTER THIS LINE ### + +# [webservice] +# admin_user: restadmin +# admin_pass: secret diff --git a/mailman.logrotate b/mailman.logrotate new file mode 100644 index 0000000..dfcc44f --- /dev/null +++ b/mailman.logrotate @@ -0,0 +1,9 @@ +@LOGDIR@/*.log { + missingok + sharedscripts + su mailman mailman + postrotate + /bin/kill -HUP $(/dev/null || true + @BINDIR@/mailman reopen >/dev/null 2>&1 || true + endscript +} diff --git a/mailman.service b/mailman.service new file mode 100644 index 0000000..d7d8435 --- /dev/null +++ b/mailman.service @@ -0,0 +1,25 @@ +# It's not recommended to modify this file in-place, because it will be +# overwritten during package upgrades. If you want to customize, the +# best way is to create a file "/etc/systemd/system/mailman3.service", +# containing +# .include /usr/lib/systemd/system/mailman3.service +# ...make your changes here... +# For more info about custom unit files, see +# http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F + + +[Unit] +Description=GNU Mailing List Manager +After=syslog.target network.target + +[Service] +Type=forking +PIDFile=/run/mailman/master.pid +User=mailman +Group=mailman +ExecStart=/usr/bin/mailman start --force +ExecReload=/usr/bin/mailman restart +ExecStop=/usr/bin/mailman stop + +[Install] +WantedBy=multi-user.target diff --git a/python-mailman.changes b/python-mailman.changes index be635a1..60d63d5 100644 --- a/python-mailman.changes +++ b/python-mailman.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Sat Sep 26 10:38:00 UTC 2020 - Andreas Schneider + +- Create mailman user and group +- Create directories for mailman and use FHS directory layout +- Create initial /etc/mailman.cfg +- Create /etc/mailman.d/ directory for extensions +- Add systemd files + ------------------------------------------------------------------- Mon May 25 06:50:41 UTC 2020 - Petr Gajdos diff --git a/python-mailman.spec b/python-mailman.spec index 9e055a0..5961134 100644 --- a/python-mailman.spec +++ b/python-mailman.spec @@ -16,6 +16,16 @@ # +%define mailman_user mailman +%define mailman_group mailman +%define mailman_name mailman +%define mailman_homedir %{_localstatedir}/lib/%{mailman_name} +%define mailman_logdir %{_localstatedir}/log/%{mailman_name} +%define mailman_spooldir %{_localstatedir}/spool/%{mailman_name} + +%define mailman_rundir %{_rundir}/%{mailman_name} +%define mailman_lockdir %{_rundir}/lock/%{mailman_name} + %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define psuffix -test @@ -32,7 +42,18 @@ Release: 0 Summary: Mailman -- the GNU mailing list manager License: GPL-3.0-only URL: https://www.list.org -Source: https://files.pythonhosted.org/packages/source/m/mailman/mailman-%{version}.tar.gz +Source0: https://files.pythonhosted.org/packages/source/m/mailman/mailman-%{version}.tar.gz +# +Source10: mailman.cfg +Source11: mailman.service +Source12: mailman-tmpfiles.conf +Source13: mailman.logrotate +# +Source20: mailman-digests.service +Source21: mailman-digests.timer +# +Source30: README.SUSE.md +# Source100: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_cert.crt Source101: https://gitlab.com/mailman/mailman/-/raw/master/src/mailman/testing/ssl_test_key.key # whitespace fix @@ -40,6 +61,8 @@ Patch0: python-mailman-test_interact_default_banner.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros +BuildRequires: systemd +%{?systemd_requires} Requires: python-SQLAlchemy >= 1.2.3 Requires: python-aiosmtpd >= 1.1 Requires: python-alembic @@ -108,6 +131,7 @@ Mailman -- the GNU mailing list manager # https://gitlab.com/mailman/mailman/-/issues/704 cp %{SOURCE100} src/mailman/testing/ cp %{SOURCE101} src/mailman/testing/ +cp %{SOURCE30} . %build sed -i 's:/sbin:%{_prefix}/bin:' src/mailman/config/mailman.cfg @@ -130,6 +154,29 @@ sed '/importlib_resources/d' -i src/mailman.egg-info/requires.txt setup.py %python_clone -a %{buildroot}%{_bindir}/mailman %python_clone -a %{buildroot}%{_bindir}/runner %python_expand %fdupes %{buildroot}%{$python_sitelib} + +install -d -m 0755 \ + %{buildroot}%{_sysconfdir} \ + %{buildroot}%{_sysconfdir}/logrotate.d \ + %{buildroot}%{_sysconfdir}/%{mailman_name}.d \ + %{buildroot}%{_tmpfilesdir} \ + %{buildroot}%{_unitdir} \ + %{buildroot}%{mailman_homedir} \ + %{buildroot}%{mailman_homedir}/data \ + %{buildroot}%{mailman_rundir} \ + %{buildroot}%{mailman_lockdir} \ + %{buildroot}%{mailman_logdir} \ + %{buildroot}%{mailman_spooldir} + +install -m 0640 %{SOURCE10} %{buildroot}%{_sysconfdir}/%{mailman_name}.cfg +install -m 0644 %{SOURCE11} %{buildroot}%{_unitdir}/%{mailman_name}.service +install -m 0644 %{SOURCE12} %{buildroot}%{_tmpfilesdir}/%{mailman_name}.conf +install -m 0644 %{SOURCE13} %{buildroot}%{_sysconfdir}/logrotate.d/%{mailman_name} +sed -i 's,@LOGDIR@,%{mailman_logdir},g;s,@BINDIR@,%{_bindir},g' \ + %{buildroot}%{_sysconfdir}/logrotate.d/%{mailman_name} + +install -m 0644 %{SOURCE20} %{buildroot}%{_unitdir}/%{mailman_name}-digests.service +install -m 0644 %{SOURCE21} %{buildroot}%{_unitdir}/%{mailman_name}-digests.timer %endif %check @@ -157,23 +204,56 @@ sed -i "s:\(902\):4\1:" src/mailman/testing/testing.cfg %endif %if !%{with test} +%pre +getent group %{mailman_group} >/dev/null || \ + %{_sbindir}/groupadd -r %{mailman_group} +getent passwd %{mailman_user} >/dev/null || \ + %{_sbindir}/useradd -r -g %{mailman_group} -s /sbin/nologin \ + -c "mailman daemon user" -d %{mailman_homedir} %{mailman_user} +%{_sbindir}/usermod -g %{mailman_group} %{mailman_user} >/dev/null +%service_add_pre %{mailman_name}.service + %post %python_install_alternative master %python_install_alternative mailman %python_install_alternative runner +%tmpfiles_create %{_tmpfilesdir}/%{mailman_name}.conf +%service_add_post %{mailman_name}.service + +%preun +%service_del_preun %{mailman_name}.service %postun +%service_del_postun %{mailman_name}.service %python_uninstall_alternative master %python_uninstall_alternative mailman %python_uninstall_alternative runner %files %{python_files} -%doc README.rst +%doc README.rst README.SUSE.md %license COPYING %python_alternative %{_bindir}/runner %python_alternative %{_bindir}/mailman %python_alternative %{_bindir}/master %{python_sitelib}/* + +%{_unitdir}/%{mailman_name}.service +%{_unitdir}/%{mailman_name}-digests.service +%{_unitdir}/%{mailman_name}-digests.timer +%{_tmpfilesdir}/%{mailman_name}.conf + +%config(noreplace) %attr(640,root,mailman) %{_sysconfdir}/mailman.cfg +%config(noreplace) %{_sysconfdir}/logrotate.d/%{mailman_name} + +%dir %attr(750,root,mailman) %{_sysconfdir}/%{mailman_name}.d + +%dir %attr(750,mailman,mailman) %{mailman_homedir} +%dir %attr(2750,mailman,mailman) %{mailman_homedir}/data +%dir %attr(750,mailman,mailman) %{mailman_spooldir} +%dir %attr(750,mailman,mailman) %{mailman_logdir} +%ghost %dir %{mailman_rundir} +%ghost %dir %{_rundir}/lock +%ghost %dir %{mailman_lockdir} %endif %changelog From 114760fc69b6dbf8513c2e7799e47a84ef3d02d292597444492e7bd4a05e4316 Mon Sep 17 00:00:00 2001 From: Petr Gajdos Date: Wed, 30 Sep 2020 07:19:11 +0000 Subject: [PATCH 2/3] - remove systemd (build)requires OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-mailman?expand=0&rev=28 --- python-mailman.changes | 5 +++++ python-mailman.spec | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python-mailman.changes b/python-mailman.changes index 60d63d5..363e3f3 100644 --- a/python-mailman.changes +++ b/python-mailman.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Sep 30 07:18:40 UTC 2020 - pgajdos@suse.com + +- remove systemd (build)requires + ------------------------------------------------------------------- Sat Sep 26 10:38:00 UTC 2020 - Andreas Schneider diff --git a/python-mailman.spec b/python-mailman.spec index 5961134..9716924 100644 --- a/python-mailman.spec +++ b/python-mailman.spec @@ -61,8 +61,6 @@ Patch0: python-mailman-test_interact_default_banner.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros -BuildRequires: systemd -%{?systemd_requires} Requires: python-SQLAlchemy >= 1.2.3 Requires: python-aiosmtpd >= 1.1 Requires: python-alembic From 715101f14847268ea81796d778c7fd39e22dbeab79f9d6e5f40708bd56d82080 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 8 Oct 2020 10:15:35 +0000 Subject: [PATCH 3/3] Accepting request 839919 from home:gladiac:mailman3 - Remove suid bit from /var/lib/mailman/data OBS-URL: https://build.opensuse.org/request/show/839919 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:mailman/python-mailman?expand=0&rev=29 --- python-mailman.changes | 5 +++++ python-mailman.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/python-mailman.changes b/python-mailman.changes index 363e3f3..3ca5cfa 100644 --- a/python-mailman.changes +++ b/python-mailman.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Oct 7 05:46:29 UTC 2020 - Andreas Schneider + +- Remove suid bit from /var/lib/mailman/data + ------------------------------------------------------------------- Wed Sep 30 07:18:40 UTC 2020 - pgajdos@suse.com diff --git a/python-mailman.spec b/python-mailman.spec index 9716924..cf6014e 100644 --- a/python-mailman.spec +++ b/python-mailman.spec @@ -246,7 +246,7 @@ getent passwd %{mailman_user} >/dev/null || \ %dir %attr(750,root,mailman) %{_sysconfdir}/%{mailman_name}.d %dir %attr(750,mailman,mailman) %{mailman_homedir} -%dir %attr(2750,mailman,mailman) %{mailman_homedir}/data +%dir %attr(750,mailman,mailman) %{mailman_homedir}/data %dir %attr(750,mailman,mailman) %{mailman_spooldir} %dir %attr(750,mailman,mailman) %{mailman_logdir} %ghost %dir %{mailman_rundir}