Date: Thu, 10 Jan 2008 13:22:47 +0000 From: Jim Bow <jimbow@darq.net> To: Mike Bristow <mike@urgle.com> Cc: freebsd-questions@freebsd.org Subject: Re: mail from: field question Message-ID: <47861C27.8080608@darq.net> In-Reply-To: <20080110121425.GA21247@cheddar.urgle.com> References: <47834FB2.9010907@darq.net> <443at70zy1.fsf@be-well.ilk.org> <4785F786.1010706@darq.net> <20080110121425.GA21247@cheddar.urgle.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?47861C27.8080608>