[Popcon-developers] Bug#264593: popularity-contest: it should be possible to configure user which invokes sendmail

Martin Dickopp Martin Dickopp <martin-deb@zero-based.org>, 264593@bugs.debian.org
Mon, 09 Aug 2004 16:57:59 +0200


This is a multi-part MIME message sent by reportbug.

--===============0145791431==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: popularity-contest
Version: 1.23
Severity: wishlist
Tags: patch

Hi,

I think it is reasonable to configure the MTA so that "root" cannot
send mail to the outside world.  Therefore, I would like to be able
to configure a user as which popcon invokes the MTA.  A patch to add
this functionality is included.

Best regards,
Martin


-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (500, 'testing'), (200, 'unstable')
Architecture: i386 (i586)
Kernel: Linux 2.6.7-3
Locale: LANG=C, LC_CTYPE=de_DE@euro

Versions of packages popularity-contest depends on:
ii  debconf                       1.4.30     Debian configuration management sy
ii  dpkg                          1.10.23    Package maintenance system for Deb
ii  exim4-daemon-light [mail-tran 4.34-4     Lightweight version of the Exim (v

--===============0145791431==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="popcon.diff"

diff -ur popularity-contest-1.23.orig/FAQ popularity-contest-1.23/FAQ
--- popularity-contest-1.23.orig/FAQ	2004-05-14 14:44:53.000000000 +0200
+++ popularity-contest-1.23/FAQ	2004-08-09 14:56:48.000000000 +0200
@@ -42,7 +42,9 @@
 
 A) popularity-contest send the report as root but the email address of the root
    user was not configured properly. With exim, you can add an entry for root
-   in /etc/email-addresses with a suitable address.
+   in /etc/email-addresses with a suitable address. Alternatively, you can
+   specify another user to send the report as by setting MAILUSER in
+   /etc/popularity-contest.conf.
 
    A better fix would be to change popcon.debian.org to not reject emails with
    invalid sender domain in the first place, but it is out of our reach for the
diff -ur popularity-contest-1.23.orig/debian/cron.weekly popularity-contest-1.23/debian/cron.weekly
--- popularity-contest-1.23.orig/debian/cron.weekly	2004-02-10 12:56:26.000000000 +0100
+++ popularity-contest-1.23/debian/cron.weekly	2004-08-09 16:31:07.000000000 +0200
@@ -7,6 +7,7 @@
 
 unset MAILFROM
 unset MAILTO
+unset MAILUSER
 unset MY_HOSTID
 unset PARTICIPATE
 
@@ -41,9 +42,17 @@
 do_sendmail()
 {
 	if [ -n "$MAILFROM" ]; then
-		sendmail -oi -f "$MAILFROM" "$MAILTO"
+		if [ -n "$MAILUSER" ] && [ "$MAILUSER" != root ]; then
+			HOME=/tmp su "$MAILUSER" -s /bin/sh -c "/usr/sbin/sendmail -oi -f \"$MAILFROM\" \"$MAILTO\""
+		else
+			sendmail -oi -f "$MAILFROM" "$MAILTO"
+		fi
 	else
-		sendmail -oi "$MAILTO"
+		if [ -n "$MAILUSER" ] && [ "$MAILUSER" != root ]; then
+			HOME=/tmp su "$MAILUSER" -s /bin/sh -c "/usr/sbin/sendmail -oi \"$MAILTO\""
+		else
+			sendmail -oi "$MAILTO"
+		fi
 	fi
 }
 
diff -ur popularity-contest-1.23.orig/default.conf popularity-contest-1.23/default.conf
--- popularity-contest-1.23.orig/default.conf	2004-01-26 21:59:18.000000000 +0100
+++ popularity-contest-1.23/default.conf	2004-08-09 14:54:25.000000000 +0200
@@ -28,6 +28,11 @@
 #
 #MAILFROM="root@example.org"
 
+# If MAILUSER is set, the MTA is invoked as the specified user;
+# otherwise it is invoked as root.
+#
+#MAILUSER="username"
+
 # MY_HOSTID is a secret number that the popularity-contest receiver
 # uses to keep track of your submissions.  Whenever you send in a
 # new entry, it overwrites the last one that had the same HOSTID.

--===============0145791431==--