Bug 3665 - 2_a1: /var/log/messages has localhost instead of hostname alias in runlevel 3
Summary: 2_a1: /var/log/messages has localhost instead of hostname alias in runlevel 3
Status: RESOLVED DUPLICATE of bug 2983
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: Cauldron
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Mageia Bug Squad
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-08 00:01 CET by Bit Twister
Modified: 2012-01-04 11:51 CET (History)
9 users (show)

See Also:
Source RPM: rsyslog-5.8.6-1.mga2.src.rpm
CVE:
Status comment:


Attachments

Description Bit Twister 2011-12-08 00:01:07 CET
Description of problem:

 /var/log/messages has localhost instead of hostname alias

Dec  7 16:51:14 localhost logger: Shorewall started
Dec  7 16:51:14 localhost shorewall[2373]: done.

# hostname --alias
wb2

# grep $(hostname --alias) /etc/hosts
192.168.1.100 wb2.home.test wb2

# hostname --ip-address
192.168.1.100


Version-Release number of selected component (if applicable):


How reproducible: Always


Steps to Reproduce:
1. add  space 3 to end kernel line in /boot/grub/menu.lst
2. reboot
3. tail -4 /var/log/messages

Hit Left windows key until you find a Login: prompt
Comment 1 Manuel Hiebel 2011-12-08 16:11:56 CET
Hi, thanks for reporting this bug.
As there is no maintainer for this package I added the committers in CC.

CC: (none) => ahmadsamir3891, arnaud.patard, dmorganec, guillomovitch, mageia, mageia, mageia, misc

Comment 2 Colin Guthrie 2011-12-08 16:15:40 CET
Quick question, does installing: nss-myhostname fix this issue?
Comment 3 Colin Guthrie 2011-12-08 16:16:38 CET
Also does kill -HUP rsyslog fix it up too?

(I'm wondering if it just reads the hostname when it's started and doesn't poll for hostname changes)
Comment 4 Bit Twister 2011-12-08 21:28:08 CET
(In reply to comment #2)
> Quick question, does installing: nss-myhostname fix this issue?

Not really.
# urpmi nss-myhostname
Package nss-myhostname-0.3-1.mga2.x86_64 is already installed
Marking nss-myhostname as manually installed, it won't be auto-orphaned
writing /var/lib/rpm/installed-through-deps.list

(In reply to comment #3)
> Also does kill -HUP rsyslog fix it up too?

# kill -SIGHUP $(cat /var/run/rsyslogd.pid)

# tail -1 /var/log/messages

Dec  8 14:22:26 localhost rsyslogd: [origin software="rsyslogd" swVersion="5.8.6" x-pid="1265" x-info="http://www.rsyslog.com"] rsyslogd was HUPed

# systemctl stop smb.service

tail -3 /var/log/messages
Dec  8 14:24:19 localhost smbd[2838]:   failed to retrieve printer list: NT_STATUS_UNSUCCESSFUL
Dec  8 14:25:07 localhost smb[4039]: Shutting down SMB services: [  OK  ]
Dec  8 14:25:07 localhost smb[4039]: Shutting down NMB services: [FAILED]
Comment 5 Bit Twister 2011-12-09 00:10:24 CET
(In reply to comment #3)
> Also does kill -HUP rsyslog fix it up too?
> 
> (I'm wondering if it just reads the hostname when it's started and doesn't poll
> for hostname changes)


I would have thought it would read /etc/sysconfig/network for hostname.
If not set, check /etc/hostname, maybe /etc/host. When the network comes up dhcp client could change the name. 

I will have to change /etc/hostname back to installed value to see if my change is causing the problem.
$ head -4 /etc/hosts
# generated by drakconnect
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
192.168.1.100 wb2.home.test wb2

I am currently rebuilding the system.
Comment 6 Bit Twister 2011-12-09 00:25:19 CET
I just checked my Mandriva Linux 2011 log. It has the hostname alias
and format of /etc/hosts is the same. Same file actually. Problem is not my /etc/hosts file. What is different is I have named running on 2011 and have not been back to reinstalling all my changes.
Comment 7 Colin Guthrie 2011-12-09 11:05:43 CET
It checks /etc/hostname first. If it's set that will be the hostname used, but this is the init system, not rsyslog itself. rsyslog just uses the glibc gethostname() fucntion to get the hostname. It should however be informed somehow that the hostname has changed... I reckon a "killall -HUP rsyslog" would likely make it reinit itself, but not sure if there is another mechanism that we should employ to do that automagically.
Comment 8 Frank Griffin 2011-12-10 16:43:54 CET
I've noticed this for a long time, but didn't test as thoroughly as Bit Twister.  I assumed that it occurred as a result of the old speedboot thing of not having services wait for the network to come up, e.g. DMs coming up with "localhost" because the processing of a DHCP-returned hostname had not yet happened.

But you're right, a re-init should fix it, and better still there should be a hostname-changed event.  Even better, syslog should cache until network-up and then fetch the hostname to be used on all of the cached lines, because otherwise apps that post-process syslog can't rely on the hostname as valid.

CC: (none) => ftg

Comment 9 Bit Twister 2011-12-10 17:40:48 CET
(In reply to comment #8)

> But you're right, a re-init should fix it, and better still there should be a
> hostname-changed event.  Even better, syslog should cache until network-up and
> then fetch the hostname to be used on all of the cached lines, because
> otherwise apps that post-process syslog can't rely on the hostname as valid.

Looking at Mandriva 2011, they appeared to have cached original text to console and waited until system got into the network setup.

$ cat /var/log/messages
Dec 10 10:10:50 wb NetworkManager[2238]: <info> caught signal 15, shutting down normally.
Dec 10 10:10:50 wb NetworkManager[2238]: <warn> quit request received, terminating...
Dec 10 10:10:50 wb kernel: Kernel logging (proc) stopped.
Dec 10 10:10:50 wb rsyslogd: [origin software="rsyslogd" swVersion="5.8.5" x-pid="2306" x-info="http://www.rsyslog.com"] exiting on signal 15.
Dec 10 10:11:49 wb kernel: imklog 5.8.5, log source = /proc/kmsg started.
Dec 10 10:11:49 wb rsyslogd: [origin software="rsyslogd" swVersion="5.8.5" x-pid="2295" x-info="http://www.rsyslog.com"] start
Dec 10 10:11:48 wb shorewall[1986]: Starting Shorewall....
<snip more shorewall messages>

Then we get the console text pushed in
Dec 10 10:11:49 wb kernel: Initializing cgroup subsys cpuset
Dec 10 10:11:48 wb shorewall[1986]: Running /sbin/iptables-restore...
Dec 10 10:11:49 wb kernel: Initializing cgroup subsys cpu
Dec 10 10:11:49 wb kernel: Linux version 2.6.38.7-desktop-1mnb2 (thomas@celeste.mandriva.com) (gcc version 4.6.0 20110513 (prerelease) (GCC) ) #1 SMP Sun May 22 19:38:58 UTC 2011
Dec 10 10:11:49 wb kernel: Command line: BOOT_IMAGE=md2011_0_64 root=LABEL=cooker nokmsboot   vga=0x0324  3
Dec 10 10:11:49 wb kernel: BIOS-provided physical RAM map:
Dec 10 10:11:49 wb kernel: BIOS-e820: 0000000000000000 - 0000000000098c00 (usable)
Comment 10 Bit Twister 2012-01-03 13:19:00 CET
clean install, applied updates, rebooted.
/var/log/messages has node name.

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 11 Bit Twister 2012-01-03 23:01:22 CET
Third system I did a clean install on has localhost instead of node name. :(
Other two clean installs has node name.

Other than actual hardware, the only difference between the third box is mysqld is running and eth1 is connected to a hub/switch.

# diff ifcfg-eth0 ifcfg-eth1
1c1
< DEVICE=eth0
---
> DEVICE=eth1
3c3
< IPADDR=192.168.1.200
---
> IPADDR=169.254.1.1
5c5
< GATEWAY=192.168.1.1
---
> GATEWAY=192.168.1.200
16d15
< NM_CONTROLLED=no
17a17
> PEERDNS=no

Resolution: FIXED => (none)
Status: RESOLVED => REOPENED

Comment 12 Colin Guthrie 2012-01-04 00:18:51 CET
What is the content of /etc/hostname on the affected machine?
Comment 13 Bit Twister 2012-01-04 01:34:54 CET
(In reply to comment #12)
> What is the content of /etc/hostname on the affected machine?

All three machines have localhost in /etc/hostname. Which I did not set that I know of. 

All systems have same /etc/hosts file and except for HOSTNAME all /etc/sysconfig/network looks like:

# cat /etc/sysconfig/network
GATEWAYDEV=eth0
GATEWAY=192.168.1.1
NEEDHOSTNAME=no
NETWORKING=yes
HOSTNAME=mtv.home.test
CRDA_DOMAIN=US


# host $(hostname)
mtv.home.test has address 192.168.1.200

# head -5 /etc/hosts
127.0.0.1 localhost
127.0.0.1 localhost.localdomain
192.168.1.100 wb2.home.test wb2
192.168.1.200 mtv.home.test mtv
192.168.1.132 wb.home.test wb


Frap, just booted wb2. and it is back to localhost in /var/log/messages.
Comment 14 Bit Twister 2012-01-04 01:51:45 CET
(In reply to comment #13)
> (In reply to comment #12)
> > What is the content of /etc/hostname on the affected machine?
> 
> All three machines have localhost in /etc/hostname. Which I did not set that I
> know of. 

> Frap, just booted wb2. and it is back to localhost in /var/log/messages.

Sorry, lost control of my mouse because ksmserver crashed.

removed /etc/hostname, rebooted and /var/log/messages has node name instead of localhost.

I remember disabling dhcpd on wb2 to see if that caused the problem on wb2, but it was ok. I re-enabled dhcpd and powered off.

On wb only thing I did was delete the wan0 connection in via mcc and rebooted.

Just checked in my VirtualBox guest. /etc/hostname was set localhost.
Removed it, rebooted, and it is fine.
Guillaume Rousse 2012-01-04 09:22:52 CET

CC: guillomovitch => (none)

Comment 15 Colin Guthrie 2012-01-04 10:01:59 CET
You shouldn't really remove this file, but rather "echo myhostname >/etc/hostname"... it's basically the new "standard" (i.e. cross distro) place to keep hostname configuration, but clearly various tools of ours do not update that file when updating the hostname in other places.

So likely this is fundamentally a drakxtools bug in some capacity. I'll try and dig into where we update hostname in the old place and make sure the new one is updated too!
Comment 16 Luc Menut 2012-01-04 10:18:28 CET
(In reply to comment #15)
> 
> So likely this is fundamentally a drakxtools bug in some capacity. I'll try and
> dig into where we update hostname in the old place and make sure the new one is
> updated too!

probably related to:
https://bugs.mageia.org/show_bug.cgi?id=2983
https://bugs.mageia.org/show_bug.cgi?id=2983#c12

I attached a patch that still need to be reviewed.
https://bugs.mageia.org/attachment.cgi?id=1143&action=diff

Hardware: x86_64 => All
CC: (none) => lmenut

Comment 17 Colin Guthrie 2012-01-04 11:51:27 CET
(In reply to comment #16)
> (In reply to comment #15)
> > 
> > So likely this is fundamentally a drakxtools bug in some capacity. I'll try and
> > dig into where we update hostname in the old place and make sure the new one is
> > updated too!
> 
> probably related to:
> https://bugs.mageia.org/show_bug.cgi?id=2983
> https://bugs.mageia.org/show_bug.cgi?id=2983#c12
> 
> I attached a patch that still need to be reviewed.
> https://bugs.mageia.org/attachment.cgi?id=1143&action=diff

Yup, certainly related...  I've actually just written a very similar patch... but a bit different. Will merge your one in too.

I'm gonna mark this as a duplicate of that other bug, but feel free to comment on this one again if needs be.

*** This bug has been marked as a duplicate of bug 2983 ***

Resolution: (none) => DUPLICATE
Status: REOPENED => RESOLVED


Note You need to log in before you can comment on or make changes to this bug.