Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jan 2008 12:14:25 +0000
From:      Mike Bristow <mike@urgle.com>
To:        Jim Bow <jimbow@darq.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: mail from: field question
Message-ID:  <20080110121425.GA21247@cheddar.urgle.com>
In-Reply-To: <4785F786.1010706@darq.net>
References:  <47834FB2.9010907@darq.net> <443at70zy1.fsf@be-well.ilk.org> <4785F786.1010706@darq.net>

next in thread | previous in thread | raw e-mail | index | archive | help
[ apologies to Jim Bow who gets this twice due to my fingers typing
faster than my brain. ]

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).

I expect you can do the same thing with sudo with something like
'sudo bash -login' or similar.

> The only way I can get it to be sent from root is if I explicitly login as 
> root.
> 
>>  Make sure the results are the same (if they're not, the MTA isn't
> > the problem).
> 
> So it looks like it isn't. What can be the cause of this then?

The extra things the shell does when running as a login shell; in
particular clearing the enviroment and setting things like LOGNAME
and USER (which I expect /usr/bin/mail and others pay attention to).

-- 
Shenanigans!  Shenanigans!    Best of 3!
	-- Flash 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080110121425.GA21247>