Bug 194862 - net-mail/mailman/mailman-2.1.9-r2 - make mailman user configurable
Bug#: 194862 Product:  Gentoo Linux Version: unspecified Platform: x86
OS/Version: Linux Status: RESOLVED Severity: enhancement Priority: P5
Resolution: FIXED Assigned To: hanno@gentoo.org Reported By: sebastian@nanofortnight.org
Component: Ebuilds
URL: 
Summary: net-mail/mailman/mailman-2.1.9-r2 - make mailman user configurable
Keywords:  
Status Whiteboard: 
Opened: 2007-10-05 23:42 0000
Description:   Opened: 2007-10-05 23:42 0000
Is it possible to change the user "mailman" to a variable like we did it for
VAR_PREFIX, CGIGID and MAILGID, too?
Because we would like to change VAR_PREFIX to a home directory of another user
and then it would be great that portage doesn't create another mailman user.
I have got a test installation and it works great.

If you accept my suggestion, it would be necessary to change files/mailman.rc 
You can easily change to the new mailman user, but then please use the full
path in the ebuild.


Another point is the line 67 in /usr/lib/mailman/bin/qmail-to-mailman.py:
"local = re.sub("^mailman-","",local)"
You strip there only the mailman user, but if we've change to another user than
mailman it would be better to use:
"local = re.sub("^" + os.environ['USER'] + "-","",local)"


Hanno, thanks a lot for your help. :-)
If you've got any questions feel free to ask me.


With the changes above it works for me very well.

Reproducible: Always

------- Comment #1 From Michael Hanselmann (hansmi) (RETIRED) 2007-10-06 08:56:50 0000 -------
(In reply to comment #0)
> Another point is the line 67 in /usr/lib/mailman/bin/qmail-to-mailman.py:
> "local = re.sub("^mailman-","",local)"
> You strip there only the mailman user, but if we've change to another user than
> mailman it would be better to use:
> "local = re.sub("^" + os.environ['USER'] + "-","",local)"

This creates a potential security problem. Please use
re.escape(os.environ["USER"]) at least.

------- Comment #2 From Sebastian Wieseler 2007-10-22 14:05:37 0000 -------
--- mailman-2.1.9-r2.ebuild     2007-10-22 10:10:22.000000000 +0000
+++ mailman-2.1.9-r100.ebuild   2007-10-22 14:03:58.000000000 +0000
@@ -22,15 +22,17 @@
        INSTALLDIR=${MAILMAN_PREFIX:-"/usr/lib/mailman"}
        VAR_PREFIX=${MAILMAN_VAR_PREFIX:-"/var/lib/mailman"}
        CGIGID=${MAILMAN_CGIGID:-81}
-       MAILGID=${MAILMAN_MAILGID:-280}
        MAILUSR=${MAILMAN_MAILUSR:-mailman}
        MAILUID=${MAILMAN_MAILUID:-280}
+       MAILGRP=${MAILMAN_MAILGRP:mailman}
+       MAILGID=${MAILMAN_MAILGID:-280}
+

        # Bug #58526: switch to enew{group,user}.
        # need to add mailman here for compile process.
        # Duplicated at pkg_postinst() for binary install.
-       enewgroup mailman 280
-       enewuser ${MAILUSR} ${MAILUID} /bin/bash ${INSTALLDIR} mailman -G cron
-c ${MAILUSR}
+       enewgroup ${MAILGRP} ${MAILGID}
+       enewuser  ${MAILUSR} ${MAILUID} /bin/bash ${INSTALLDIR} mailman -G cron
-c "mailman"
 }

 src_unpack() {
@@ -45,6 +47,8 @@
                --with-mail-gid=${MAILGID} \
                --with-cgi-gid=${CGIGID} \
                --with-var-prefix=${VAR_PREFIX} \
+               --with-username=${MAILUSR} \
+               --with-groupname=${MAILGRP} \
        || die "configure failed"

        emake || die "make failed"
@@ -88,7 +92,7 @@
        keepdir ${VAR_PREFIX}/lists
        keepdir ${VAR_PREFIX}/qfiles

-       chown -R mailman:mailman ${D}/${VAR_PREFIX} ${D}/${INSTALLDIR}
${D}/etc/mailman/*
+       chown -R ${MAILUSR}:${MAILGRP} ${D}/${VAR_PREFIX} ${D}/${INSTALLDIR}
${D}/etc/mailman/*
        chmod 2775 ${D}/${INSTALLDIR} ${D}/${INSTALLDIR}/templates/* \
                ${D}/${INSTALLDIR}/messages/* ${D}/${VAR_PREFIX}
${D}/${VAR_PREFIX}/{logs,lists,spam,locks,archives/public}
        chmod 2750 ${D}/${VAR_PREFIX}/archives/private
@@ -100,8 +104,8 @@
 pkg_postinst() {
        python_mod_optimize ${INSTALLDIR}/bin/ ${INSTALLDIR}/Mailman

-       enewgroup mailman 280
-       enewuser mailman 280 -1 ${INSTALLDIR} mailman -G cron -c "mailman"
+       enewgroup ${MAILGRP} ${MAILGID}
+       enewuser  ${MAILUSR} ${MAILUID} -1 ${INSTALLDIR} mailman -G cron -c
"mailman"
        elog
        elog "Please read /usr/share/doc/${PF}/README.gentoo.gz for additional"
        elog "Setup information, mailman will NOT run unless you follow"
@@ -120,6 +124,9 @@
        ewarn "MAILMAN_INSTALLDIR (default: /usr/lib/mailman)"
        ewarn "MAILMAN_VAR_PREFIX (default: /var/lib/mailman)"
        ewarn "MAILMAN_CGIGID (default: 81)"
+       ewarn "MAILMAN_MAILUSR (default: mailman)"
+       ewarn "MAILMAN_MAILUID (default: 280)"
+       ewarn "MAILMAN_MAILGRP (default: mailman)"
        ewarn "MAILMAN_MAILGID (default: 280)"
        ewarn
        ewarn "Config file is now symlinked in /etc/mailman, so etc-update
works."


This could be help to change the mailman-user and mailman-group easily with
some meta variables. It is tested and seems to work at least for me.


Sebastian 'kickino' Wieseler

------- Comment #3 From Sebastian Wieseler 2007-10-22 14:08:49 0000 -------
--- /usr/portage/net-mail/mailman/mailman-2.1.9-r2.ebuild       2007-09-28
07:36:11.000000000 +0000
+++ mailman-2.1.9-r100.ebuild     2007-10-22 14:08:21.000000000 +0000
@@ -22,13 +22,17 @@
        INSTALLDIR=${MAILMAN_PREFIX:-"/usr/lib/mailman"}
        VAR_PREFIX=${MAILMAN_VAR_PREFIX:-"/var/lib/mailman"}
        CGIGID=${MAILMAN_CGIGID:-81}
+       MAILUSR=${MAILMAN_MAILUSR:-mailman}
+       MAILUID=${MAILMAN_MAILUID:-280}
+       MAILGRP=${MAILMAN_MAILGRP:-mailman}
        MAILGID=${MAILMAN_MAILGID:-280}

+
        # Bug #58526: switch to enew{group,user}.
        # need to add mailman here for compile process.
        # Duplicated at pkg_postinst() for binary install.
-       enewgroup mailman 280
-       enewuser mailman 280 /bin/bash ${INSTALLDIR} mailman -G cron -c mailman
+       enewgroup ${MAILGRP} ${MAILGID}
+       enewuser  ${MAILUSR} ${MAILUID} /bin/bash ${INSTALLDIR} mailman -G cron
-c "mailman"
 }

 src_unpack() {
@@ -43,6 +47,8 @@
                --with-mail-gid=${MAILGID} \
                --with-cgi-gid=${CGIGID} \
                --with-var-prefix=${VAR_PREFIX} \
+               --with-username=${MAILUSR} \
+               --with-groupname=${MAILGRP} \
        || die "configure failed"

        emake || die "make failed"
@@ -86,7 +92,7 @@
        keepdir ${VAR_PREFIX}/lists
        keepdir ${VAR_PREFIX}/qfiles

-       chown -R mailman:mailman ${D}/${VAR_PREFIX} ${D}/${INSTALLDIR}
${D}/etc/mailman/*
+       chown -R ${MAILUSR}:${MAILGRP} ${D}/${VAR_PREFIX} ${D}/${INSTALLDIR}
${D}/etc/mailman/*
        chmod 2775 ${D}/${INSTALLDIR} ${D}/${INSTALLDIR}/templates/* \
                ${D}/${INSTALLDIR}/messages/* ${D}/${VAR_PREFIX}
${D}/${VAR_PREFIX}/{logs,lists,spam,locks,archives/public}
        chmod 2750 ${D}/${VAR_PREFIX}/archives/private
@@ -98,8 +104,8 @@
 pkg_postinst() {
        python_mod_optimize ${INSTALLDIR}/bin/ ${INSTALLDIR}/Mailman

-       enewgroup mailman 280
-       enewuser mailman 280 -1 ${INSTALLDIR} mailman -G cron -c "mailman"
+       enewgroup ${MAILGRP} ${MAILGID}
+       enewuser  ${MAILUSR} ${MAILUID} -1 ${INSTALLDIR} mailman -G cron -c
"mailman"
        elog
        elog "Please read /usr/share/doc/${PF}/README.gentoo.gz for additional"
        elog "Setup information, mailman will NOT run unless you follow"
@@ -118,6 +124,9 @@
        ewarn "MAILMAN_INSTALLDIR (default: /usr/lib/mailman)"
        ewarn "MAILMAN_VAR_PREFIX (default: /var/lib/mailman)"
        ewarn "MAILMAN_CGIGID (default: 81)"
+       ewarn "MAILMAN_MAILUSR (default: mailman)"
+       ewarn "MAILMAN_MAILUID (default: 280)"
+       ewarn "MAILMAN_MAILGRP (default: mailman)"
        ewarn "MAILMAN_MAILGID (default: 280)"
        ewarn
        ewarn "Config file is now symlinked in /etc/mailman, so etc-update
works."


Fixed some things.

------- Comment #4 From Sebastian Wieseler 2007-10-22 17:06:00 0000 -------
Created an attachment (id=134121) [details]
diff as attachment (maybe prefered?) - mailman user and group configurable

------- Comment #5 From Hanno Boeck 2007-11-26 02:25:11 0000 -------
ebuild changes committed, thanks.

About the qmail-to-mailman-script, can you make the patch secure and send it
upstream?

------- Comment #6 From Sebastian Wieseler 2007-11-29 09:47:26 0000 -------
(In reply to comment #5)
> About the qmail-to-mailman-script, can you make the patch secure and send it
> upstream?

I did. But qmail-to-mailman isn't maintained by the mailman team but from a
third party. I mailed my patch to the programmer but no respone since some
weeks. :-/