From owner-freebsd-questions@FreeBSD.ORG Thu Jan 10 13:22:54 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7840416A421 for ; Thu, 10 Jan 2008 13:22:54 +0000 (UTC) (envelope-from jimbow@darq.net) Received: from farnborough.darq.net (fab.darq.net [82.136.41.2]) by mx1.freebsd.org (Postfix) with ESMTP id 123D913C45B for ; Thu, 10 Jan 2008 13:22:53 +0000 (UTC) (envelope-from jimbow@darq.net) Received: from localhost (localhost [127.0.0.1]) by farnborough.darq.net (Postfix) with ESMTP id 4A6771D019; Thu, 10 Jan 2008 13:23:14 +0000 (GMT) X-Virus-Scanned: amavisd-new at darq.net Received: from farnborough.darq.net ([127.0.0.1]) by localhost (farnborough.darq.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Hx7Lin0KkLk1; Thu, 10 Jan 2008 13:23:10 +0000 (GMT) Received: from troop.darq.net (hackney.darq.net [78.86.112.102]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: zygis@darq.net) by farnborough.darq.net (Postfix) with ESMTP id 6592E1CFA3; Thu, 10 Jan 2008 13:23:10 +0000 (GMT) Message-ID: <47861C27.8080608@darq.net> Date: Thu, 10 Jan 2008 13:22:47 +0000 From: Jim Bow User-Agent: Thunderbird 2.0.0.6 (X11/20071004) MIME-Version: 1.0 To: Mike Bristow References: <47834FB2.9010907@darq.net> <443at70zy1.fsf@be-well.ilk.org> <4785F786.1010706@darq.net> <20080110121425.GA21247@cheddar.urgle.com> In-Reply-To: <20080110121425.GA21247@cheddar.urgle.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-questions@freebsd.org Subject: Re: mail from: field question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jan 2008 13:22:54 -0000 Mike Bristow wrote: > On Thu, Jan 10, 2008 at 10:46:30AM +0000, Jim Bow wrote: >> If I run the script (or just send a mail) on the command line using sudo, >> then it's sent as me and not root. Same happens if I su to root first. > > use 'su -'. It means you get a login shell (which sets up the enviroment > in the same way that login does). That makes perfect sense, but doesn't seem to work. Here's the output of my terminal session: host% whoami jim host% sudo su - (tried doing "su -" also, with same results) Password: host# whoami root host# env USER=root HOME=/root SHELL=/bin/csh PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin MAIL=/var/mail/root BLOCKSIZE=K FTP_PASSIVE_MODE=YES TERM=screen HOSTTYPE=FreeBSD VENDOR=intel OSTYPE=FreeBSD MACHTYPE=i386 SHLVL=1 PWD=/root LOGNAME=root GROUP=wheel HOST=host.example.com EDITOR=vi PAGER=more host# cat /etc/motd | mail -s "hello" test@example.com This results in the mail from: header of jim@host.example.com. I've tried this on two different hosts with the same result. The actual thing Im trying to do is to email something from a script that runs as root from devd, but I run into the same problem of the email arriving from somebody other than root, hence trying this manually on the command line. There is definitely something that I am overlooking, but what is it? I'm extremely curious to work-out why I'm seeing such behavior as its defeating all my expectations so far. Thanks for reading. JimBow