Re: mail from: field question
Ian Smith wrote: paqi# alias um tty;id -p;who am i paqi# um /dev/ttyp3 login smithi uid root groups wheel operator network root ttyp3Jan 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, Yes, I think you've hit the nail on the head there. 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. Is 'somebody other than root' consistent, and someone who's logged in, perhaps before su'ing and then starting the session that invokes devd? 'somebody other than root' is the same user each time. They are not logged in at the time the script runs, but do own some active processes (most notably screen). 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 Postfix doesn't seem to be affected by the same issue and works as one would expect when run from command line and devd. I've also tried using nullmailer and that works ok too. Seems that sendmail's workings were responsible for the confusion. I'm going to be replacing it with nullmailer on all machines. Thanks for all your help, Jim Bow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
Lowell Gilbert wrote: The answer will probably depend on the MTA you're using (which you didn't mention, so it's probably sendmail) You've guessed it. Its out-of-the-box sendmail. Run the script from the command line and in particular just call mail the way the script does. 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. 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? Thanks for your help. JimBow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
[ 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 +, 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
Mike Bristow wrote: On Thu, Jan 10, 2008 at 10:46:30AM +, 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 [EMAIL PROTECTED] This results in the mail from: header of [EMAIL PROTECTED] 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 ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
--On Thursday, January 10, 2008 13:22:47 + Jim Bow [EMAIL PROTECTED] wrote: Mike Bristow wrote: On Thu, Jan 10, 2008 at 10:46:30AM +, 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 [EMAIL PROTECTED] This results in the mail from: header of [EMAIL PROTECTED] 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. I'm not sure what, but something is wrong. I did the exact same thing you did, but the results are completely different. [EMAIL PROTECTED] env HOST=utd59514.utdallas.edu TERM=xterm SHELL=/bin/csh GROUP=wheel USER=root HOSTTYPE=FreeBSD PAGER=more FTP_PASSIVE_MODE=YES MAIL=/var/mail/root PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin BLOCKSIZE=K PWD=/usr/ports/dns/noip EDITOR=vi [EMAIL PROTECTED] SHLVL=2 HOME=/root OSTYPE=FreeBSD VENDOR=intel LOGNAME=root MACHTYPE=i386 _=/usr/bin/env OLDPWD=/usr/ports [EMAIL PROTECTED] cat /etc/motd | mail -s hello [EMAIL PROTECTED] [EMAIL PROTECTED] tail /var/log/maillog Jan 10 03:44:29 utd59514 postfix/qmgr[816]: 6EDD1261839: from=[EMAIL PROTECTED], size=13491, nrcpt=1 (queue active) Jan 10 03:44:29 utd59514 postfix/smtp[37291]: 6D39E261838: to=[EMAIL PROTECTED], orig_to=root, relay=smtp.utdallas.edu[129.110.10.33]:25, delay=0.16, delays=0.01/0.06/0.05/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 855C65AEAC) Jan 10 03:44:29 utd59514 postfix/qmgr[816]: 6D39E261838: removed Jan 10 03:44:29 utd59514 postfix/smtp[37292]: 6EDD1261839: to=[EMAIL PROTECTED], orig_to=root, relay=smtp.utdallas.edu[129.110.10.33]:25, delay=0.17, delays=0/0.06/0.05/0.06, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 853C95AEA9) Jan 10 03:44:29 utd59514 postfix/qmgr[816]: 6EDD1261839: removed Jan 10 09:28:00 utd59514 postfix/pickup[37968]: 3A037261834: uid=0 from=root Jan 10 09:28:00 utd59514 postfix/cleanup[38056]: 3A037261834: message-id=[EMAIL PROTECTED] Jan 10 09:28:00 utd59514 postfix/qmgr[816]: 3A037261834: from=[EMAIL PROTECTED], size=641, nrcpt=1 (queue active) Jan 10 09:28:00 utd59514 postfix/smtp[38058]: 3A037261834: to=[EMAIL PROTECTED], relay=smtp.utdallas.edu[129.110.10.33]:25, delay=0.07, delays=0.02/0.01/0.01/0.04, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as 3E1575ADDD) Jan 10 09:28:00 utd59514 postfix/qmgr[816]: 3A037261834: removed [EMAIL PROTECTED] whoami root And the message received was sent by root. Received: from smtp2.utdallas.edu ([129.110.10.33]) by UTDEVS08.campus.ad.utdallas.edu with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Jan 2008 09:29:03 -0600 Received: from utd59514.utdallas.edu (utd59514.utdallas.edu [129.110.3.28]) by smtp2.utdallas.edu (Postfix) with ESMTP id 3E1575ADDD for [EMAIL PROTECTED]; Thu, 10 Jan 2008 09:28:00 -0600 (CST) Received: by utd59514.utdallas.edu (Postfix, from userid 0) id 3A037261834; Thu, 10 Jan 2008 09:28:00 -0600 (CST) To: [EMAIL PROTECTED] Subject: hello Message-Id: [EMAIL PROTECTED] Date: Thu, 10 Jan 2008 09:28:00 -0600 (CST) From: [EMAIL PROTECTED] (Charlie Root) Return-Path: [EMAIL PROTECTED] X-OriginalArrivalTime: 10 Jan 2008 15:29:03.0486 (UTC) FILETIME=[87E371E0:01C8539D] FreeBSD 6.2-RELEASE-p9 (GENERIC) #2: Wed Dec 5 16:16:36 CST 2007 (1) Unauthorized use is prohibited; (2) Usage may be subject to security testing and monitoring; (3) Misuse is subject to criminal prosecution; and (4) No expectation of privacy except as otherwise provided by applicable privacy laws. -- Paul Schmehl ([EMAIL PROTECTED]) Senior Information Security Analyst The University of Texas at Dallas http://www.utdallas.edu/ir/security/ ___ freebsd-questions@freebsd.org mailing list
Re: mail from: field question
Paul Schmehl wrote: I'm not sure what, but something is wrong. I did the exact same thing you did, but the results are completely different. The only difference I can spot is that you are using Postfix, while the hosts I'm using all run standard Sendmail. Could this be the problem? I might give it a quick test to find out for sure. Thanks, Jim Bow ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
On Thu, 10 Jan 2008 13:22:47 + Jim Bow [EMAIL PROTECTED] wrote: Mike Bristow wrote: On Thu, Jan 10, 2008 at 10:46:30AM +, 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 [EMAIL PROTECTED] This results in the mail from: header of [EMAIL PROTECTED] 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 ttyp3Jan 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: [EMAIL PROTECTED] 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 [EMAIL PROTECTED]; Fri, 11 Jan 2008 13:42:16 +1100 (EST) (envelope-from [EMAIL PROTECTED]) Received: (from [EMAIL PROTECTED]) 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 [EMAIL PROTECTED] Message-Id: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: boo hoo Note 'received from [EMAIL PROTECTED]' 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@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: mail from: field question
Jim Bow [EMAIL PROTECTED] writes: I have a small shell script that does a backup to a usb drive and emails the results to a set of people. The script is triggered from devd (upon drive attachment) and runs as root. The problem is that the mail report is sent from an active system user and not user root. The user the mail is sent from is not referenced in the script. The mail line looks like this: cat $LOGFILE | mail -s backuptousb report [EMAIL PROTECTED] I find this rather confusing since I was expecting the email to be sent by the user running the script. How can this be? A little research told me that this may be because of something called envelope-from, but I found little explanation of what that actually means. Anyone have any suggestions? The answer will probably depend on the MTA you're using (which you didn't mention, so it's probably sendmail), but checking a couple of simple things first will help ensure you're at least on the right track. Run the script from the command line, and in particular just call mail the way the script does. Make sure the results are the same (if they're not, the MTA isn't the problem). Then, look in the mail logs to see what they tell you about the message. ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]