From nobody@FreeBSD.org  Wed Oct 20 10:25:18 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 7727916A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Oct 2004 10:25:18 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4ACDA43D58
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Oct 2004 10:25:18 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.11/8.12.11) with ESMTP id i9KAPHd1096085
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 20 Oct 2004 10:25:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.11/8.12.11/Submit) id i9KAPHYa096084;
	Wed, 20 Oct 2004 10:25:17 GMT
	(envelope-from nobody)
Message-Id: <200410201025.i9KAPHYa096084@www.freebsd.org>
Date: Wed, 20 Oct 2004 10:25:17 GMT
From: Matthias Fechner <idefix@fechner.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Cron will not send emails via Exim
X-Send-Pr-Version: www-2.3

>Number:         72915
>Category:       bin
>Synopsis:       [cron] Cron will not send emails via Exim
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 20 10:30:19 GMT 2004
>Closed-Date:    Sat Jun 25 17:48:20 GMT 2005
>Last-Modified:  Sat Jun 25 17:48:20 GMT 2005
>Originator:     Matthias Fechner
>Release:        5.2.1 and 5.3-BETA7
>Organization:
>Environment:
FreeBSD server.idefix.loc 5.3-BETA7 FreeBSD 5.3-BETA7 #5: Sat Oct 16 15:59:18 CEST 2004     root@:/usr/obj/usr/src/sys/SERVER  i386
>Description:
it is not possible set in Cron an emailadress like MAILTO="idefix@fechner.net", the mail is not send correctly.
I have tested now some things.
At first i have write a short script like:
echo $0 >> /tmp/bla ; env >> /tmp/bla

Which is executed from cron, i get the following output:
--- cut ---                                                                                                                                            
/usr/local/bin/testcron                                                                                                                                
USER=root                                                                                                                                              
HOME=/root                                                                                                                                             
MAILTO=idefix@fechner.net                                                                                                                              
LOGNAME=root                                                                                                                                           
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin                                                                                                 
SHELL=/bin/sh                                                                                                                                          
--- cut ---                                                                                                                                            

In the exim log i can see the following output if cron try to send the email:
--- cut ---
2004-10-20 12:18:00 1CKDXc-000DVc-Ae <= <> R=1CKDXc-000DVb-A8 U=mailnull P=local S=701
2004-10-20 12:18:04 1CKDXc-000DVc-Ae => root@fechner.net R=send_to_smart_host T=remote_smtp H=ipv4.fechner.net [83.120.0.234] X=TLSv1:DHE-RSA-AES256-SHA:256
2004-10-20 12:18:04 1CKDXc-000DVc-Ae Completed
--- cut ---

Here in the first line i miss the receipiant adress.

If i sent an email via shell with user account or root account like:
mail idefix@fechner.net
i get:
--- cut ---
2004-10-20 12:21:22 1CKDas-000DZG-Ma <= root@fechner.net U=root P=local S=321
2004-10-20 12:21:24 no IP address found for host localhost.idefix.loc (during SMTP connection from [127.0.0.1])
2004-10-20 12:21:24 1CKDau-000DZL-Ql <= root@fechner.net H=(localhost) [127.0.0.1] P=esmtp S=858 id=E1CKDas-000DZG-Ma@server.idefix.loc
2004-10-20 12:21:24 1CKDas-000DZG-Ma => idefix@fechner.net R=amavis T=amavis H=localhost [127.0.0.1]
2004-10-20 12:21:24 1CKDas-000DZG-Ma Completed
2004-10-20 12:21:28 1CKDau-000DZL-Ql => idefix@fechner.net R=send_to_smart_host T=remote_smtp H=ipv4.fechner.net [83.120.0.234] X=TLSv1:DHE-RSA-AES256-SHA:256
2004-10-20 12:21:28 1CKDau-000DZL-Ql Completed
--- cut ---

And the mail is ok.
>How-To-Repeat:
use exim from port (exim-4.43+28) set in cron MAILTO="idefix@fechner.net" or any other email like "idefix" (local account etc.), than write something like this in cron:
MAILTO="idefix"
*/1 *   *       *       *       root    echo test


>Fix:
      
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->freebsd-bugs 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Oct 24 00:29:52 GMT 2004 
Responsible-Changed-Why:  
This does not sound i386-specific. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72915 

From: Matthias Fechner <idefix@fechner.net>
To: bug-followup@FreeBSD.org, idefix@fechner.net
Cc:  
Subject: Re: bin/72915: [cron] Cron will not send emails via Exim
Date: Sat, 18 Jun 2005 11:54:41 +0200

 i tried now to debug it, and found a solution, which solves the problem.
 But i have no idea, why this is resolving the problem.
 
 Patch the file /usr/src/usr.sbin/cron/cron/do_command.c with the 
 following patch:
 --- do_command.c.orig   Wed Jun 15 11:19:43 2005
 +++ do_command.c        Sat Jun 18 11:45:21 2005
 @@ -419,6 +419,8 @@
                                 register char   **env;
                                 auto char       mailcmd[MAX_COMMAND];
                                 auto char       hostname[MAXHOSTNAMELEN];
 +                               FILE *myfdh;
 +                               myfdh=fopen("/tmp/cron.log","w");
 
                                 (void) gethostname(hostname, 
 MAXHOSTNAMELEN);
                                 (void) snprintf(mailcmd, sizeof(mailcmd),
 @@ -440,6 +442,7 @@
                                         fprintf(mail, "X-Cron-Env: <%s>\n",
                                                 *env);
                                 fprintf(mail, "\n");
 +                               fclose(myfdh);
 
                                 /* this was the first char from the pipe
                                  */
 
 -- 
 Thx Matthias

From: Matthias Fechner <idefix@fechner.net>
To: bug-followup@FreeBSD.org, idefix@fechner.net
Cc:  
Subject: Re: bin/72915: [cron] Cron will not send emails via Exim
Date: Sat, 25 Jun 2005 19:25:36 +0200

 i found now the problem, i have in the file /etc/nsswitch.conf the 
 following lines:
 passwd: files ldap
 group:  files ldap
 
 i removed the entry ldap and now everthing is working fine.
 Maybe it has something to do with bug:
 http://www.freebsd.org/cgi/query-pr.cgi?pr=81555
 
 I think, you can close this PR.
 
 -- 
 Thx
 Matthias
State-Changed-From-To: open->closed 
State-Changed-By: linimon 
State-Changed-When: Sat Jun 25 17:48:02 GMT 2005 
State-Changed-Why:  
Closed at submitter's request. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=72915 
>Unformatted:
