GNOME Bugzilla – Bug 580676
compile problem on Solaris for GDM
Last modified: 2009-08-24 20:38:55 UTC
The file daemon/gdm-display-access-file.c references "HOST_NAME_MAX". However, this #define is not available on Solaris. On Solaris, the following similar #defines are available: ./limits.h:#define _POSIX_HOST_NAME_MAX 255 ./netdb.h:#define MAXHOSTNAMELEN 256 Would it be possible to change the code to use one of the above?
OS X 10.5 build of gdm-2.26.1 fails for same reason. We do have: /usr/include/limits.h:#define _POSIX_HOST_NAME_MAX 255 /usr/include/sys/param.h:#define MAXHOSTNAMELEN 256 /* max hostname size */ /usr/include/unistd.h:#define _SC_HOST_NAME_MAX 72 Interestingly, my manpage for gethostname() says "Host names are limited to {HOST_NAME_MAX} characters, not including the trailing null, currently 255."
Check on Ubuntu, it has _POSIX_HOST_NAME_MAX in <bits/posix1_lim.h>. In limits.h, it introduce this marco. #ifdef __USE_POSIX /* POSIX adds things to <limits.h>. */ # include <bits/posix1_lim.h> #endif Seems _POSIX_HOST_NAME_MAX are common for Solaris/OS X/Ubunutu.
According to http://developer.apple.com/documentation/Darwin/Reference/ManPages/man3/gethostname.3.html and http://docs.sun.com/app/docs/doc/816-5168/gethostname-3c?a=view a more appropriate solution might be calling getconf('HOST_NAME_MAX') in the configure script and adding it to config.h. You could also try sysconf('_SC_HOST_NAME_MAX') although I haven't been able to get that working on Linux. See also http://www.cyberciti.biz/tips/linux-hostname.html#comment-143644
Fedora also seems to have limits.h -> bits/posix1_lib.h, wherein _POSIX_HOST_NAME_MAX is defined
You can't trust _POSIX_HOST_NAME_MAX, though, as it the effective value may be smaller than that: martello:/usr/include% lsb_release -d Description: Debian GNU/Linux 5.0.2 (lenny) martello:/usr/include% grep -r HOST_NAME_MAX * bits/posix1_lim.h:#define _POSIX_HOST_NAME_MAX 255 bits/local_lim.h:#define HOST_NAME_MAX 64 martello:/usr/include% getconf HOST_NAME_MAX 64
How does following patch look like? diff --git a/configure.ac b/configure.ac index fffe6c7..da6a76c 100644 --- a/configure.ac +++ b/configure.ac @@ -325,6 +325,12 @@ AC_CHECK_FUNC(gethostbyname,,[ EXTRA_SLAVE_LIBS="$EXTRA_SLAVE_LIBS -lnsl" EXTRA_CHOOSER_LIBS="$EXTRA_CHOOSER_LIBS -lnsl" EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -lnsl"])]) +AC_CHECK_DECL(HOST_NAME_MAX, , + AC_CHECK_DECL(_POSIX_HOST_NAME_MAX, + AC_DEFINE(HOST_NAME_MAX, _POSIX_HOST_NAME_MAX, []), + AC_DEFINE(HOST_NAME_MAX, 256, [Define to 256 if neither have HOST_NAME_MAX nor _POSIX_HOST_NAME_MAX]), + [[#include <limits.h>]]), + [[#include <limits.h>]]) AC_CHECK_FUNC(sched_yield,[ AC_DEFINE(HAVE_SCHED_YIELD, 1, [Define if we have sched yield])],[ AC_CHECK_LIB(rt,sched_yield, [ I've tested this patch on Solaris and Ubuntu, works well as wish. Refer to http://msdn.microsoft.com/en-us/library/ms738527%28VS.85%29.aspx [quote] So if a buffer of 256 bytes is passed in the name parameter and the namelen parameter is set to 256, the buffer size will always be adequate. [/quote]
Using a system call to `getconf HOST_NAME_MAX` is probably the best solution. My FreeBSD system is currently offline so I cannot test this patch against that platform yet, but I will try and do so in the next few days.
Oops - sorry for the delay. On FreeBSD 7.2, this picks up the _POSIX_HOST_NAME_MAX variable OK.
Fixed in master.