On (28/08/13 13:11), Simo Sorce wrote: >On Wed, 2013-08-28 at 17:35 +0200, Lukas Slebodnik wrote: >> On (28/08/13 09:59), Simo Sorce wrote: >> >On Wed, 2013-08-28 at 15:31 +0200, Lukas Slebodnik wrote: >> >> +/* Endianness-compatibility for systems running older versions of >> >> glibc */ >> >> + >> >> +#ifndef le32toh >> >> +#ifdef HAVE_BYTESWAP_H >> >> +# include <byteswap.h> >> >> +#endif /* 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 /* le32toh */ >> >> + >> > >> >If byteswap is not defined does the rest of the define work ? >> > >> >In the code you replace byteswap is included unconditionally as I assume >> >it is the file that contains __BYTE_ORDER__ , __LITTLE_ENDIAN and other >> >definitions needed to reimplement le32toh, so the if byteswap.h is not >> >available I guess the rest of the ifdef will just fail ? >> > >> >maybe you should have instead: >> > >> >#ifndef le32toh >> >#ifndef HAVE_BYTESWAP_H >> >#error missing le32toh and byteswap.h >> >#else >> >/* support RHEL5 lack of definitions */ >> >... >> >... >> >#endif /* HAVE_BYTESWAP_H */ >> >#endif /* le32toh */ >> > >> Changed. >> >> I also changed patch with sss_strnlen >> from ++*len >> to (*len)++ >> >> Updated patches are attached > >Unfortunately my example code fooled you and now the code is missing >#include <byteswap.h> completely, add it in the #else branch and you >have my ack. > >Simo.
Sure, stupid mistake. LS
>From 2203c632ba7132f72a4c85a0750d78803958ca07 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> 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 | 57 ++++++++++++++++++++++++++ src/util/util.h | 19 --------- 8 files changed, 66 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 <endian.h> #include <errno.h> #include <limits.h> #include <stdbool.h> @@ -24,6 +23,7 @@ #include <sys/types.h> #include "util/util.h" +#include "util/sss_endian.h" #include <openssl/evp.h> #include <openssl/rand.h> 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 <endian.h> #include <errno.h> #include <limits.h> #include <stdbool.h> @@ -22,6 +21,7 @@ #include <sys/types.h> #include "util/util.h" +#include "util/sss_endian.h" #include "util/crypto/nss/nss_util.h" #include <prinit.h> 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 <stdlib.h> #include <stdint.h> -#include <endian.h> #include <string.h> -#include <byteswap.h> - -/* 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..952f8e1aa63d60626eafc60a4a7c88965b735cd2 --- /dev/null +++ b/src/util/sss_endian.h @@ -0,0 +1,57 @@ +/* + SSSD + + Authors: + Lukas Slebodnik <[email protected]> + + 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 <http://www.gnu.org/licenses/>. +*/ + +#ifndef SSS_ENDIAN_H_ +#define SSS_ENDIAN_H_ + +#ifdef HAVE_ENDIAN_H +# include <endian.h> +#elif defined HAVE_SYS_ENDIAN_H +# include <sys/endian.h> +#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 */ +#include <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 <byteswap.h> - -/* 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
>From 6ca375cd9d6d988ba9c322f1d9b36e278cd64e9f Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 08:31:17 +0200 Subject: [PATCH 2/7] CLIENT: Fix non gnu sss_strnlen implementation last argument of function sss_strnlen "size_t *len" is output variable. We need to increment value of size_t being pointed to by pointer instead of incrementing pointer. --- src/sss_client/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sss_client/common.c b/src/sss_client/common.c index 6639ae15600d6cd89abe671589ab0c9691eeaa49..d990861473b526e36420606002267b609a19cf93 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -984,7 +984,7 @@ errno_t sss_strnlen(const char *str, size_t maxlen, size_t *len) *len = 0; while (*len < maxlen) { if (str[*len] == '\0') break; - len++; + (*len)++; } #endif -- 1.8.3.1
>From fb512b198f9f29c887ae7eb9fea9d1c0083e3345 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 08:31:17 +0200 Subject: [PATCH 3/7] MONITOR: Move function declaration out of conditional build Function monitor_config_file_fallback was defined inside of conditional block "#ifdef HAVE_SYS_INOTIFY_H", but it was also used out of this block. This patch move declaration of function before start of conditional build section. --- src/monitor/monitor.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 7604b30988502fcea32ee81b936083a99d53c939..495f31e3487027884313c3eef87ea8d8a3f15028 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1636,6 +1636,12 @@ done: return ret; } +errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx, + struct mt_ctx *ctx, + const char *file, + monitor_reconf_fn fn, + bool ignore_missing); + #ifdef HAVE_SYS_INOTIFY_H static void process_config_file(struct tevent_context *ev, struct tevent_timer *te, @@ -1791,11 +1797,6 @@ done: talloc_free(tmp_ctx); } -errno_t monitor_config_file_fallback(TALLOC_CTX *mem_ctx, - struct mt_ctx *ctx, - const char *file, - monitor_reconf_fn fn, - bool ignore_missing); static void rewatch_config_file(struct tevent_context *ev, struct tevent_timer *te, struct timeval t, void *ptr) -- 1.8.3.1
>From 903d3842d5376d6c40a25901aba561b607461c68 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 08:31:17 +0200 Subject: [PATCH 4/7] UTIL: Explicitly include header file sys/socket.h We use constant AF_INET6 in util.c, but we do not explicitly include header file sys/socket.h. This header file was indirectly incuded by another header file netdb.h (netdb.h -> netinet/in.h -> sys/socket.h), but other platform can have other dependencies among header files. --- src/util/util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/util.c b/src/util/util.c index 63cffe85e145953d3b2f4f85e649d2a0ac5b1b83..4802967663cb1409d1ccad98a3841f7342e4d925 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -21,6 +21,7 @@ #include <ctype.h> #include <netdb.h> #include <poll.h> +#include <sys/socket.h> #include "talloc.h" #include "util/util.h" -- 1.8.3.1
>From 3c96aa63d1ee9860d7621571ad72798b12c89784 Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 08:31:18 +0200 Subject: [PATCH 5/7] MEMBEROF: Remove temporary workaround --- src/ldb_modules/memberof.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c index 79b33137b5ac45bda4bb5fc7efce4553f7227fe3..c26a13bb94bafe62299572565cab4b53c77f3d94 100644 --- a/src/ldb_modules/memberof.c +++ b/src/ldb_modules/memberof.c @@ -17,11 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* Temporary workaround, will be fixed in ldb upstream soon */ -#ifndef LDB_VERSION -#define LDB_VERSION "0.9.22" -#endif - #include <string.h> #include "ldb_module.h" #include "util/util.h" -- 1.8.3.1
>From 557e2d40dd72b90237569be3b1085bf9d6c6984e Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 08:31:18 +0200 Subject: [PATCH 6/7] IPA_HBAC: Explicitelly include header file time.h struct hbac_eval_req is defined in header file and it has attribute request_time with type time_t, but header file "time.h" was not included. It was not problem, because time.h was indirectly included by stdlib.h (stdlib.h -> sys/types.h -> time.h) in implementation files, but other platforms can have other dependencies among header files. --- src/providers/ipa/ipa_hbac.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/providers/ipa/ipa_hbac.h b/src/providers/ipa/ipa_hbac.h index 8bc2c4f90f32a83d14240abb4979ae265913ae6a..f43611351c8a5dfb20ca3d075f0bcd7bb71798c9 100644 --- a/src/providers/ipa/ipa_hbac.h +++ b/src/providers/ipa/ipa_hbac.h @@ -39,6 +39,7 @@ #include <stdint.h> #include <stdbool.h> +#include <time.h> /** Result of HBAC evaluation */ enum hbac_eval_result { -- 1.8.3.1
>From cdccd717dd91151650faa51843c31be92ad0c74a Mon Sep 17 00:00:00 2001 From: Lukas Slebodnik <[email protected]> Date: Wed, 28 Aug 2013 12:56:53 +0200 Subject: [PATCH 7/7] CONFIGURE: Get rid of bashism --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e23e7c078b5dd949f3cb6b9332e040313621ee08..511e8d6c8afbfb0cbf5aca076b460aa4c881e252 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ AC_SUBST([PRERELEASE_VERSION], AC_DEFINE([PRERELEASE_VERSION], "PRERELEASE_VERSION_NUMBER", [Prerelease version number of package]) -AM_CONDITIONAL([GIT_CHECKOUT], [git log -1 &>/dev/null]) +AM_CONDITIONAL([GIT_CHECKOUT], [git log -1 >/dev/null 2>&1]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) -- 1.8.3.1
_______________________________________________ sssd-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/sssd-devel
