Solved How to add hostname to periodic email

Hi,
When I receive the daily security run outout, I get the following header:
Code:
From: alerts@mydomain.co.uk
To: root@missing_domain
Could someone please tell me why I get @missing_domain?
I would like yo to be the server hostname.
I looked at various conf but could not tell what to modify, To start I tough that the file beloow would hold the answer but it doesn't
chpass
Code:
#Changing user information for root.
Login: root
Password: $6$qwsFNYQAsgfKyRS8$Cdhyko6sY.X.NxHzPDZS34JpmYLP5dOrvWCfvK0yANCfid01KcCZzvsN2Pply.ZqRX7MDeo6GsVY8C12QMKf.1
Uid [#]: 0
Gid [# or name]: 0
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /root
Shell: /bin/csh
Full Name: fredtheuser
Office Location:
Office Phone:
Home Phone:
Other information:
 
Set the hostname in /etc/rc.conf, including the domain.
 
Hi SirDice
hostname in /etc/rc.conf is already set :(
That been said, looking at man iocage(), I have a few options that could be link to what you are saying:
Code:
host_hostname=UUID

           The hostname of the jail.

           Default: UUID
           Source: jail(8)
Code:
allow_set_hostname=1 | 0

           The jail's hostname may be changed via hostname(1) or sethostname(3).

           Default: 1
           Source: jail(8)
I don't really understand what the 2 options above do (my english is at fault here not the man).

Could you please advise further?
 
.. I tried to set iocage set allow_set_hostname=1 default and iocage set allow_set_hostname=1 <big number> but the To field is still
Code:
root@missing_domain
 
Normally a jail isn't allowed to change its own hostname, by setting allow_set_hostname you can. But if the hostname is already set correctly this won't do much for you. But this does beg the question, do you set the hostname for a jail fully qualified? I.e. including the domain name?
 
Hi SirDice , Thank you for coming back to me.
Bellow is what I have...
iocage list
Code:
JID   UUID                                  BOOT  STATE  TAG
4     dbb40c5a-cdd8-11e5-99af-f04da20055fe  on    up     jailhostname.mydomain.co.uk
iocage get hostname dbb40c5a
Code:
jailhostname.mydomain.co.uk
iocage console dbb40c5a
hostname -f
Code:
jailhostname.mydomain.co.uk
vi /etc/rc.conf
Code:
hostname="jailhostname.mydomain.co.uk"
I must be missing the obvious here or a bug with iocage maybe?
Do I need to do anything with hosts or resolve.conf
Do I need anything else?

Thank you
 
Hello,

I am still really stuck on this issue, could someone please sugest any other things I could look at in order to troubleshoot my problem?

Thank you
 
No idea actually. One thing did come to mind though, by default sendmail(8) is disabled completely in an iocage(8) jail. May be it's not configured completely. What happens if you run this:
Code:
cd /etc/mail
make all
This should generate a <hostname>.mc file that's used to configure sendmail(8).
 
It did generate the missing <hostname>.mc file but didn't solved the problem
I also had an error when I ran make all
Code:
cp freebsd.mc jailhostname.mydomain.co.uk.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 jailhostname.mydomain.co.uk.mc > jailhostname.mydomain.co.uk.cf
cp freebsd.submit.mc jailhostname.mydomain.co.uk.submit.mc
/usr/bin/m4 -D_CF_DIR_=/usr/share/sendmail/cf/   /usr/share/sendmail/cf/m4/cf.m4 jailhostname.mydomain.co.uk.submit.mc > jailhostname.mydomain.co.uk.submit.cf
/usr/sbin/sendmail -bi -OAliasFile=/etc/mail/aliases
sendmail: Aliases are not used in sSMTP
chmod 0640 /etc/mail/aliases.db
chmod: /etc/mail/aliases.db: No such file or directory
*** Error code 1

Stop.
make: stopped in /etc/mail
 
Well, configuring sendmail(8) isn't going to work if you use something else as MTA. Would you mind posting the sSMTP configuration?
 
Sure,
/etc/ssmtp/ssmtp.conf
Code:
root=alerts@mydomain.co.uk                     # Redirect mail for root@ to alerts@mydomain.co.uk
mailhub=sophimail.mydomain.co.uk:465           # SMTP server hostname and port
rewriteDomain=mydomain.co.uk                   # The host the mail appears to be coming from
hostname=northstarpayroll.mydomain.co.uk                       # The name of this host
FromLineOverride=YES                            # Force the From: line
UseTLS=YES                                      # Secure connection (SSL/TLS)
AuthUser=serverstatus@mydomain.co.uk           # Our mail account username
AuthPass=cAdraj7D2axxxx                        # The password for the mail account
etc/ssmtp/revaliases
Code:
root:alerts@mydomain.co.uk:mail.mydomain.co.uk
 
Dear fred974,
your question is related to the earlier post? I have in my www jails /usr/local/etc/ssmtp/ssmtp.conf
Code:
mailhub=10.0.0.254
rewriteDomain=www.local
hostname=www.local
with the hosts lo1 as 10.0.0.254. A mail from the jails root crontab is as below.
Code:
From root@www.local  Fri Feb 26 21:45:55 2016  
>From chris  Fri Feb 26 21: 45:55 2016  
Return-Path: <root@www.local>  
X-Original-To: chris@esprimo.local  
Delivered-To: chris@esprimo.local  
Received: from www.local (www [10.0.0.1])  
  by esprimo.local (Postfix) with SMTP id 7A39745CD8A  
  for <chris@esprimo.local>; Fri, 26 Feb 2016 21:45:54 +0100 (CET)  
Received: by www.local (sSMTP sendmail emulation); Fri, 26 Feb 2016 20:45:54 +0000  
From: Charlie & <root@www.local>  
Date: Fri, 26 Feb 2016 20:45:54 +0000  
To: chris@esprimo.local  
Subject: Cron <root@www> /usr/sbin/pkg audit -F  
X-Cron-Env: <MAILTO=chris@esprimo.local>  
X-Cron-Env: <SHELL=/bin/sh>  
X-Cron-Env: <HOME=/root>  
X-Cron-Env: <PATH=/usr/bin:/bin>  
X-Cron-Env: <LOGNAME=root>  
X-Cron-Env: <USER=root>  
Message-Id: <20160226204554.7A39745CD8A@esprimo.local>  
  
vulnxml file up-to-date  
0 problem(s) in the installed packages found.
The hosts postfix accepts mails from of the jails. The jails name are listed in /etc/hosts of the host. I hope it helps.
 
Back
Top