URL: https://github.com/SSSD/sssd/pull/79
Author: fidencio
 Title: #79: LIBSSS_CONFIG: Drop libsss_config
Action: opened

PR body:
"""
libssss_config has been used only by OpenLMI and the project has been
deprecated making, then, no sense to keep the support on SSSD.

Distros that, for some reason, are still packing and distributing
OpenLMI can stick to SSSD 1.14 branch.

Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com>
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/79/head:pr79
git checkout pr79
From c4a08ee4a5fe1fdf363ce15b305c71ef875392c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fiden...@redhat.com>
Date: Thu, 10 Nov 2016 18:31:02 +0100
Subject: [PATCH] LIBSSS_CONFIG: Drop libsss_config
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

libssss_config has been used only by OpenLMI and the project has been
deprecated making, then, no sense to keep the support on SSSD.

Distros that, for some reason, are still packing and distributing
OpenLMI can stick to SSSD 1.14 branch.

Signed-off-by: Fabiano Fidêncio <fiden...@redhat.com>
---
 Makefile.am                        |  47 --
 configure.ac                       |   5 -
 contrib/sssd.spec.in               |   1 -
 src/external/configlib.m4          |  12 -
 src/external/libaugeas.m4          |  10 -
 src/responder/ifp/ifp_components.c | 228 ----------
 src/responder/ifp/ifp_components.h |   8 -
 src/responder/ifp/ifp_iface.c      |   3 -
 src/tests/dlopen-tests.c           |   3 -
 src/tests/sss_config-tests.c       | 884 -------------------------------------
 src/util/sss_config.c              | 509 ---------------------
 src/util/sss_config.h              |  71 ---
 12 files changed, 1781 deletions(-)
 delete mode 100644 src/external/configlib.m4
 delete mode 100644 src/external/libaugeas.m4
 delete mode 100644 src/tests/sss_config-tests.c
 delete mode 100644 src/util/sss_config.c
 delete mode 100644 src/util/sss_config.h

diff --git a/Makefile.am b/Makefile.am
index e037930..0c7797b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -208,12 +208,6 @@ if BUILD_SSH
     non_interactive_check_based_tests += sysdb_ssh-tests
 endif
 
-if BUILD_IFP
-if BUILD_CONFIG_LIB
-    non_interactive_check_based_tests += sss_config-tests
-endif # BUILD_CONFIG_LIB
-endif # BUILD_IFP
-
 if BUILD_DBUS_TESTS
     non_interactive_check_based_tests += \
 	sbus_tests \
@@ -604,7 +598,6 @@ dist_noinst_HEADERS = \
     src/util/sss_ssh.h \
     src/util/sss_ini.h \
     src/util/sss_format.h \
-    src/util/sss_config.h \
     src/util/refcount.h \
     src/util/find_uid.h \
     src/util/user_info_msg.h \
@@ -1028,24 +1021,6 @@ SSSD_INTERNAL_LTLIBS = \
     libsss_child.la \
     $(NULL)
 
-if BUILD_IFP
-if BUILD_CONFIG_LIB
-pkglib_LTLIBRARIES += libsss_config.la
-libsss_config_la_SOURCES = \
-    src/util/sss_config.c
-libsss_config_la_CFLAGS = \
-    $(AM_CFLAGS) \
-    $(AUGEAS_CFLAGS) \
-    $(TALLOC_CFLAGS)
-libsss_config_la_LIBADD = \
-    $(AUGEAS_LIBS) \
-    $(TALLOC_LIBS) \
-    $(SSSD_INTERNAL_LTLIBS)
-libsss_config_la_LDFLAGS = \
-    -avoid-version
-endif # BUILD_CONFIG_LIB
-endif # BUILD_IFP
-
 lib_LTLIBRARIES = libipa_hbac.la \
                   libsss_idmap.la \
                   libsss_nss_idmap.la \
@@ -1387,11 +1362,6 @@ dist_dbuspolicy_DATA = \
     src/responder/ifp/org.freedesktop.sssd.infopipe.conf
 dist_dbusservice_DATA = \
     src/responder/ifp/org.freedesktop.sssd.infopipe.service
-
-if BUILD_CONFIG_LIB
-sssd_ifp_LDADD += libsss_config.la
-endif
-
 endif
 
 if BUILD_SECRETS
@@ -2094,23 +2064,6 @@ sbus_codegen_tests_LDADD = \
 
 endif # BUILD_DBUS_TESTS
 
-if BUILD_IFP
-if BUILD_CONFIG_LIB
-sss_config_tests_SOURCES = \
-    src/tests/sss_config-tests.c \
-    src/tests/common.c
-sss_config_tests_CFLAGS = \
-    $(AM_CFLAGS) \
-    $(CHECK_CFLAGS)
-sss_config_tests_LDADD = \
-    $(SSSD_LIBS) \
-    $(CHECK_LIBS) \
-    $(SSSD_INTERNAL_LTLIBS) \
-    libsss_config.la \
-    libsss_test_common.la
-endif # BUILD_CONFIG_LIB
-endif # BUILD_IFP
-
 if HAVE_CMOCKA
 
 TEST_MOCK_RESP_OBJ = \
diff --git a/configure.ac b/configure.ac
index d3ef1e1..d48f08c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,7 +195,6 @@ m4_include([src/external/signal.m4])
 m4_include([src/external/inotify.m4])
 m4_include([src/external/samba.m4])
 m4_include([src/external/sasl.m4])
-m4_include([src/external/configlib.m4])
 m4_include([src/external/libnfsidmap.m4])
 m4_include([src/external/cwrap.m4])
 m4_include([src/external/libresolv.m4])
@@ -208,10 +207,6 @@ if test x$with_secrets = xyes; then
     m4_include([src/external/libjansson.m4])
 fi
 
-if test x$build_config_lib = xyes; then
-    m4_include([src/external/libaugeas.m4])
-fi
-
 WITH_UNICODE_LIB
 if test x$unicode_lib = xlibunistring; then
     m4_include([src/external/libunistring.m4])
diff --git a/contrib/sssd.spec.in b/contrib/sssd.spec.in
index 62f3e41..2917629 100644
--- a/contrib/sssd.spec.in
+++ b/contrib/sssd.spec.in
@@ -943,7 +943,6 @@ done
 # InfoPipe DBus plumbing
 %{_sysconfdir}/dbus-1/system.d/org.freedesktop.sssd.infopipe.conf
 %{_datadir}/dbus-1/system-services/org.freedesktop.sssd.infopipe.service
-%{_libdir}/%{name}/libsss_config.so
 
 %files -n libsss_simpleifp
 %defattr(-,root,root,-)
diff --git a/src/external/configlib.m4 b/src/external/configlib.m4
deleted file mode 100644
index ad6c1a9..0000000
--- a/src/external/configlib.m4
+++ /dev/null
@@ -1,12 +0,0 @@
-AC_ARG_ENABLE([config-lib],
-              [AS_HELP_STRING([--disable-config-lib],
-                              [do not build internal config library])],
-              [build_config_lib=$enableval],
-              [build_config_lib=yes])
-
-AM_CONDITIONAL([BUILD_CONFIG_LIB],
-               [test x$build_config_lib = xyes])
-
-AM_COND_IF([BUILD_CONFIG_LIB],
-           [AC_DEFINE_UNQUOTED(HAVE_CONFIG_LIB, 1,
-            [Build with internal config library])])
\ No newline at end of file
diff --git a/src/external/libaugeas.m4 b/src/external/libaugeas.m4
deleted file mode 100644
index 29a7935..0000000
--- a/src/external/libaugeas.m4
+++ /dev/null
@@ -1,10 +0,0 @@
-AC_SUBST(AUGEAS_CFLAGS)
-AC_SUBST(AUGEAS_LIBS)
-
-PKG_CHECK_MODULES(AUGEAS,
-    augeas >= 1.0.0,
-    ,
-    AC_MSG_ERROR([
-Please install augeas-devel or disable this dependency
-by specifying --disable-config-lib when running configure.])
-    )
diff --git a/src/responder/ifp/ifp_components.c b/src/responder/ifp/ifp_components.c
index 38707c1..498061d 100644
--- a/src/responder/ifp/ifp_components.c
+++ b/src/responder/ifp/ifp_components.c
@@ -30,10 +30,6 @@
 #include "responder/common/responder.h"
 #include "responder/ifp/ifp_components.h"
 
-#ifdef HAVE_CONFIG_LIB
-#include "util/sss_config.h"
-#endif
-
 #define PATH_MONITOR    IFP_PATH_COMPONENTS "/monitor"
 #define PATH_RESPONDERS IFP_PATH_COMPONENTS "/Responders"
 #define PATH_BACKENDS   IFP_PATH_COMPONENTS "/Backends"
@@ -462,230 +458,6 @@ int ifp_find_backend_by_name(struct sbus_request *dbus_req,
     return iface_ifp_FindBackendByName_finish(dbus_req, result);
 }
 
-int ifp_component_enable(struct sbus_request *dbus_req, void *data)
-{
-#ifndef HAVE_CONFIG_LIB
-    return sbus_request_fail_and_finish(dbus_req,
-                sbus_error_new(dbus_req, DBUS_ERROR_NOT_SUPPORTED, NULL));
-#else
-    struct ifp_ctx *ctx = NULL;
-    DBusError *error = NULL;
-    const char *path = dbus_message_get_path(dbus_req->message);
-    char *name = NULL;
-    enum component_type type;
-    struct sss_config_ctx *config_ctx = NULL;
-    errno_t ret;
-
-    ctx = talloc_get_type(data, struct ifp_ctx);
-    if (ctx == NULL) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Invalid ifp context!\n");
-        ret = EINVAL;
-        goto done;
-    }
-
-    ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
-                                            path, &type, &name);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    config_ctx = sss_config_open(dbus_req, NULL, SSSD_CONFIG_FILE);
-    if (config_ctx == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    switch (type) {
-    case COMPONENT_MONITOR:
-        error = sbus_error_new(dbus_req, DBUS_ERROR_NOT_SUPPORTED, NULL);
-        goto done;
-        break;
-    case COMPONENT_RESPONDER:
-        ret = sss_config_service_enable(config_ctx, name);
-        break;
-    case COMPONENT_BACKEND:
-        ret = sss_config_domain_enable(config_ctx, name);
-        break;
-    }
-
-    if (ret != EOK) {
-        goto done;
-    }
-
-    ret = sss_config_save(config_ctx);
-    if (ret != EOK) {
-        goto done;
-    }
-
-done:
-    sss_config_close(&config_ctx);
-
-    if (ret == ENOMEM) {
-        return sbus_request_fail_and_finish(dbus_req, NULL);
-    } else if (error != NULL) {
-        return sbus_request_fail_and_finish(dbus_req, error);
-    } else if (ret != EOK) {
-        error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED, "%s", strerror(ret));
-        return sbus_request_fail_and_finish(dbus_req, error);
-    }
-
-    return iface_ifp_components_Enable_finish(dbus_req);
-#endif
-}
-
-int ifp_component_disable(struct sbus_request *dbus_req, void *data)
-{
-#ifndef HAVE_CONFIG_LIB
-    return sbus_request_fail_and_finish(dbus_req,
-                sbus_error_new(dbus_req, DBUS_ERROR_NOT_SUPPORTED, NULL));
-#else
-    struct ifp_ctx *ctx = NULL;
-    DBusError *error = NULL;
-    const char *path = dbus_message_get_path(dbus_req->message);
-    char *name = NULL;
-    enum component_type type;
-    struct sss_config_ctx *config_ctx = NULL;
-    errno_t ret;
-
-    ctx = talloc_get_type(data, struct ifp_ctx);
-    if (ctx == NULL) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Invalid ifp context!\n");
-        ret = EINVAL;
-        goto done;
-    }
-
-    ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
-                                            path, &type, &name);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    config_ctx = sss_config_open(dbus_req, NULL, SSSD_CONFIG_FILE);
-    if (config_ctx == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    switch (type) {
-    case COMPONENT_MONITOR:
-        error = sbus_error_new(dbus_req, DBUS_ERROR_NOT_SUPPORTED, NULL);
-        goto done;
-        break;
-    case COMPONENT_RESPONDER:
-        ret = sss_config_service_disable(config_ctx, name);
-        break;
-    case COMPONENT_BACKEND:
-        ret = sss_config_domain_disable(config_ctx, name);
-        break;
-    }
-
-    if (ret != EOK) {
-        goto done;
-    }
-
-    ret = sss_config_save(config_ctx);
-    if (ret != EOK) {
-        goto done;
-    }
-
-done:
-    sss_config_close(&config_ctx);
-
-    if (ret == ENOMEM) {
-        return sbus_request_fail_and_finish(dbus_req, NULL);
-    } else if (error != NULL) {
-        return sbus_request_fail_and_finish(dbus_req, error);
-    } else if (ret != EOK) {
-        error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED, "%s", strerror(ret));
-        return sbus_request_fail_and_finish(dbus_req, error);
-    }
-
-    return iface_ifp_components_Disable_finish(dbus_req);
-#endif
-}
-
-int ifp_component_change_debug_level(struct sbus_request *dbus_req,
-                                     void *data,
-                                     uint32_t arg_new_level)
-{
-#ifndef HAVE_CONFIG_LIB
-    return sbus_request_fail_and_finish(dbus_req,
-                sbus_error_new(dbus_req, DBUS_ERROR_NOT_SUPPORTED, NULL));
-#else
-    struct ifp_ctx *ctx = NULL;
-    DBusError *error = NULL;
-    const char *path = dbus_message_get_path(dbus_req->message);
-    char *name = NULL;
-    enum component_type type;
-    struct sss_config_ctx *config_ctx = NULL;
-    const char *section = NULL;
-    errno_t ret;
-
-    ctx = talloc_get_type(data, struct ifp_ctx);
-    if (ctx == NULL) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "Invalid ifp context!\n");
-        ret = EINVAL;
-        goto done;
-    }
-
-    ret = check_and_get_component_from_path(dbus_req, ctx->rctx->cdb,
-                                            path, &type, &name);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    switch (type) {
-    case COMPONENT_MONITOR:
-        section = "sssd";
-        break;
-    case COMPONENT_RESPONDER:
-        section = name;
-        break;
-    case COMPONENT_BACKEND:
-        section = talloc_asprintf(dbus_req, "domain/%s", name);
-        break;
-    }
-
-    if (section == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    config_ctx = sss_config_open(dbus_req, NULL, SSSD_CONFIG_FILE);
-    if (config_ctx == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    ret = sss_config_set_debug_level(config_ctx, section, arg_new_level);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    ret = sss_config_save(config_ctx);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    ret = change_debug_level_tmp(ctx->rctx->cdb, name, type, arg_new_level);
-    if (ret != EOK) {
-        goto done;
-    }
-
-done:
-    sss_config_close(&config_ctx);
-
-    if (ret == ENOMEM) {
-        return sbus_request_fail_and_finish(dbus_req, NULL);
-    } else if (ret != EOK) {
-        error = sbus_error_new(dbus_req, DBUS_ERROR_FAILED, "%s", strerror(ret));
-        return sbus_request_fail_and_finish(dbus_req, error);
-    }
-
-    return iface_ifp_components_ChangeDebugLevel_finish(dbus_req);
-#endif
-}
-
 int ifp_component_change_debug_level_tmp(struct sbus_request *dbus_req,
                                          void *data,
                                          uint32_t arg_new_level)
diff --git a/src/responder/ifp/ifp_components.h b/src/responder/ifp/ifp_components.h
index 7ccac7f..c73cb37 100644
--- a/src/responder/ifp/ifp_components.h
+++ b/src/responder/ifp/ifp_components.h
@@ -44,14 +44,6 @@ int ifp_find_backend_by_name(struct sbus_request *dbus_req,
 
 /* org.freedesktop.sssd.infopipe.Components */
 
-int ifp_component_enable(struct sbus_request *dbus_req, void *data);
-
-int ifp_component_disable(struct sbus_request *dbus_req, void *data);
-
-int ifp_component_change_debug_level(struct sbus_request *dbus_req,
-                                     void *data,
-                                     uint32_t arg_new_level);
-
 int ifp_component_change_debug_level_tmp(struct sbus_request *dbus_req,
                                          void *data,
                                          uint32_t arg_new_level);
diff --git a/src/responder/ifp/ifp_iface.c b/src/responder/ifp/ifp_iface.c
index ff306ad..d0382e9 100644
--- a/src/responder/ifp/ifp_iface.c
+++ b/src/responder/ifp/ifp_iface.c
@@ -47,9 +47,6 @@ struct iface_ifp iface_ifp = {
 
 struct iface_ifp_components iface_ifp_components = {
     { &iface_ifp_components_meta, 0 },
-    .Enable = ifp_component_enable,
-    .Disable = ifp_component_disable,
-    .ChangeDebugLevel = ifp_component_change_debug_level,
     .ChangeDebugLevelTemporarily = ifp_component_change_debug_level_tmp,
     .get_name = ifp_component_get_name,
     .get_debug_level = ifp_component_get_debug_level,
diff --git a/src/tests/dlopen-tests.c b/src/tests/dlopen-tests.c
index 520c91f..d11ae96 100644
--- a/src/tests/dlopen-tests.c
+++ b/src/tests/dlopen-tests.c
@@ -110,9 +110,6 @@ struct so {
     { "_py3sss_murmur.so", { LIBPFX"_py3sss_murmur.so", NULL } },
     { "_py3sss_nss_idmap.so", { LIBPFX"_py3sss_nss_idmap.so", NULL } },
 #endif
-#ifdef HAVE_CONFIG_LIB
-    { "libsss_config.so", { LIBPFX"libsss_config.so", NULL } },
-#endif
 #ifdef BUILD_NFS_IDMAP
     { "sss.so", { LIBPFX"sss.so", NULL } },
 #endif
diff --git a/src/tests/sss_config-tests.c b/src/tests/sss_config-tests.c
deleted file mode 100644
index 1b26089..0000000
--- a/src/tests/sss_config-tests.c
+++ /dev/null
@@ -1,884 +0,0 @@
-/*
-    Authors:
-        Pavel Březina <pbrez...@redhat.com>
-
-    Copyright (C) 2014 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/>.
-*/
-
-#include <check.h>
-#include <stdio.h>
-#include <talloc.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-#include "util/util.h"
-#include "util/sss_config.h"
-#include "tests/common.h"
-#include "tests/common_check.h"
-
-#define TEST_SUBDIR "test_sss_config"
-#define TEST_FILE TEST_SUBDIR "/sss_config_test.conf"
-#define TEST_FILE_BACKUP TEST_FILE ".augsave"
-
-/* input files */
-
-const char *test_orig =
-"[sssd]\n\
-services = nss, pam\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_svc_one =
-"[sssd]\n\
-services = nss\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_svc_empty =
-"[sssd]\n\
-services =\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_svc_missing =
-"[sssd]\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_dom_empty =
-"[sssd]\n\
-services = nss, pam\n\
-domains =\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_dom_missing =
-"[sssd]\n\
-services = nss, pam\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *test_dom_two =
-"[sssd]\n\
-services = nss, pam\n\
-domains = LDAP, IPA\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-/* expected */
-
-const char *exp_debug_level_exist =
-"[sssd]\n\
-services = nss, pam\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0330\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_debug_level_notexist =
-"[sssd]\n\
-services = nss, pam\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n\
-[nss]\n\
-debug_level=0x0330\n";
-
-const char *exp_svc =
-"[sssd]\n\
-services = nss, pam, pac\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_empty =
-"[sssd]\n\
-services =pac\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_missing =
-"[sssd]\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-services=pac\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_disable =
-"[sssd]\n\
-services = pam\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_disable_one =
-"[sssd]\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_disable_empty =
-"[sssd]\n\
-services =\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_svc_disable_missing =
-"[sssd]\n\
-domains = LDAP\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom =
-"[sssd]\n\
-services = nss, pam\n\
-domains = LDAP, IPA\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom_empty =
-"[sssd]\n\
-services = nss, pam\n\
-domains =IPA\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom_missing =
-"[sssd]\n\
-services = nss, pam\n\
-debug_level = 0x0ff0\n\
-domains=IPA\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom_disable =
-"[sssd]\n\
-services = nss, pam\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom_disable_two =
-"[sssd]\n\
-services = nss, pam\n\
-domains = IPA\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-const char *exp_dom_disable_empty =
-"[sssd]\n\
-services = nss, pam\n\
-domains =\n\
-debug_level = 0x0ff0\n\
-[domain/LDAP]\n\
-debug_level = 0x0ff0\n\
-[domain/IPA]\n\
-debug_level = 0x0ff0\n";
-
-struct sss_config_ctx *config_ctx;
-
-static bool
-check_file_content(const char *filename, const char *expected)
-{
-    FILE *file = NULL;
-    size_t i;
-    int c;
-    bool result;
-
-    file = fopen(filename, "r");
-    fail_if(file == NULL, "unable to open test file");
-
-    i = 0;
-    while ((c = fgetc(file)) != EOF) {
-        if (c != expected[i]) {
-            printf("\nnot match: %d %c == %d %c\n", c, c, expected[i], expected[i]);
-            result = false;
-            goto done;
-        }
-
-        i++;
-    }
-
-    if (expected[i] != '\0') {
-        printf("\nnot end: %d %c == %d %c\n", c, c, expected[i], expected[i]);
-        result = false;
-        goto done;
-    }
-
-    result = true;
-
-done:
-    fclose(file);
-    return result;
-}
-
-static void test_setup(const char *configuration)
-{
-    FILE *file = NULL;
-    size_t ret;
-
-    file = fopen(TEST_FILE, "w+");
-    fail_if(file == NULL, "unable to create test file");
-
-    ret = fputs(configuration, file);
-    fail_if(ret == EOF, "unable to write test file");
-
-    fail_if(fclose(file) != 0, "unable to close test file");
-
-    config_ctx = sss_config_open(NULL, TEST_DIR, TEST_FILE);
-    fail_if(config_ctx == NULL, "config_ctx is NULL");
-}
-
-static void setup(void)
-{
-    errno_t ret;
-
-    ret = mkdir(TEST_SUBDIR, S_IRWXU);
-    if (ret != EOK) {
-        ret = errno;
-        fail("unable to create test dir [%d]: %s", ret, strerror(ret));
-    }
-
-    ck_leak_check_setup();
-}
-
-static void teardown(void)
-{
-    errno_t ret;
-
-    sss_config_close(&config_ctx);
-    fail_if(config_ctx != NULL, "config_ctx is not NULL");
-
-    unlink(TEST_FILE);
-    unlink(TEST_FILE_BACKUP);
-
-    ret = rmdir(TEST_SUBDIR);
-    if (ret != EOK) {
-        ret = errno;
-        fail("unable to remove test dir [%d]: %s", ret, strerror(ret));
-    }
-
-    ck_leak_check_teardown();
-}
-
-START_TEST(test_sss_config_set_debug_level_exist)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_set_debug_level(config_ctx, "domain/LDAP", 0x0330);
-    fail_if(ret != EOK, "unable change configuration");
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration");
-
-    result = check_file_content(TEST_FILE, exp_debug_level_exist);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_set_debug_level_notexist)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_set_debug_level(config_ctx, "nss", 0x0330);
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_debug_level_notexist);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_enabled)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_service_is_enabled(config_ctx, "nss", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == false, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disabled)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_service_is_enabled(config_ctx, "pac", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disabled_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_empty);
-
-    ret = sss_config_service_is_enabled(config_ctx, "pac", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disabled_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_missing);
-
-    ret = sss_config_service_is_enabled(config_ctx, "pac", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_enable)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_service_enable(config_ctx, "pac");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_enable_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_empty);
-
-    ret = sss_config_service_enable(config_ctx, "pac");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_empty);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_svc_empty);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_enable_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_missing);
-
-    ret = sss_config_service_enable(config_ctx, "pac");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_missing);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_svc_missing);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disable)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_service_disable(config_ctx, "nss");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_disable);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disable_one)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_one);
-
-    ret = sss_config_service_disable(config_ctx, "nss");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_disable_one);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_svc_one);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disable_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_empty);
-
-    ret = sss_config_service_disable(config_ctx, "nss");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_disable_empty);
-    fail_if(result == false, "file does not match");
-
-    /* no backup file created */
-}
-END_TEST
-
-START_TEST(test_sss_config_service_disable_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_svc_missing);
-
-    ret = sss_config_service_disable(config_ctx, "nss");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_svc_disable_missing);
-    fail_if(result == false, "file does not match");
-
-    /* no backup file created */
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_enabled)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_domain_is_enabled(config_ctx, "LDAP", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == false, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disabled)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_domain_is_enabled(config_ctx, "AD", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disabled_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_empty);
-
-    ret = sss_config_domain_is_enabled(config_ctx, "LDAP", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disabled_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_missing);
-
-    ret = sss_config_domain_is_enabled(config_ctx, "LDAP", &result);
-    fail_if(ret != EOK, "unable to read configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    fail_if(result == true, "wrong result");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_enable)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_domain_enable(config_ctx, "IPA");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_enable_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_empty);
-
-    ret = sss_config_domain_enable(config_ctx, "IPA");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_empty);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_dom_empty);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_enable_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_missing);
-
-    ret = sss_config_domain_enable(config_ctx, "IPA");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_missing);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_dom_missing);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disable)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_orig);
-
-    ret = sss_config_domain_disable(config_ctx, "LDAP");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_disable);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_orig);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disable_two)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_two);
-
-    ret = sss_config_domain_disable(config_ctx, "LDAP");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_disable_two);
-    fail_if(result == false, "file does not match");
-
-    result = check_file_content(TEST_FILE_BACKUP, test_dom_two);
-    fail_if(result == false, "backup file does not match");
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disable_empty)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_empty);
-
-    ret = sss_config_domain_disable(config_ctx, "LDAP");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_disable_empty);
-    fail_if(result == false, "file does not match");
-
-    /* no backup file created */
-}
-END_TEST
-
-START_TEST(test_sss_config_domain_disable_missing)
-{
-    errno_t ret;
-    bool result;
-
-    test_setup(test_dom_missing);
-
-    ret = sss_config_domain_disable(config_ctx, "LDAP");
-    fail_if(ret != EOK, "unable change configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    ret = sss_config_save(config_ctx);
-    fail_if(ret != EOK, "unable save configuration [%d]: %s",
-                        ret, strerror(ret));
-
-    result = check_file_content(TEST_FILE, exp_dom_disable);
-    fail_if(result == false, "file does not match");
-
-    /* no backup file created */
-}
-END_TEST
-
-Suite *sss_config_suite(void)
-{
-    Suite *s = suite_create("sss_config");
-    TCase *tc = tcase_create("sss_config");
-
-    tcase_add_checked_fixture(tc, setup, teardown);
-
-    tcase_add_test(tc, test_sss_config_set_debug_level_exist);
-    tcase_add_test(tc, test_sss_config_set_debug_level_notexist);
-    tcase_add_test(tc, test_sss_config_service_enabled);
-    tcase_add_test(tc, test_sss_config_service_disabled);
-    tcase_add_test(tc, test_sss_config_service_disabled_empty);
-    tcase_add_test(tc, test_sss_config_service_disabled_missing);
-    tcase_add_test(tc, test_sss_config_service_enable);
-    tcase_add_test(tc, test_sss_config_service_enable_empty);
-    tcase_add_test(tc, test_sss_config_service_enable_missing);
-    tcase_add_test(tc, test_sss_config_service_disable);
-    tcase_add_test(tc, test_sss_config_service_disable_one);
-    tcase_add_test(tc, test_sss_config_service_disable_empty);
-    tcase_add_test(tc, test_sss_config_service_disable_missing);
-    tcase_add_test(tc, test_sss_config_domain_enabled);
-    tcase_add_test(tc, test_sss_config_domain_disabled);
-    tcase_add_test(tc, test_sss_config_domain_disabled_empty);
-    tcase_add_test(tc, test_sss_config_domain_disabled_missing);
-    tcase_add_test(tc, test_sss_config_domain_enable);
-    tcase_add_test(tc, test_sss_config_domain_enable_empty);
-    tcase_add_test(tc, test_sss_config_domain_enable_missing);
-    tcase_add_test(tc, test_sss_config_domain_disable);
-    tcase_add_test(tc, test_sss_config_domain_disable_two);
-    tcase_add_test(tc, test_sss_config_domain_disable_empty);
-    tcase_add_test(tc, test_sss_config_domain_disable_missing);
-
-
-
-    tcase_set_timeout(tc, 60);
-
-    suite_add_tcase(s, tc);
-
-    return s;
-}
-
-int main(int argc, const char *argv[])
-{
-    int number_failed;
-
-    tests_set_cwd();
-
-    Suite *s = sss_config_suite();
-    SRunner *sr = srunner_create(s);
-
-    srunner_run_all(sr, CK_NORMAL);
-    number_failed = srunner_ntests_failed(sr);
-    srunner_free(sr);
-
-    if (number_failed == 0) {
-        return EXIT_SUCCESS;
-    }
-
-    return EXIT_FAILURE;
-}
diff --git a/src/util/sss_config.c b/src/util/sss_config.c
deleted file mode 100644
index 8f7080a..0000000
--- a/src/util/sss_config.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
-    Authors:
-        Pavel Březina <pbrez...@redhat.com>
-
-    Copyright (C) 2014 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/>.
-*/
-
-#include <augeas.h>
-#include <talloc.h>
-#include <string.h>
-#include "util/sss_config.h"
-
-#define PATH_SECTION "/files/%s/target[. = \"%s\"]"
-#define PATH_OPTION PATH_SECTION "/%s"
-
-#define build_section_path(mem_ctx, config_ctx, section) \
-    talloc_asprintf(mem_ctx, PATH_SECTION, config_ctx->file, section)
-
-#define build_option_path(mem_ctx, config_ctx, section, option) \
-    talloc_asprintf(mem_ctx, PATH_OPTION, config_ctx->file, section, option)
-
-struct sss_config_ctx
-{
-    augeas *auges_ctx;
-    const char *file;
-};
-
-static errno_t
-sss_config_set_option(struct sss_config_ctx *ctx,
-                      const char *section,
-                      const char *option,
-                      const char *value)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char *target_path = NULL;
-    char *option_path = NULL;
-    errno_t ret;
-    int aug_ret;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    target_path = build_section_path(tmp_ctx, ctx, section);
-    if (target_path == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    option_path = build_option_path(tmp_ctx, ctx, section, option);
-    if (option_path == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    /* Set configuration option:
-     *
-     * # make sure the section exists
-     * set /files/$file/target[. = "$section"] $section
-     *
-     * # set value
-     * set /files/$file/target[. = "$section"]/$option $value
-     */
-
-    aug_ret = aug_set(ctx->auges_ctx, target_path, section);
-    if (aug_ret != 0) {
-        ret = EIO;
-        goto done;
-    }
-
-    aug_ret = aug_set(ctx->auges_ctx, option_path, value);
-    if (aug_ret != 0) {
-        ret = EIO;
-        goto done;
-    }
-
-    ret = EOK;
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static errno_t
-sss_config_rm_option(struct sss_config_ctx *ctx,
-                      const char *section,
-                      const char *option)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char *option_path = NULL;
-    errno_t ret;
-    int aug_ret;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    option_path = build_option_path(tmp_ctx, ctx, section, option);
-    if (option_path == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    /* Remove configuration option:
-     *
-     * rm /files/$file/target[. = "$section"]/$option
-     */
-
-    aug_ret = aug_rm(ctx->auges_ctx, option_path);
-    if (aug_ret != 1) {
-        ret = EIO;
-        goto done;
-    }
-
-    ret = EOK;
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static errno_t
-sss_config_set_list(struct sss_config_ctx *ctx,
-                    const char *section,
-                    const char *option,
-                    char **list)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char *value = NULL;
-    errno_t ret;
-    int i;
-
-    if (list == NULL) {
-        return EINVAL;
-    }
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    if (list[0] == NULL) {
-        ret = sss_config_rm_option(ctx, section, option);
-        goto done;
-    }
-
-    value = talloc_strdup(tmp_ctx, list[0]);
-    if (value == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    for (i = 1; list[i] != NULL; i++) {
-        value = talloc_asprintf_append(value, ", %s", list[i]);
-        if (value == NULL) {
-            ret = ENOMEM;
-            goto done;
-        }
-    }
-
-    ret = sss_config_set_option(ctx, section, option, value);
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static errno_t
-sss_config_get_list(TALLOC_CTX *mem_ctx,
-                    struct sss_config_ctx *ctx,
-                    const char *section,
-                    const char *option,
-                    char ***_list)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char *option_path = NULL;
-    const char *value = NULL;
-    char **list = NULL;
-    errno_t ret;
-    int aug_ret;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    option_path = build_option_path(tmp_ctx, ctx, section, option);
-    if (option_path == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    aug_ret = aug_get(ctx->auges_ctx, option_path, &value);
-    if (aug_ret == 0 || (aug_ret == 1 && (value == NULL || *value == '\0'))) {
-        /* option is not present, return empty list */
-        list = talloc_zero_array(tmp_ctx, char*, 1);
-        if (list == NULL) {
-            ret = ENOMEM;
-            goto done;
-        }
-
-        ret = EOK;
-        goto done;
-    } else if (aug_ret != 1) {
-        /* error: more than one value found */
-        ret = EINVAL;
-        goto done;
-    }
-
-    ret = split_on_separator(tmp_ctx, value, ',', true, true, &list, NULL);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    *_list = talloc_steal(mem_ctx, list);
-    ret = EOK;
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static errno_t
-sss_config_is_in_list(struct sss_config_ctx *ctx,
-                      const char *section,
-                      const char *option,
-                      const char *value,
-                      bool *_result)
-{
-    char **list = NULL;
-    errno_t ret;
-
-    ret = sss_config_get_list(ctx, ctx, section, option, &list);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    *_result = string_in_list(value, list, true);
-
-done:
-    talloc_free(list);
-    return ret;
-}
-
-static errno_t
-sss_config_add_to_list(struct sss_config_ctx *ctx,
-                       const char *section,
-                       const char *option,
-                       const char *value)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char **list = NULL;
-    errno_t ret;
-    bool result = false;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    ret = sss_config_get_list(tmp_ctx, ctx, section, option, &list);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    result = string_in_list(value, list, true);
-    if (result == true) {
-        ret = EOK;
-        goto done;
-    }
-
-    ret = add_string_to_list(tmp_ctx, value, &list);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    ret = sss_config_set_list(ctx, section, option, list);
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static errno_t
-sss_config_del_from_list(struct sss_config_ctx *ctx,
-                         const char *section,
-                         const char *option,
-                         const char *value)
-{
-    TALLOC_CTX *tmp_ctx = NULL;
-    char **list = NULL;
-    errno_t ret;
-    bool found;
-    int i;
-
-    tmp_ctx = talloc_new(NULL);
-    if (tmp_ctx == NULL) {
-        return ENOMEM;
-    }
-
-    ret = sss_config_get_list(tmp_ctx, ctx, section, option, &list);
-    if (ret != EOK) {
-        goto done;
-    }
-
-    if (list == NULL) {
-        goto done;
-    }
-
-    found = false;
-    for (i = 0; list[i] != NULL; i++) {
-        if (strcmp(list[i], value) == 0) {
-            found = true;
-        }
-
-        if (found) {
-            list[i] = list[i + 1];
-        }
-    }
-
-    ret = sss_config_set_list(ctx, section, option, list);
-
-done:
-    talloc_free(tmp_ctx);
-    return ret;
-}
-
-static int sss_config_ctx_destructor(struct sss_config_ctx *ctx)
-{
-    if (ctx->auges_ctx != NULL) {
-        aug_close(ctx->auges_ctx);
-        ctx->auges_ctx = NULL;
-    }
-
-    return 0;
-}
-
-struct sss_config_ctx *
-sss_config_open(TALLOC_CTX *mem_ctx,
-                const char *root,
-                const char *file)
-{
-    struct sss_config_ctx *ctx = NULL;
-    errno_t ret;
-    int aug_ret;
-
-    ctx = talloc_zero(mem_ctx, struct sss_config_ctx);
-    if (ctx == NULL) {
-        return NULL;
-    }
-
-    talloc_set_destructor(ctx, sss_config_ctx_destructor);
-
-    ctx->auges_ctx = aug_init(root, NULL, AUG_NO_LOAD | AUG_NO_MODL_AUTOLOAD
-                              | AUG_SAVE_BACKUP);
-    if (ctx->auges_ctx == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    ctx->file = talloc_strdup(ctx, file);
-    if (ctx->file == NULL) {
-        ret = ENOMEM;
-        goto done;
-    }
-
-    /* Load configuration file
-     *
-     * set /augeas/load/sssd/lens sssd.lns
-     * set /augeas/load/sssd/incl $file
-     * load
-     */
-
-    aug_ret = aug_set(ctx->auges_ctx, "/augeas/load/sssd/lens", "sssd.lns");
-    if (aug_ret != 0) {
-        ret = EIO;
-        goto done;
-    }
-
-    aug_ret = aug_set(ctx->auges_ctx, "/augeas/load/sssd/incl", ctx->file);
-    if (aug_ret != 0) {
-        ret = EIO;
-        goto done;
-    }
-
-    aug_ret = aug_load(ctx->auges_ctx);
-    if (aug_ret != 0) {
-        ret = EIO;
-        goto done;
-    }
-
-    ret = EOK;
-
-done:
-    if (ret != EOK) {
-        talloc_free(ctx);
-    }
-
-    return ctx;
-}
-
-errno_t
-sss_config_save(struct sss_config_ctx *ctx)
-{
-    int aug_ret;
-
-    aug_ret = aug_save(ctx->auges_ctx);
-    if (aug_ret != 0) {
-        return EIO;
-    }
-
-    return EOK;
-}
-
-void
-sss_config_close(struct sss_config_ctx **_ctx)
-{
-    if (_ctx == NULL || *_ctx == NULL) {
-        return;
-    }
-
-    talloc_free(*_ctx);
-    *_ctx = NULL;
-}
-
-errno_t
-sss_config_set_debug_level(struct sss_config_ctx *ctx,
-                           const char *section,
-                           uint32_t level)
-{
-    char *level_str = NULL;
-    errno_t ret;
-
-    level_str = talloc_asprintf(ctx, "%#.4x", level);
-    if (level_str == NULL) {
-        return ENOMEM;
-    }
-
-    ret = sss_config_set_option(ctx, section, CONFDB_SERVICE_DEBUG_LEVEL,
-                                level_str);
-
-    talloc_free(level_str);
-    return ret;
-}
-
-errno_t
-sss_config_service_is_enabled(struct sss_config_ctx *ctx,
-                              const char *service,
-                              bool *_result)
-{
-    return sss_config_is_in_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_SERVICES,
-                                 service, _result);
-}
-
-errno_t
-sss_config_service_enable(struct sss_config_ctx *ctx,
-                          const char *service)
-{
-    return sss_config_add_to_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_SERVICES,
-                                  service);
-}
-
-errno_t
-sss_config_service_disable(struct sss_config_ctx *ctx,
-                           const char *service)
-{
-    return sss_config_del_from_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_SERVICES,
-                                    service);
-}
-
-errno_t
-sss_config_domain_is_enabled(struct sss_config_ctx *ctx,
-                             const char *domain,
-                             bool *_result)
-{
-    return sss_config_is_in_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_DOMAINS,
-                                 domain, _result);
-}
-
-errno_t
-sss_config_domain_enable(struct sss_config_ctx *ctx,
-                         const char *domain)
-{
-    return sss_config_add_to_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_DOMAINS,
-                                  domain);
-}
-
-errno_t
-sss_config_domain_disable(struct sss_config_ctx *ctx,
-                          const char *domain)
-{
-    return sss_config_del_from_list(ctx, "sssd", CONFDB_MONITOR_ACTIVE_DOMAINS,
-                                    domain);
-}
diff --git a/src/util/sss_config.h b/src/util/sss_config.h
deleted file mode 100644
index b59f5fc..0000000
--- a/src/util/sss_config.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-    Authors:
-        Pavel Březina <pbrez...@redhat.com>
-
-    Copyright (C) 2014 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_CONFIG_H_
-#define SSS_CONFIG_H_
-
-#include <talloc.h>
-#include "util/util.h"
-
-struct sss_config_ctx;
-
-struct sss_config_ctx *
-sss_config_open(TALLOC_CTX *mem_ctx,
-                const char *root,
-                const char *file);
-
-errno_t
-sss_config_save(struct sss_config_ctx *ctx);
-
-void
-sss_config_close(struct sss_config_ctx **_ctx);
-
-errno_t
-sss_config_set_debug_level(struct sss_config_ctx *ctx,
-                           const char *section,
-                           uint32_t level);
-
-errno_t
-sss_config_service_is_enabled(struct sss_config_ctx *ctx,
-                              const char *service,
-                              bool *_result);
-
-errno_t
-sss_config_service_enable(struct sss_config_ctx *ctx,
-                          const char *service);
-
-errno_t
-sss_config_service_disable(struct sss_config_ctx *ctx,
-                           const char *service);
-
-errno_t
-sss_config_domain_is_enabled(struct sss_config_ctx *ctx,
-                             const char *domain,
-                             bool *_result);
-
-errno_t
-sss_config_domain_enable(struct sss_config_ctx *ctx,
-                         const char *domain);
-
-errno_t
-sss_config_domain_disable(struct sss_config_ctx *ctx,
-                          const char *domain);
-
-#endif /* SSS_CONFIG_H_ */
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org

Reply via email to