From: Philip Hazel Date: Wed, 14 Mar 2007 12:15:56 +0000 (+0000) Subject: Change originator_xxx fields in the daemon when it gives up root so that X-Git-Tag: exim-4_67~15 X-Git-Url: https://git.exim.org/exim.git/commitdiff_plain/ebeaf99687d0fd6545c95983f0d91e2ddee7fbb7 Change originator_xxx fields in the daemon when it gives up root so that the -H files are always consistent. --- diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 9140b63c7..bbaa500dc 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.495 2007/03/14 11:22:23 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.496 2007/03/14 12:15:56 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -175,6 +175,13 @@ PH/39 In a list of hosts for manualroute, if one item (either because of multi- from the list, along with the local host and any following hosts (which is what is supposed to happen). +PH/40 When Exim receives a message, it writes the login name, uid, and gid of + whoever called Exim into the -H file. In the case of the daemon it was + behaving confusingly. When first started, it used values for whoever + started the daemon, but after a SIGHUP it used the Exim user (because it + calls itself on a restart). I have changed the code so that it now always + uses the Exim user. + Exim version 4.66 ----------------- diff --git a/src/src/daemon.c b/src/src/daemon.c index 4c6c90878..e844403a4 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/daemon.c,v 1.22 2007/01/23 14:34:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/daemon.c,v 1.23 2007/03/14 12:15:56 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -881,6 +881,7 @@ There are no arguments to this function, and it never returns. */ void daemon_go(void) { +struct passwd *pw; int *listen_sockets = NULL; int listen_socket_count = 0; ip_address_item *addresses = NULL; @@ -1453,6 +1454,14 @@ cannot do this. */ exim_setugid(exim_uid, exim_gid, geteuid()==root_uid, US"running as a daemon"); +/* Update the originator_xxx fields so that received messages as listed as +coming from Exim, not whoever started the daemon. */ + +originator_uid = exim_uid; +originator_gid = exim_gid; +originator_login = ((pw = getpwuid(exim_uid)) != NULL)? + string_copy_malloc(US pw->pw_name) : US"exim"; + /* Get somewhere to keep the list of queue-runner pids if we are keeping track of them (and also if we are doing queue runs). */ diff --git a/test/runtest b/test/runtest index 4e511dc36..472aeaf78 100755 --- a/test/runtest +++ b/test/runtest @@ -1,6 +1,6 @@ #! /usr/bin/perl -w -# $Cambridge: exim/test/runtest,v 1.24 2007/02/08 15:16:19 ph10 Exp $ +# $Cambridge: exim/test/runtest,v 1.25 2007/03/14 12:15:56 ph10 Exp $ ############################################################################### # This is the controlling script for the "new" test suite for Exim. It should # @@ -463,9 +463,10 @@ while() # ======== Exim's login ======== - # For bounce messages, this will appear on the U= lines in logs and also - # after Received: and in addresses. In one pipe test it appears after - # "Running as:". It also appears in addresses, and in the names of lock + # For messages received by the daemon, this is in the -H file, which some + # tests inspect. For bounce messages, this will appear on the U= lines in + # logs and also after Received: and in addresses. In one pipe test it appears + # after "Running as:". It also appears in addresses, and in the names of lock # files. s/U=$parm_eximuser/U=EXIMUSER/; @@ -482,6 +483,8 @@ while() s/\buid=$parm_exim_uid\b/uid=EXIM_UID/g; s/\bgid=$parm_exim_gid\b/gid=EXIM_GID/g; + s/^$parm_eximuser $parm_exim_uid $parm_exim_gid/EXIMUSER EXIM_UID EXIM_GID/; + # ======== General uids, gids, and pids ======== # Note: this must come after munges for caller's and exim's uid/gid diff --git a/test/stdout/0035 b/test/stdout/0035 index dfc44ed51..15cac0b0f 100644 --- a/test/stdout/0035 +++ b/test/stdout/0035 @@ -135,7 +135,7 @@ Connecting to 127.0.0.1 port 1225 ... connected <<< 221 myhost.test.ex closing connection End of script 10HmaX-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -154,7 +154,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) id 10HmaX-0005vi-00 for x@y; Tue, 2 Mar 1999 09:44:33 +0000 10HmaY-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -176,7 +176,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) dddF From: a@y 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmaZ-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID <> ddddddddd 0 -helo_name rhu.barb @@ -196,7 +196,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) 047I Message-Id: 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmbA-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -216,7 +216,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) for x@y; Tue, 2 Mar 1999 09:44:33 +0000 dddS Sender: sender@some.where 10HmbB-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -239,7 +239,7 @@ ddd* Sender: sender@some.where dddF From: a@y 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmbC-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -262,7 +262,7 @@ dddS Sender: sender@some.where dddF From: a@y 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmbD-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb diff --git a/test/stdout/3415 b/test/stdout/3415 index 8cfc49d37..bc9555c02 100644 --- a/test/stdout/3415 +++ b/test/stdout/3415 @@ -144,7 +144,7 @@ Connecting to 127.0.0.1 port 1225 ... connected <<< 221 myhost.test.ex closing connection End of script 10HmaX-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID ddddddddd 0 -helo_name rhu.barb @@ -169,7 +169,7 @@ dddF From: a@y dddS Sender: username@myhost.test.ex 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmaY-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID <> ddddddddd 0 -helo_name rhu.barb @@ -192,7 +192,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) dddF From: username@myhost.test.ex 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmaZ-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID <> ddddddddd 0 -helo_name rhu.barb @@ -215,7 +215,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) dddF From: username@another.domain 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmbA-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID <> ddddddddd 0 -helo_name rhu.barb @@ -238,7 +238,7 @@ dddP Received: from [127.0.0.1] (helo=rhu.barb) dddF From: username@auth.id.domain 038 Date: Tue, 2 Mar 1999 09:44:33 +0000 10HmbB-0005vi-00-H -CALLER UID GID +EXIMUSER EXIM_UID EXIM_GID <> ddddddddd 0 -helo_name rhu.barb