All my machines use a uniq hostname. So, each machin send cron emails with a from address like root@server1.com, root@server2.org ... but that email adress is suffixed with a user name; so when messages are received by MUA, the FROM field looks like:
From: root@server1.org (Cron Daemon)
or
From: root@server2.org (Cron Daemon)
but because my MUA is stupid, it only shows the username, not the full email address, so that all emails are shown to come from "Cron Daemon".
How can I alter the cron user name so that the username in parenthesis differs from host to host ?
Debian Stretch
exim
For messages sent from CLI by root, the fix was easy: in /etc/passwd, change
root0:0:root:/root:/bin/bash
into
root0:0:root DaServer01:/root:/bin/bash
But
grep -nr "Cron Daemon" /etc/
gave no result, so, it may be hardcoded in /usr ?
Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
How to change the username for cron emails ?
-
- Posts: 145
- Joined: 2014-09-01 17:04
- Location: East Central Illinois, USA
Re: How to change the username for cron emails ?
There might be an easier solution, if your MUA allows you to set up filters to sort incoming mail into folders in the inbox.
1) set up folders for server1, server2, etc.
2) set up filters to sort FROM: root@server1.com to folder server1, FROM: root@server2.org into server2 folder, and so on.
With mail properly sorted, you know which host sent the mail by the folder the mail is in.
1) set up folders for server1, server2, etc.
2) set up filters to sort FROM: root@server1.com to folder server1, FROM: root@server2.org into server2 folder, and so on.
With mail properly sorted, you know which host sent the mail by the folder the mail is in.
Registered GNU/Linux user #170078
Go ask google before you ask on these boards.
It it isn't broken, Tweak It !!!
Go ask google before you ask on these boards.
It it isn't broken, Tweak It !!!
Re: How to change the username for cron emails ?
My MUA can't do this. I want to fix the problem at the source.
Re: How to change the username for cron emails ?
reading you can search i can see at least 2 approaches to make this more distinct; have you checked them all out?
Code: Select all
man cron
Code: Select all
/mail
Re: How to change the username for cron emails ?
I don't care about MAILTO; Debian does not support MAILFROM (some other distros do).
I was wondering if there is an easy way to change this at exim level ? (needs rewriting of the FROM field; a simple grep can do it, but not in the traditionnal way mta usually do it).
Otherwise, I have started grep -nr "Cron Daemon" /, but it will take the whole day.
I was wondering if there is an easy way to change this at exim level ? (needs rewriting of the FROM field; a simple grep can do it, but not in the traditionnal way mta usually do it).
Otherwise, I have started grep -nr "Cron Daemon" /, but it will take the whole day.
Re: How to change the username for cron emails ?
Binary file /usr/sbin/cron matches
if I alter it with binary tools, will it still work, or are there checksums around ?
if I alter it with binary tools, will it still work, or are there checksums around ?
Re: How to change the username for cron emails ?
First shoot:
Must be very carefull to check that the file size have not changed.
Code: Select all
#!/bin/bash
/etc/init.d/cron stop
grep -nra "Cron Daemon" /usr/sbin/cron
#66:[%d] %s/usr/sbin/sendmailinfoCONTENT_TYPECONTENT_TRANSFER_ENCODINGFrom: root (Cron Daemon)
grep -nra "From:" /usr/sbin/cron
cp -a /usr/sbin/cron /usr/sbin/cron.backup.$(/bin/date +%Y-%m-%d_%H-%M-%S).before
hn="$(hostname -f)................"
hn="${hn:0:11}"
echo "'${hn}'"
sed -i /usr/sbin/cron -e "s/(Cron Daemon)/(${hn})/g"
cp -a /usr/sbin/cron /usr/sbin/cron.backup.$(/bin/date +%Y-%m-%d_%H-%M-%S).after
grep -nra "From:" /usr/sbin/cron
/etc/init.d/cron start
stat /usr/sbin/cron*
Re: How to change the username for cron emails ?
In exim4 an alias might work: https://serverfault.com/questions/17310 ... tc-aliases