Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

Sending emails from root after "su -", strange sender

SOLVED
Go to solution
Bernie Vande Griend
Respected Contributor

Sending emails from root after "su -", strange sender

We are forcing all of our users to log in as themselves and then do a "su -" to go in as root or other system accounts. When we use sendmail or mailx to send email as root directly logged in the user sees the message coming from the root user. If we send it from root after the "su -" it picks a different user in /etc/passwd as the sender and not always the same one. Adding the "-r" option to mailx works in most cases for us, but I'm still curious as to what the difference is in email from console root and "su -" root.
Ye who thinks he has a lot to say, probably shouldn't.
4 REPLIES
Reinhold Flecke
Occasional Advisor

Re: Sending emails from root after "su -", strange sender

I used "remsh/rexec hostname -l username -n command" or better for security issues "ssh hostname -l username -n command".

Please setup "who am i" and you can see why "su -" doesn't work.
no work no fun
Fred Ruffet
Honored Contributor

Re: Sending emails from root after "su -", strange sender

when using "su", you switch conected user, but there are still traces of your original connection. If you use "id", you will see currently connected user. If you use "who -m" (or "who am i") you will still see original user (the one who connected first to the machine). This is due to the fact that it is still holding the tty.
To see it exactly, use "ls -l $(tty)" to see who is holding your tty. This is probably what sendmail is verifying when sending mail.

Regards,

Fred
--

"Reality is just a point of view." (P. K. D.)
Bernie Vande Griend
Respected Contributor

Re: Sending emails from root after "su -", strange sender

Yes, I understand that the original login is holding the tty and I understand the difference between the LOGNAME and the "who -m" or "who am i", and I assumed it had something to do with this as well. HOWEVER, I would understand if email is then sent as the original login, but it is not, it is coming up with a whole different person from the system and it changes depending on who switched. I have this on every system when switching user to root. My other question is, other than using the "-r" option with mailx, is there a way to make the emails sent come from root even when switched user?
Ye who thinks he has a lot to say, probably shouldn't.
Ermin Borovac
Honored Contributor
Solution

Re: Sending emails from root after "su -", strange sender

This may be due to corruption of utmp and utmpx files. See knowledge base article KBRC00012956.

Mailx Mail From Root Shows It Coming From Another User
DocId: KBRC00012956 Updated: 8/5/03 8:14:00 AM