[PATCH] use_fqdn with gethostname() not returning fqdn
Hi all! I came across this issue while I was setting up a central syslog-ng server that collects logs from several hosts in different domains. I wanted to use the use_fqdn option to distinguish every host in my logs better, but all I saw was just the plain hostname. Please find attached two patches, one against 1.6.7 and one against 1.9.4 that add support for fqdns. If gethostname() returns a name without dots it tries to lookup the fqdn of the host. Cheers, Sven -- Sven Wegener Gentoo Linux Developer http://www.gentoo.org/
Hi, Thanks for the contribution to syslog-ng and sorry for not answering so long. The problem I have with your patches that I'd prefer not to rely on getaddrinfo() functions as I'm a bit afraid of portability issues. Are there any other way (with gethostbyaddr for example) to determine network local name? On Sun, 2005-05-08 at 07:32 +0200, Sven Wegener wrote:
Hi all!
I came across this issue while I was setting up a central syslog-ng server that collects logs from several hosts in different domains. I wanted to use the use_fqdn option to distinguish every host in my logs better, but all I saw was just the plain hostname. Please find attached two patches, one against 1.6.7 and one against 1.9.4 that add support for fqdns. If gethostname() returns a name without dots it tries to lookup the fqdn of the host.
-- Bazsi
On Wed, May 18, 2005 at 12:25:11PM +0200, Balazs Scheidler wrote:
Hi,
Thanks for the contribution to syslog-ng and sorry for not answering so long.
The problem I have with your patches that I'd prefer not to rely on getaddrinfo() functions as I'm a bit afraid of portability issues. Are there any other way (with gethostbyaddr for example) to determine network local name?
Hi, gethostbyaddr is fine too. It does the same thing as getaddrinfo. We could also use gethostname and append the result from getdomainname to it, but POSIX does not specify the *domainname functions. I'll modify the patch to use gethostbyaddr instead of getaddrinfo when I'm back at home. Cheers, Sven -- Sven Wegener Gentoo Linux Developer http://www.gentoo.org/
On Wed, May 18, 2005 at 12:25:11PM +0200, Balazs Scheidler wrote:
Hi,
Thanks for the contribution to syslog-ng and sorry for not answering so long.
The problem I have with your patches that I'd prefer not to rely on getaddrinfo() functions as I'm a bit afraid of portability issues. Are there any other way (with gethostbyaddr for example) to determine network local name?
Hi again! Well, actualy gethostbyname is the function to go for. What I said in my last email is wrong, I was thinking about gethostbyname but I wrote gethostbyaddr. Please find attached two patches against latest snapshot from the 1.6 and 1.9 series. Downside of using gethostbyname is that it uses static memory for the result. We're copying the result to our own buffer so this is safe, but from what I saw in the source the 1.6 series seems to or has the ability to use threads. 1.9 does not to use threads itself, but eventlog does. Is there the chance of having two or more threads calling the hostname functions synchronously? I guess you can tell this better than me. Greetings, Sven -- Sven Wegener Gentoo Linux Developer http://www.gentoo.org/
On Wed, 2005-05-18 at 20:20 +0200, Sven Wegener wrote:
On Wed, May 18, 2005 at 12:25:11PM +0200, Balazs Scheidler wrote:
Hi,
Thanks for the contribution to syslog-ng and sorry for not answering so long.
The problem I have with your patches that I'd prefer not to rely on getaddrinfo() functions as I'm a bit afraid of portability issues. Are there any other way (with gethostbyaddr for example) to determine network local name?
Hi again!
Well, actualy gethostbyname is the function to go for. What I said in my last email is wrong, I was thinking about gethostbyname but I wrote gethostbyaddr. Please find attached two patches against latest snapshot from the 1.6 and 1.9 series.
Downside of using gethostbyname is that it uses static memory for the result. We're copying the result to our own buffer so this is safe, but from what I saw in the source the 1.6 series seems to or has the ability to use threads. 1.9 does not to use threads itself, but eventlog does. Is there the chance of having two or more threads calling the hostname functions synchronously? I guess you can tell this better than me.
Syslog-ng does not really use threads in neither 1.6 nor 1.9, it is needed by door support on Solaris, but the function running in the separate thread does nothing but acknowledge the message. (door_return) EventLog does not use threads on its own, it only allows using threads in an application using EventLog. I've committed a slightly changed patch to both syslog-ng 1.6 and 1.9. Thanks for your contribution. -- Bazsi
participants (2)
-
Balazs Scheidler
-
Sven Wegener