Re: mail from: field question



On Thu, 10 Jan 2008 13:22:47 +0000 Jim Bow <jimbow@xxxxxxxx> wrote:
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@xxxxxxxxxxx

This results in the mail from: header of jim@xxxxxxxxxxxxxxxxx I've
tried this on two different hosts with the same result.

I can confirm this behaviour, also using csh and sendmail, and 'su -'
from originally having logged in as myself, since freebsd 2.2 ..

I use this csh alias whenever not entirely sure who or where I am ..

paqi# alias um
tty;id -p;who am i
paqi# um
/dev/ttyp3
login smithi
uid root
groups wheel operator network
root ttyp3 Jan 11 14:09

Note 'id -p' showing 'login smithi'; see id(1) .. I gather that sendmail
must also use getlogin(2) - which value does not appear in `env` - when
sending mail from an su'd session, as opposed to an original root login,
and don't know whether or how this may be configurable in sendmail.

paqi# mail smithi
Subject: boo
hoo
..
EOT

Return-Path: <smithi@xxxxxxxxxxxxxxxxxx>
Received: from paqi.nimnet.asn.au (localhost.nimnet.asn.au [127.0.0.1])
by paqi.nimnet.asn.au (8.13.8/8.13.8) with ESMTP id m0B2gGpU059565
for <smithi@xxxxxxxxxxxxxxxxxx>; Fri, 11 Jan 2008 13:42:16 +1100 (EST)
(envelope-from smithi@xxxxxxxxxxxxxxxxxx)
Received: (from root@localhost)
by paqi.nimnet.asn.au (8.13.8/8.13.8/Submit) id m0B2gFPr059564
for smithi; Fri, 11 Jan 2008 13:42:15 +1100 (EST)
(envelope-from smithi)
Date: Fri, 11 Jan 2008 13:42:15 +1100 (EST)
From: Ian Smith <smithi@xxxxxxxxxxxxxxxxxx>
Message-Id: <200801110242.m0B2gFPr059564@xxxxxxxxxxxxxxxxxx>
To: smithi@xxxxxxxxxxxxxxxxxx
Subject: boo

hoo

Note 'received from root@localhost' but 'envelope-from smithi'. Also
note I'm not using domain masquerading here, as I don't actually mail
out from this box currently.

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.

Hmm .. I know mail sent from cron scripts properly comes 'from root',
and don't know why scripts run as root from devd would be any different.

Is 'somebody other than root' consistent, and someone who's logged in,
perhaps before su'ing and then starting the session that invokes devd?

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.

I noticed later that Paul gets a different result .. maybe postfix as
mentioned, if Paul was starting from an su'd session, not a root login?

cheers, Ian

_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Limit the number of erroneous logins of root from the same IP
    ... After the limit that IP can not try to login anymore. ... Why are you allowing root to log in over the net? ... before any of the deny lists in /etc/hosts.allow. ... It offered three options - add a host reject route (man ...
    (alt.os.linux.redhat)
  • SUMARY: Cant login as root
    ... As a result, i was not able to log in as root, neither create a new ... Asunto: RE: Can't login as root ... > console. ... > If we log as any other user everythig is ok, but we cannot either do su-. ...
    (Tru64-UNIX-Managers)
  • RE: Urgent help needed with Login problems after installation of FC1
    ... symptom trying to su back to root. ... After another minimal install, I was able to add my user and su to it and su ... I was unable to boot using the boot floppy. ... I did a minimal install and was able to login as root, ...
    (Fedora)
  • Re: BSM, SSH, and Session ID
    ... Are you logging in as root through ssh or is that just the way it is ... Sun SSH/OpenSSH should fork off before the login because the sshd ... It should always be a different session, ...
    (Focus-SUN)
  • Re: Urgent help needed with Login problems after installation of FC1
    ... login would do anything but loop back to the Login: ... >From Gnome desktop, I was able to logout user, login root, over and ... Am able to boot from floppy. ... >After another minimal install, I was able to add my user and su to ...
    (Fedora)