After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 580676 - compile problem on Solaris for GDM
compile problem on Solaris for GDM
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
unspecified
Other opensolaris
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2009-04-29 02:00 UTC by Brian Cameron
Modified: 2009-08-24 20:38 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26



Description Brian Cameron 2009-04-29 02:00:35 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?
Comment 1 Daniel Macks 2009-07-28 05:21:45 UTC
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."
Comment 2 Halton Huo 2009-07-28 06:03:18 UTC
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.
Comment 3 David Adam 2009-07-28 07:22:59 UTC
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
Comment 4 Daniel Macks 2009-07-28 08:18:27 UTC
Fedora also seems to have limits.h -> bits/posix1_lib.h, wherein _POSIX_HOST_NAME_MAX is defined
Comment 5 David Adam 2009-07-28 10:08:03 UTC
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
Comment 6 Halton Huo 2009-07-29 04:13:53 UTC
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]
Comment 7 David Adam 2009-07-30 14:11:21 UTC
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.
Comment 8 David Adam 2009-08-16 02:45:19 UTC
Oops - sorry for the delay. On FreeBSD 7.2, this picks up the _POSIX_HOST_NAME_MAX variable OK.
Comment 9 Brian Cameron 2009-08-24 20:38:55 UTC
Fixed in master.