>From 2f15b1be164d30cd5909c9796fdb9ceff4a25117 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik Date: Wed, 28 Aug 2013 08:31:17 +0200 Subject: [PATCH 1/7] UTIL: Create new wraper header file sss_endian.h Some platform have header file endian.h and anothers have sys/endian.h. We nedd to use conditional build to handle it correctly, therefore new header file sss_endian.h was created. --- Makefile.am | 1 + configure.ac | 3 ++ src/lib/idmap/sss_idmap_conv.c | 1 + src/util/crypto/libcrypto/crypto_sha512crypt.c | 2 +- src/util/crypto/nss/nss_sha512crypt.c | 2 +- src/util/murmurhash3.c | 13 +----- src/util/sss_endian.h | 56 ++++++++++++++++++++++++++ src/util/util.h | 19 --------- 8 files changed, 65 insertions(+), 32 deletions(-) create mode 100644 src/util/sss_endian.h diff --git a/Makefile.am b/Makefile.am index c3f3c4a54953ff71a680ecdb5b8c8c2a6498e730..f9635f30ac0b0ab2caeefc6d56ffea8a0d355c94 100644 --- a/Makefile.am +++ b/Makefile.am @@ -386,6 +386,7 @@ dist_noinst_HEADERS = \ src/util/io.h \ src/util/util_errors.h \ src/util/strtonum.h \ + src/util/sss_endian.h \ src/util/sss_nss.h \ src/util/sss_ldap.h \ src/util/sss_python.h \ diff --git a/configure.ac b/configure.ac index b9b72e3d7cd3adf1bd127e6ae9546a460ee0055e..e23e7c078b5dd949f3cb6b9332e040313621ee08 100644 --- a/configure.ac +++ b/configure.ac @@ -73,6 +73,9 @@ AC_CHECK_HEADERS([security/pam_appl.h security/pam_misc.h security/pam_modules.h [AC_MSG_ERROR([PAM development libraries not installed])] ) +#Check for endian headers +AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h]) + #Set the NSS library install path AC_ARG_ENABLE([nsslibdir], [AS_HELP_STRING([--enable-nsslibdir], [Where to install nss libraries ($libdir)])], diff --git a/src/lib/idmap/sss_idmap_conv.c b/src/lib/idmap/sss_idmap_conv.c index ef93f2a9fb782fcba1bccacf100422d33bf65fee..fd06b23dd32edc9c88b0766cd22f53de92ee2eb1 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/crypto/libcrypto/crypto_sha512crypt.c b/src/util/crypto/libcrypto/crypto_sha512crypt.c index f4c3e0daee0807035f66ac212016d873acdcbb67..88628b686d8ced78e0c21a6b641086b673ca7fc4 100644 --- a/src/util/crypto/libcrypto/crypto_sha512crypt.c +++ b/src/util/crypto/libcrypto/crypto_sha512crypt.c @@ -12,7 +12,6 @@ #include "config.h" -#include #include #include #include @@ -24,6 +23,7 @@ #include #include "util/util.h" +#include "util/sss_endian.h" #include #include diff --git a/src/util/crypto/nss/nss_sha512crypt.c b/src/util/crypto/nss/nss_sha512crypt.c index 76eb8a635971d4c4f9d101e0d92f62b41a844907..2838c4716b2c8d94cacb35737725f4f63552c4aa 100644 --- a/src/util/crypto/nss/nss_sha512crypt.c +++ b/src/util/crypto/nss/nss_sha512crypt.c @@ -10,7 +10,6 @@ #include "config.h" -#include #include #include #include @@ -22,6 +21,7 @@ #include #include "util/util.h" +#include "util/sss_endian.h" #include "util/crypto/nss/nss_util.h" #include diff --git a/src/util/murmurhash3.c b/src/util/murmurhash3.c index 80e52ed565f8d567c7739c695d7b5d16923edea2..cab138e1761dfc2d6e3b74c8d355471c5cbfce57 100644 --- a/src/util/murmurhash3.c +++ b/src/util/murmurhash3.c @@ -8,19 +8,10 @@ #include #include -#include #include -#include - -/* support RHEL5 lack of definitions */ -#ifndef le32toh -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define le32toh(x) (x) -# else -# define le32toh(x) bswap_32 (x) -# endif -#endif +#include "config.h" +#include "util/sss_endian.h" static uint32_t rotl(uint32_t x, int8_t r) { diff --git a/src/util/sss_endian.h b/src/util/sss_endian.h new file mode 100644 index 0000000000000000000000000000000000000000..3f09632279a7575b512628dc97ec091cd6d83c7b --- /dev/null +++ b/src/util/sss_endian.h @@ -0,0 +1,56 @@ +/* + SSSD + + Authors: + Lukas Slebodnik + + Copyright (C) 2013 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 . +*/ + +#ifndef SSS_ENDIAN_H_ +#define SSS_ENDIAN_H_ + +#ifdef HAVE_ENDIAN_H +# include +#elif defined HAVE_SYS_ENDIAN_H +# include +#endif /* !HAVE_ENDIAN_H && !HAVE_SYS_ENDIAN_H */ + +/* Endianness-compatibility for systems running older versions of glibc */ + +#ifndef le32toh +#ifndef HAVE_BYTESWAP_H +#error missing le32toh and byteswap.h +#else /* defined HAVE_BYTESWAP_H */ + +/* support RHEL5 lack of definitions */ +/* Copied from endian.h on glibc 2.15 */ +#ifdef __USE_BSD +/* Conversion interfaces. */ +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define le32toh(x) (x) +# define htole32(x) (x) +# else +# define le32toh(x) __bswap_32 (x) +# define htole32(x) __bswap_32 (x) +# endif +#endif /* __USE_BSD */ + +#endif /* HAVE_BYTESWAP_H */ + +#endif /* le32toh */ + +#endif /* SSS_ENDIAN_H_ */ diff --git a/src/util/util.h b/src/util/util.h index d8aeb733e4dbe2db414be5caa43712cecccca7f9..e4d5c730db665343687c7446f4f7321936a99d3a 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -561,25 +561,6 @@ errno_t sss_br_lock_file(int fd, size_t start, size_t len, int num_tries, useconds_t wait); #include "io.h" -/* Endianness-compatibility for systems running older versions of glibc */ - -#ifndef le32toh -#include - -/* Copied from endian.h on glibc 2.15 */ -#ifdef __USE_BSD -/* Conversion interfaces. */ -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define le32toh(x) (x) -# define htole32(x) (x) -# else -# define le32toh(x) __bswap_32 (x) -# define htole32(x) __bswap_32 (x) -# endif -#endif /* __USE_BSD */ - -#endif /* le32toh */ - #ifdef HAVE_PAC_RESPONDER #define BUILD_WITH_PAC_RESPONDER true #else -- 1.8.3.1