Bug 116466 - syslog does not get right hostname when dhcp is used
Summary: syslog does not get right hostname when dhcp is used
Status: VERIFIED FIXED
Alias: None
Product: SUSE LINUX 10.0
Classification: openSUSE
Component: Network (show other bugs)
Version: Beta 1
Hardware: Other All
: P5 - None : Normal
Target Milestone: ---
Assignee: Marius Tomaschewski
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on: 134160
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-12 12:51 UTC by Carsten Hoeger
Modified: 2019-02-08 08:40 UTC (History)
7 users (show)

See Also:
Found By: Other
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Patch to update the cached hostname in syslog-ng on SIGHUP (763 bytes, patch)
2006-02-08 02:32 UTC, Marius Tomaschewski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carsten Hoeger 2005-09-12 12:51:50 UTC
and that results in an invalid hostname in system log:

[...]

Sep 12 12:22:57 linux kernel: end_request: I/O error, dev fd0, sector 0
Sep 12 12:22:57 linux kernel: subfs: unsuccessful attempt to mount media (256)
Sep 12 12:23:00 linux bsadmin: starting up 
Sep 12 12:23:00 linux bsadmin: starting up 
Sep 12 12:23:01 linux abuild-bs: starting up 
Sep 12 12:23:01 linux abuild-bs: entering daemon mode 

[...]

although DHCLIENT_SET_HOSTNAME is set to "yes"

hurwitz:~ # grep SET_HOSTNAME /etc/sysconfig/network/dhcp
DHCLIENT_SET_HOSTNAME="yes"
Comment 1 Carsten Hoeger 2005-09-12 13:16:54 UTC
hurwitz:~ # cat /etc/HOSTNAME 
linux.site
Comment 2 Peter Poeml 2005-09-12 13:20:53 UTC
(The dhcp client never writes /etc/HOSTNAME. that file is only written by
YaST.)

What does /var/lib/dhcpcd/dhcpcd-eth0.info contain?
Comment 3 Carsten Hoeger 2005-09-12 13:23:33 UTC
IPADDR=10.10.0.19
NETMASK=255.255.0.0
NETWORK=10.10.0.0
BROADCAST=10.10.255.255
GATEWAY=10.10.0.8
HOSTNAME='hurwitz'
DOMAIN='suse.de'
NISDOMAIN='suse.de'
DNS=10.10.0.1,149.44.160.146,10.10.2.88
DNSSEARCH='suse.de nue.novell.com'
NTPSERVERS=149.44.160.50,149.44.160.54,149.44.160.1
WINSSERVERS=149.44.160.39
NISSERVERS=149.44.160.146,10.10.0.1,149.44.160.50
LPRSERVERS=149.44.160.33
DHCPSID=149.44.160.50
DHCPGIADDR=10.10.255.254
DHCPSIADDR=149.44.160.50
DHCPCHADDR=00:00:1C:B5:65:16
DHCPSHADDR=00:03:47:97:4E:3A
DHCPSNAME='Idun.suse.de'
LEASETIME=1296000
RENEWALTIME=648000
REBINDTIME=1134000
INTERFACE='eth0'
CLASSID='Linux 2.6.13-10-default i686'
CLIENTID=00:00:1C:B5:65:16
Comment 4 Peter Poeml 2005-09-12 13:28:10 UTC
and 'hostname -f'?
Comment 5 Carsten Hoeger 2005-09-12 13:30:31 UTC
hurwitz:~ # hostname -f
hurwitz.suse.de

Comment 6 Peter Poeml 2005-09-12 13:32:39 UTC
then all is right... but syslog needs a reload. 
Comment 7 Peter Poeml 2005-09-12 15:33:33 UTC
I think this is either not a bug, or we decided that it is not a bug. I
vaguely remember a discussion about remote logging, or how logfiles from
many machines are aggregated otherwise, and how the the machine name
matters there. 

I wonder whether the current behaviour is new since syslog is started
earlier than before 9.3, or if it has always been like this. Stephan, do
you know?
Comment 8 Thorsten Kukuk 2005-09-12 16:52:23 UTC
It doesn't matter if dhcp writes /etc/HOSTNAME or not in this case. 
But syslog should not use linux if another hostname is set later, else 
the syslog host will have useless informations (all clients reports as 
linux). 
Comment 9 Carsten Hoeger 2005-09-13 12:59:57 UTC
It seems like the current behaviour is somehow related to the kind of
installation . On a testsystem (minimal+X, boots into runlevel 3) the problem
does not exit.
Comment 10 Peter Poeml 2005-09-16 16:27:22 UTC
It would matter if dhcpcd writes /etc/HOSTNAME -- because dhcpcd actually uses that file. It contains 
the hostname which is sent with a DHCP request and which might be used by a DHCP server to register 
that name in a network via dynamic DNS updates.

Werner? Coolo?

(And I wonder, does the syslog host actually use a name as sent from the client? Doesn't it do DNS 
lookups instead?)
Comment 11 Dr. Werner Fink 2005-09-16 16:41:40 UTC
Hmmm ... Do you use syslog-ng or syslog?
Nevetheless, the old syslogd initiallize the hostname
with the help of gethostname only once.

The question then is: What service is started first, dhcp or syslog(-ng)?
Comment 12 Stephan Kulow 2005-09-17 09:30:11 UTC
in init3, syslog(-ng) always starts after network, in init5 there is 
earlysyslog which starts syslog before network if there are no network log 
targets defined. 
 
So: if the host name matters in syslog files even though you're only doing 
local logging, we need to some signaling to the syslog daemon when the 
hostname changes. If that's not possible: WONTFIX. 
Comment 13 Peter Poeml 2005-09-30 10:48:33 UTC
Christian, what do you think about adding 'rcsyslog reload' to
/etc/sysconfig/network/scripts/dhcpcd-hook ?
Comment 14 Christian Zoz 2005-09-30 12:41:25 UTC
Why not.

Do we know in dhcpcd-hook if the hostname was changed?

This should also be added to NetworkManager and friends or to dhclient.
Comment 15 Peter Poeml 2005-09-30 13:33:48 UTC
Roughly; we know if the IP address has changed.
I have added it for STABLE (it is in the sysconfig CVS).

Reassigning for NetworkManager.
Comment 16 Robert Love 2005-11-18 18:10:33 UTC
Timo: This is the same as bug #134160, no?
Comment 17 Timo Hoenig 2005-11-21 08:05:23 UTC
Not exactly, but #134160 relates since I expect dhcdbd not to set the domain name and host name, too.
Comment 18 Robert Love 2006-01-20 15:15:31 UTC
*** Bug 144324 has been marked as a duplicate of this bug. ***
Comment 19 Timo Hoenig 2006-01-20 15:27:50 UTC
hostname is still not being set in Beta1 in some situations.  Should be fixed by  Beta2.

Moving to 10.1 beta1.
Comment 20 Timo Hoenig 2006-01-20 15:28:11 UTC
I'll take care.
Comment 21 Timo Hoenig 2006-01-20 15:33:59 UTC
Sorry, I haven't read the bug carefully enough.

Reverting summary.
Comment 22 Heiko Rommel 2006-01-27 15:13:58 UTC
Apparently, syslog-ng does not update the hostname used for logging when signaled with HUP.

The current fix (reloading syslog) is useless unless we


a) _restart_ syslog

or

b) patch syslog-ng to update the hostname when signaled with HUP
Comment 23 Christian Zoz 2006-01-27 15:27:05 UTC
Please decide what to do and reaasign to me if i should change it to restart.

Will it be neccessary to change NetworkManager as well? I guess this problem it not important on systems using NM.
Comment 24 Timo Hoenig 2006-01-27 15:48:14 UTC
If required, we could add a dispatcher script.  Though, I do not think that this issue matters for NM's audience.
Comment 25 Anja Stock 2006-02-01 09:47:11 UTC
QA recommends to repair :-) So I reassign to Christian again
Comment 26 Christian Zoz 2006-02-01 11:16:35 UTC
would you mind to write something understandable?
repair syslog-ng?
rcnetwork repair? (do you mean restart?)

And who is QA in this case?
Comment 27 Anja Stock 2006-02-01 11:40:09 UTC
Our QA-Team tested. In person: Heiko.
Comment 28 Christian Zoz 2006-02-01 12:28:24 UTC
Then maybe Heiko will be able to explain, what we should do and why? I was asking the syslog-nt maintainer which solution he prefers.

Again the question from comment 22 and 23 was not answered. Back to mt.

Marius, is it a bug of syslog-nt that it does not reread hostname on HUP? Will that change? On the other side, is it ok to restart syslog or may that possibly lose log messages?

Changing reload -> restart is no problem for me. 

Marius (or someone else who knows syslog-ng), please answer. This week.
Comment 29 Marius Tomaschewski 2006-02-01 16:24:23 UTC
I've tested what happens to syslog-ng if the hostname changes.

The code looks like it calls gethostname (that returns the new one) for local
sources (unix sockets) and uses the cached DNS hostname of the source-socket
in case of inet sockets. This should work fine also without a HUP.

But in fact, this is not really the case - it uses a cached (the old) one.

I consider this as a bug, but while my first look into the source code, I was
not able to find the place where it happens and have to take a closer on it
(add a printf debugger) to provide a fix.

I'll try to provide a fix this week.
Comment 30 Marius Tomaschewski 2006-02-01 16:27:22 UTC
[...] of the source-socket in case of inet sockets if the message doesn't
contain one.
Comment 31 Marius Tomaschewski 2006-02-08 02:32:40 UTC
Created attachment 66916 [details]
Patch to update the cached hostname in syslog-ng on SIGHUP

Is this sufficient to update it on SIGHUP?

I overlooked a static keyword in a function
on my first search.
Comment 32 Marius Tomaschewski 2006-02-09 22:25:39 UTC
I've submitted syslog-ng that updates the hostname on SIGHUP to stable.

Let me know, what you plan for 10.0.
Comment 33 Anja Stock 2006-02-13 12:45:09 UTC
Marius, we should ship this together with the sysconfig update for 10.0. SWAMPID is 2965. Would you please submit patch and the patchinfo file?
Comment 34 Marius Tomaschewski 2006-02-13 16:18:57 UTC
Submitted package for 10.0 and pachinfo as:
/work/src/done/PATCHINFO/syslog-ng.patch.box 

DISTRIBUTION: 10.0-i386,10.0-ppc,10.0-x86_64
PACKAGE:  syslog-ng
PACKAGER: mt@suse.de
BUGZILLA: 116466
SWAMPID:  2965
CATEGORY: recommended
DESCRIPTION:
This update fixes the following problems:

- Syslog-ng continued to use old hostname after it was
  changed by dhcp. Fixed syslog-ng to update its cached
  hostname on SIGHUP (reload).

DESCRIPTION_DE:
Dieses Update behebt folgende Probleme:

- Syslog-ng verwendete weiterhin den alten Hostnamen,
  nachdem ein neuer von dhcp gesetzt wurde. Syslog-ng
  liest den Hostnamen nun beim SIGUP (reload) neu ein.
  
Comment 35 Christian Zoz 2006-02-13 16:47:08 UTC
There is a typo in the german description: 'SIGUP'
Comment 36 Anja Stock 2006-02-14 09:02:48 UTC
released
Comment 37 Swamp Workflow Management 2019-02-08 08:40:25 UTC
This is an autogenerated message for OBS integration:
This bug (116466) was mentioned in
https://build.opensuse.org/request/show/672696 15.1 / syslog-ng