diff options
author | Dan Williams <dcbw@redhat.com> | 2008-06-24 13:11:42 -0400 |
---|---|---|
committer | Adam Jackson <ajax@redhat.com> | 2008-06-24 13:11:42 -0400 |
commit | 6702e2a15992f4cb85dfa7ac8214125eb0a2bb2d (patch) | |
tree | b880a0d10278ee1c6f2b8d233e3357b8f4bce70b | |
parent | 2a827d26cfb10dc6b1203b77c0cc91dc838d97a3 (diff) |
Bug #14949: Don't use gethostbyname() for client IDs.
gethostbyname() will hit the network, which leads to DNS timeouts, which
leads to fail. Just use UUIDs.
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/sm_genid.c | 23 |
3 files changed, 36 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index 4a72c19..db2f3b9 100644 --- a/configure.ac +++ b/configure.ac @@ -35,6 +35,13 @@ AC_HEADER_STDC # Needed to check for TCP & IPv6 support and set flags appropriately XTRANS_CONNECTION_FLAGS +AC_ARG_WITH(libuuid, AC_HELP_STRING([--with-libuuid], [Build with libuuid support for client IDs])) +AM_CONDITIONAL(WITH_LIBUUID, test x"$with_libuuid" != xno) + +if test x"$with_uuid" != xno; then + PKG_CHECK_MODULES(LIBUUID, uuid) +fi + if test "x$GCC" = "xyes"; then GCC_WARNINGS="-Wall -Wpointer-arith -Wstrict-prototypes \ -Wmissing-prototypes -Wmissing-declarations \ diff --git a/src/Makefile.am b/src/Makefile.am index b44e623..dbfef37 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,10 +2,18 @@ lib_LTLIBRARIES=libSM.la AM_CFLAGS= -I${top_srcdir}/include $(SM_CFLAGS) $(XTRANS_CFLAGS) +if WITH_LIBUUID +AM_CFLAGS += $(LIBUUID_CFLAGS) -DHAVE_LIBUUID +endif + libSM_la_LDFLAGS = -version-number 6:0:0 -no-undefined libSM_la_LIBADD = $(SM_LIBS) $(XTRANS_LIBS) +if WITH_LIBUUID +libSM_la_LIBADD += $(LIBUUID_LIBS) +endif + libSM_la_SOURCES = \ SMlibint.h \ globals.h \ diff --git a/src/sm_genid.c b/src/sm_genid.c index 1d1e0a3..6f90a48 100644 --- a/src/sm_genid.c +++ b/src/sm_genid.c @@ -1,4 +1,3 @@ -/* $Xorg: sm_genid.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */ /* Copyright 1993, 1998 The Open Group @@ -25,7 +24,6 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ -/* $XFree86: xc/lib/SM/sm_genid.c,v 3.17 2003/07/09 15:27:28 tsi Exp $ */ /* * Author: Ralph Mor, X Consortium @@ -78,11 +76,31 @@ in this Software without prior written authorization from The Open Group. #define TCPCONN #endif +#if defined(HAVE_LIBUUID) +#include <uuid/uuid.h> +#endif + char * SmsGenerateClientID (smsConn) SmsConn smsConn; { +#if defined(HAVE_LIBUUID) + char *id; + char temp[256]; + uuid_t uuid; + + uuid_generate(uuid); + + temp[0] = '2'; + temp[1] = '\0'; + uuid_unparse_lower(uuid, &temp[1]); + + if ((id = malloc (strlen (temp) + 1)) != NULL) + strcpy (id, temp); + + return id; +#else #if defined(TCPCONN) || defined(STREAMSCONN) static const char hex[] = "0123456789abcdef"; char hostname[256]; @@ -187,4 +205,5 @@ SmsGenerateClientID (smsConn) #else return (NULL); #endif +#endif } |