Older versions of glibc (like that on RHEL 5) do not have the
le32toh() function exposed. We need this for handling the Active
Directory ID-mapping, so we'll copy these macros from endian.h on
a newer glibc.

This fixes the current broken RHEL 5 builds on master.
From d69308da6be663f0de4539c48de11af709059973 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgall...@redhat.com>
Date: Tue, 1 May 2012 16:30:42 -0400
Subject: [PATCH] Handle endianness issues on older systems

Older versions of glibc (like that on RHEL 5) do not have the
le32toh() function exposed. We need this for handling the Active
Directory ID-mapping, so we'll copy these macros from endian.h on
a newer glibc.
---
 Makefile.am                    |    1 +
 src/lib/idmap/sss_idmap_conv.c |    1 +
 src/util/sss_endian.h          |   70 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 72 insertions(+)
 create mode 100644 src/util/sss_endian.h

diff --git a/Makefile.am b/Makefile.am
index f5c1b940c079564e1173cffc8376f3997f33e06c..c46c3bf6ac1fd51462fbc36db1fc71e0520496b4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -337,6 +337,7 @@ dist_noinst_HEADERS = \
     src/util/murmurhash3.h \
     src/util/mmap_cache.h \
     src/util/atomic_io.h \
+    src/util/sss_endian.h \
     src/monitor/monitor.h \
     src/monitor/monitor_interfaces.h \
     src/responder/common/responder.h \
diff --git a/src/lib/idmap/sss_idmap_conv.c b/src/lib/idmap/sss_idmap_conv.c
index 83041efee38a9c789b5874a7b8f77c8c03c3cf13..815090da7a0b06aa8bf5ac266aa7db39726d2a96 100644
--- a/src/lib/idmap/sss_idmap_conv.c
+++ b/src/lib/idmap/sss_idmap_conv.c
@@ -30,6 +30,7 @@
 #include "lib/idmap/sss_idmap.h"
 #include "lib/idmap/sss_idmap_private.h"
 #include "util/util.h"
+#include "util/sss_endian.h"
 
 #define SID_ID_AUTHS 6
 #define SID_SUB_AUTHS 15
diff --git a/src/util/sss_endian.h b/src/util/sss_endian.h
new file mode 100644
index 0000000000000000000000000000000000000000..ed4b5ff10a0c954fc6611a59da6e4cb761226f29
--- /dev/null
+++ b/src/util/sss_endian.h
@@ -0,0 +1,70 @@
+/*
+    SSSD
+
+    Authors:
+        Stephen Gallagher <sgall...@redhat.com>
+
+    Copyright (C) 2012 Red Hat
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef SSS_ENDIAN_H_
+#define SSS_ENDIAN_H_
+
+#ifndef le32toh
+#include <byteswap.h>
+
+/* Copied from endian.h on glibc 2.15 */
+#ifdef __USE_BSD
+/* Conversion interfaces.  */
+# include <bits/byteswap.h>
+
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+#  define htobe16(x) __bswap_16 (x)
+#  define htole16(x) (x)
+#  define be16toh(x) __bswap_16 (x)
+#  define le16toh(x) (x)
+
+#  define htobe32(x) __bswap_32 (x)
+#  define htole32(x) (x)
+#  define be32toh(x) __bswap_32 (x)
+#  define le32toh(x) (x)
+
+#  define htobe64(x) __bswap_64 (x)
+#  define htole64(x) (x)
+#  define be64toh(x) __bswap_64 (x)
+#  define le64toh(x) (x)
+# else
+#  define htobe16(x) (x)
+#  define htole16(x) __bswap_16 (x)
+#  define be16toh(x) (x)
+#  define le16toh(x) __bswap_16 (x)
+
+#  define htobe32(x) (x)
+#  define htole32(x) __bswap_32 (x)
+#  define be32toh(x) (x)
+#  define le32toh(x) __bswap_32 (x)
+
+#  define htobe64(x) (x)
+#  define htole64(x) __bswap_64 (x)
+#  define be64toh(x) (x)
+#  define le64toh(x) __bswap_64 (x)
+# endif
+#endif /* __USE_BSD */
+
+#endif /* le32toh */
+
+
+#endif /* SSS_ENDIAN_H_ */
-- 
1.7.10

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/sssd-devel

Reply via email to