diff options
author | Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> | 2014-07-28 15:11:20 +0300 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-07-29 16:48:30 +0200 |
commit | a81e80c817808f4bb41d5219b04dbf73c943821e (patch) | |
tree | 63dcb7c9d90f291e0fbe953110bb2301d42c45fb | |
parent | d9424a4d40f5f77e70c77d39f33ffed87370c21b (diff) | |
download | sssd-a81e80c817808f4bb41d5219b04dbf73c943821e.tar.gz sssd-a81e80c817808f4bb41d5219b04dbf73c943821e.tar.xz sssd-a81e80c817808f4bb41d5219b04dbf73c943821e.zip |
build: Reverse order of libini_config checks
Check for lowest versions of libini_config first, instead of the highest ones
in libini_config.m4. Define HAVE_LIBINI_CONFIG_V* for lower versions when
higher versions are present. Simplify preprocessor branching in sss_ini.c
accordingly.
This prepares libini_config.m4 for addition of a check for one more version of
libini_config.
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
-rw-r--r-- | src/external/libini_config.m4 | 26 | ||||
-rw-r--r-- | src/util/sss_ini.c | 24 |
2 files changed, 24 insertions, 26 deletions
diff --git a/src/external/libini_config.m4 b/src/external/libini_config.m4 index 13be9c2f4..f8c422f38 100644 --- a/src/external/libini_config.m4 +++ b/src/external/libini_config.m4 @@ -1,21 +1,21 @@ -PKG_CHECK_MODULES(INI_CONFIG_V1, [ - ini_config >= 1.0.0], [ +PKG_CHECK_MODULES(INI_CONFIG_V0, [ + ini_config >= 0.6.1], [ - INI_CONFIG_CFLAGS="$INI_CONFIG_V1_CFLAGS" - INI_CONFIG_LIBS="$INI_CONFIG_V1_LIBS" - AC_DEFINE_UNQUOTED(HAVE_LIBINI_CONFIG_V1, 1, [libini_config version greater than 1.0.0]) - ], [ - AC_MSG_WARN([libini_config-devel >= 1.0.0 not available, trying older version]) - PKG_CHECK_MODULES(INI_CONFIG_V0, [ - ini_config >= 0.6.1], [ + INI_CONFIG_CFLAGS="$INI_CONFIG_V0_CFLAGS" + INI_CONFIG_LIBS="$INI_CONFIG_V0_LIBS" + AC_DEFINE_UNQUOTED(HAVE_LIBINI_CONFIG_V0, 1, [libini_config version 0.6.1 or greater]) + PKG_CHECK_MODULES(INI_CONFIG_V1, [ + ini_config >= 1.0.0], [ - INI_CONFIG_CFLAGS="$INI_CONFIG_V0_CFLAGS" - INI_CONFIG_LIBS="$INI_CONFIG_V0_LIBS" - AC_DEFINE_UNQUOTED(HAVE_LIBINI_CONFIG_V0, 1, [libini_config version lesser than 1.0.0]) + INI_CONFIG_CFLAGS="$INI_CONFIG_V1_CFLAGS" + INI_CONFIG_LIBS="$INI_CONFIG_V1_LIBS" + AC_DEFINE_UNQUOTED(HAVE_LIBINI_CONFIG_V1, 1, [libini_config version 1.0.0 or greater]) ], [ - AC_MSG_ERROR([Please install libini_config-devel]) + AC_MSG_WARN([libini_config-devel >= 1.0.0 not available, using older version]) ] ) + ], [ + AC_MSG_ERROR([Please install libini_config-devel]) ] ) diff --git a/src/util/sss_ini.c b/src/util/sss_ini.c index 63b96f287..526ca31d4 100644 --- a/src/util/sss_ini.c +++ b/src/util/sss_ini.c @@ -34,11 +34,9 @@ #ifdef HAVE_LIBINI_CONFIG_V1 #include "ini_configobj.h" -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else #include "collection.h" #include "collection_tools.h" -#else -#error "Unsupported libini version" #endif #include "ini_config.h" @@ -61,7 +59,7 @@ struct sss_ini_initdata { -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else struct sss_ini_initdata { struct collection_item *error_list; @@ -99,7 +97,7 @@ void sss_ini_close_file(struct sss_ini_initdata *init_data) ini_config_file_destroy(init_data->file); init_data->file = NULL; } -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else if (init_data->file != -1) { close(init_data->file); init_data->file = -1; @@ -118,7 +116,7 @@ int sss_ini_config_file_open(struct sss_ini_initdata *init_data, return ini_config_file_open(config_file, INI_META_STATS, &init_data->file); -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else return check_and_open_readonly(config_file, &init_data->file, 0, 0, S_IFREG|S_IRUSR, /* f r**------ */ S_IFMT|(ALLPERMS & ~(S_IWUSR|S_IXUSR))); @@ -140,7 +138,7 @@ int sss_ini_config_access_check(struct sss_ini_initdata *init_data) 0, /* owned by root */ S_IRUSR, /* r**------ */ ALLPERMS & ~(S_IWUSR|S_IXUSR)); -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else return EOK; #endif } @@ -157,7 +155,7 @@ int sss_ini_get_stat(struct sss_ini_initdata *init_data) if (!init_data->cstat) return EIO; return EOK; -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else return fstat(init_data->file, &init_data->cstat); #endif @@ -174,7 +172,7 @@ int sss_ini_get_mtime(struct sss_ini_initdata *init_data, #ifdef HAVE_LIBINI_CONFIG_V1 return snprintf(timestr, timestr_len, "%llu", (long long unsigned)init_data->cstat->st_mtime); -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else return snprintf(timestr, timestr_len, "%llu", (long long unsigned)init_data->cstat.st_mtime); #endif @@ -248,7 +246,7 @@ int sss_ini_get_config(struct sss_ini_initdata *init_data, return ret; -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else /* Read the configuration into a collection */ ret = config_from_fd("sssd", @@ -309,7 +307,7 @@ int sss_ini_get_int_config_value(struct sss_ini_initdata *init_data, { #ifdef HAVE_LIBINI_CONFIG_V1 return ini_get_int_config_value(init_data->obj, strict, def, error); -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else return get_int_config_value(init_data->obj, strict, def, error); #endif } @@ -326,7 +324,7 @@ void sss_ini_config_destroy(struct sss_ini_initdata *init_data) ini_config_destroy(init_data->sssd_config); init_data->sssd_config = NULL; } -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else free_ini_config(init_data->sssd_config); #endif } @@ -356,7 +354,7 @@ int sss_confdb_create_ldif(TALLOC_CTX *mem_ctx, size_t attr_len; #ifdef HAVE_LIBINI_CONFIG_V1 struct value_obj *obj = NULL; -#elif defined(HAVE_LIBINI_CONFIG_V0) +#else struct collection_item *obj = NULL; #endif |