dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0089-CONFDB-Remove-old-libini-support.patch

71e593
From b66f8dc3bd4e89c424bef5953aeb70742f9656dd Mon Sep 17 00:00:00 2001
71e593
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
71e593
Date: Wed, 9 Jan 2019 14:19:26 +0100
71e593
Subject: [PATCH 89/89] CONFDB: Remove old libini support
71e593
71e593
Remove code code that uses libini older then v1
71e593
71e593
Related:
71e593
https://pagure.io/SSSD/sssd/issue/3439
71e593
71e593
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
71e593
---
71e593
 src/util/sss_ini.c | 111 +--------------------------------------------
71e593
 1 file changed, 1 insertion(+), 110 deletions(-)
71e593
71e593
diff --git a/src/util/sss_ini.c b/src/util/sss_ini.c
71e593
index 010b77889..cf61a1722 100644
71e593
--- a/src/util/sss_ini.c
71e593
+++ b/src/util/sss_ini.c
71e593
@@ -32,18 +32,9 @@
71e593
 #include "confdb/confdb_setup.h"
71e593
 #include "confdb/confdb_private.h"
71e593
 
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
 #include "ini_configobj.h"
71e593
-#else
71e593
-#include "collection.h"
71e593
-#include "collection_tools.h"
71e593
-#endif
71e593
-
71e593
 #include "ini_config.h"
71e593
 
71e593
-
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
-
71e593
 struct sss_ini_initdata {
71e593
     char **error_list;
71e593
     struct ref_array *ra_success_list;
71e593
@@ -59,25 +50,6 @@ struct sss_ini_initdata {
71e593
 #define sss_ini_get_const_string_config_value  ini_get_const_string_config_value
71e593
 #define sss_ini_get_config_obj                 ini_get_config_valueobj
71e593
 
71e593
-#else
71e593
-
71e593
-struct sss_ini_initdata {
71e593
-    struct collection_item *error_list;
71e593
-    struct collection_item *sssd_config;
71e593
-    struct collection_item *obj;
71e593
-    struct stat cstat;
71e593
-    int file;
71e593
-};
71e593
-
71e593
-#define sss_ini_get_sec_list                   get_section_list
71e593
-#define sss_ini_get_attr_list                  get_attribute_list
71e593
-#define sss_ini_get_const_string_config_value  get_const_string_config_value
71e593
-#define sss_ini_get_config_obj(secs,attrs,cfg,flag,attr) \
71e593
-    get_config_item(secs,attrs,cfg,attr)
71e593
-
71e593
-#endif
71e593
-
71e593
-
71e593
 /* Initialize data structure */
71e593
 
71e593
 struct sss_ini_initdata* sss_ini_initdata_init(TALLOC_CTX *mem_ctx)
71e593
@@ -92,17 +64,10 @@ struct sss_ini_initdata* sss_ini_initdata_init(TALLOC_CTX *mem_ctx)
71e593
 void sss_ini_close_file(struct sss_ini_initdata *init_data)
71e593
 {
71e593
     if (init_data == NULL) return;
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     if (init_data->file != NULL) {
71e593
         ini_config_file_destroy(init_data->file);
71e593
         init_data->file = NULL;
71e593
     }
71e593
-#else
71e593
-    if (init_data->file != -1) {
71e593
-        close(init_data->file);
71e593
-        init_data->file = -1;
71e593
-    }
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -112,35 +77,23 @@ void sss_ini_close_file(struct sss_ini_initdata *init_data)
71e593
 int sss_ini_config_file_open(struct sss_ini_initdata *init_data,
71e593
                              const char *config_file)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     return ini_config_file_open(config_file,
71e593
                                 INI_META_STATS,
71e593
                                 &init_data->file);
71e593
-#else
71e593
-    return check_and_open_readonly(config_file, &init_data->file, 0, 0,
71e593
-                                   S_IFREG|S_IRUSR, /* f r**------ */
71e593
-                                   S_IFMT|(ALLPERMS & ~(S_IWUSR|S_IXUSR)));
71e593
-#endif
71e593
 }
71e593
 
71e593
 int sss_ini_config_file_from_mem(void *data_buf,
71e593
                                  uint32_t data_len,
71e593
                                  struct sss_ini_initdata *init_data)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     return ini_config_file_from_mem(data_buf, strlen(data_buf),
71e593
                                    &init_data->file);
71e593
-#else
71e593
-    /* FIXME: Remove support for older libini versions */
71e593
-    return EINVAL;
71e593
-#endif
71e593
 }
71e593
 
71e593
 /* Check configuration file permissions */
71e593
 
71e593
 int sss_ini_config_access_check(struct sss_ini_initdata *init_data)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     return ini_config_access_check(init_data->file,
71e593
                                    INI_ACCESS_CHECK_MODE |
71e593
                                    INI_ACCESS_CHECK_UID |
71e593
@@ -149,9 +102,6 @@ int sss_ini_config_access_check(struct sss_ini_initdata *init_data)
71e593
                                    0, /* owned by root */
71e593
                                    S_IRUSR, /* r**------ */
71e593
                                    ALLPERMS & ~(S_IWUSR|S_IXUSR));
71e593
-#else
71e593
-    return EOK;
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -160,21 +110,11 @@ int sss_ini_config_access_check(struct sss_ini_initdata *init_data)
71e593
 
71e593
 int sss_ini_get_stat(struct sss_ini_initdata *init_data)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     init_data->cstat = ini_config_get_stat(init_data->file);
71e593
 
71e593
     if (!init_data->cstat) return EIO;
71e593
 
71e593
     return EOK;
71e593
-#else
71e593
-    int ret;
71e593
-
71e593
-    ret = fstat(init_data->file, &init_data->cstat);
71e593
-    if (ret != 0) {
71e593
-        return errno;
71e593
-    }
71e593
-    return EOK;
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -185,13 +125,8 @@ int sss_ini_get_mtime(struct sss_ini_initdata *init_data,
71e593
                       size_t timestr_len,
71e593
                       char *timestr)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     return snprintf(timestr, timestr_len, "%llu",
71e593
                     (long long unsigned)init_data->cstat->st_mtime);
71e593
-#else
71e593
-    return snprintf(timestr, timestr_len, "%llu",
71e593
-                    (long long unsigned)init_data->cstat.st_mtime);
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -200,7 +135,6 @@ int sss_ini_get_mtime(struct sss_ini_initdata *init_data,
71e593
 
71e593
 static void sss_ini_config_print_errors(char **error_list)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     unsigned count = 0;
71e593
 
71e593
     if (!error_list) {
71e593
@@ -211,9 +145,6 @@ static void sss_ini_config_print_errors(char **error_list)
71e593
         DEBUG(SSSDBG_FATAL_FAILURE, "%s\n", error_list[count]);
71e593
         count++;
71e593
     }
71e593
-#endif
71e593
-
71e593
-    return;
71e593
 }
71e593
 
71e593
 
71e593
@@ -225,7 +156,6 @@ int sss_ini_get_config(struct sss_ini_initdata *init_data,
71e593
                        const char *config_dir)
71e593
 {
71e593
     int ret;
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
 #ifdef HAVE_LIBINI_CONFIG_V1_3
71e593
     const char *patterns[] = { "^[^\\.].*\\.conf$", NULL };
71e593
     const char *sections[] = { ".*", NULL };
71e593
@@ -317,35 +247,7 @@ int sss_ini_get_config(struct sss_ini_initdata *init_data,
71e593
               "Using only main configuration file due to errors in merging\n");
71e593
     }
71e593
 #endif
71e593
-
71e593
     return ret;
71e593
-
71e593
-#else
71e593
-
71e593
-    /* Read the configuration into a collection */
71e593
-    ret = config_from_fd("sssd",
71e593
-                         init_data->file,
71e593
-                         config_file,
71e593
-                         &init_data->sssd_config,
71e593
-                         INI_STOP_ON_ANY,
71e593
-                         &init_data->error_list);
71e593
-
71e593
-    if (ret != EOK) {
71e593
-        DEBUG(SSSDBG_FATAL_FAILURE,
71e593
-                "Parse error reading configuration file [%s]\n",
71e593
-                 config_file);
71e593
-
71e593
-        print_file_parsing_errors(stderr, init_data->error_list);
71e593
-
71e593
-        free_ini_config_errors(init_data->error_list);
71e593
-        free_ini_config(init_data->sssd_config);
71e593
-
71e593
-        return ret;
71e593
-    }
71e593
-
71e593
-    return EOK;
71e593
-
71e593
-#endif
71e593
 }
71e593
 
71e593
 struct ref_array *
71e593
@@ -395,11 +297,7 @@ int sss_ini_check_config_obj(struct sss_ini_initdata *init_data)
71e593
 int sss_ini_get_int_config_value(struct sss_ini_initdata *init_data,
71e593
                                  int strict, int def, int *error)
71e593
 {
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     return ini_get_int_config_value(init_data->obj, strict, def, error);
71e593
-#else
71e593
-    return get_int_config_value(init_data->obj, strict, def, error);
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -409,14 +307,11 @@ int sss_ini_get_int_config_value(struct sss_ini_initdata *init_data,
71e593
 void sss_ini_config_destroy(struct sss_ini_initdata *init_data)
71e593
 {
71e593
     if (init_data == NULL) return;
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
+
71e593
     if (init_data->sssd_config != NULL) {
71e593
         ini_config_destroy(init_data->sssd_config);
71e593
         init_data->sssd_config = NULL;
71e593
     }
71e593
-#else
71e593
-    free_ini_config(init_data->sssd_config);
71e593
-#endif
71e593
 }
71e593
 
71e593
 
71e593
@@ -443,11 +338,7 @@ int sss_confdb_create_ldif(TALLOC_CTX *mem_ctx,
71e593
     size_t dn_size;
71e593
     size_t ldif_len;
71e593
     size_t attr_len;
71e593
-#ifdef HAVE_LIBINI_CONFIG_V1
71e593
     struct value_obj *obj = NULL;
71e593
-#else
71e593
-    struct collection_item *obj = NULL;
71e593
-#endif
71e593
     bool section_handled = true;
71e593
 
71e593
     if (only_section != NULL) {
71e593
-- 
71e593
2.19.1
71e593