From cb270fff7b71991fcf7f3931f20fc676815daef1 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 30 Apr 2016 10:13:52 +0200 Subject: [PATCH] Re-enabled libzakconfi. --- .gitignore | 1 + src/aute_smbldap.c | 36 +++++++++++++++++--------------- tests/Makefile.am | 7 ++++++- tests/test_confi.c | 48 +++++++++++++++++++++++++++++++++++++++++++ tests/test_confi.conf | 9 ++++++++ 5 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 tests/test_confi.c create mode 100644 tests/test_confi.conf diff --git a/.gitignore b/.gitignore index 0907eed..fb3a8ff 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ missing config.h stamp-h1 tests/test +tests/test_confi tests/test_get_password *.tar.gz *.exe diff --git a/src/aute_smbldap.c b/src/aute_smbldap.c index c052c65..64dbff3 100644 --- a/src/aute_smbldap.c +++ b/src/aute_smbldap.c @@ -114,17 +114,17 @@ DllMain (HINSTANCE hinstDLL, #endif -#ifdef HAVE_LIBCONFI +#ifdef HAVE_LIBZAKCONFI static gboolean -get_connection_parameters_from_confi (Confi *confi, gchar **user_field) +get_connection_parameters_from_confi (ZakConfi *confi, gchar **user_field) { gboolean ret = TRUE; - host = confi_path_get_value (confi, "aute/aute-smbldap/ldap/host"); - base_dn = confi_path_get_value (confi, "aute/aute-smbldap/ldap/base_dn"); - users_ou = confi_path_get_value (confi, "aute/aute-smbldap/ldap/users_ou"); - groups_ou = confi_path_get_value (confi, "aute/aute-smbldap/ldap/groups_ou"); - *user_field = confi_path_get_value (confi, "aute/aute-smbldap/ldap/user_field"); + host = zak_confi_path_get_value (confi, "libzakauthe/libzakauthesmbldap/ldap/host"); + base_dn = zak_confi_path_get_value (confi, "libzakauthe/libzakauthesmbldap/ldap/base_dn"); + users_ou = zak_confi_path_get_value (confi, "libzakauthe/libzakauthesmbldap/ldap/users_ou"); + groups_ou = zak_confi_path_get_value (confi, "libzakauthe/libzakauthesmbldap/ldap/groups_ou"); + *user_field = zak_confi_path_get_value (confi, "libzakauthe/libzakauthesmbldap/ldap/user_field"); if (host == NULL || strcmp (g_strstrip (host), "") == 0 @@ -323,18 +323,20 @@ static gchar groups_ou = NULL; user_field = NULL; -#ifdef HAVE_LIBCONFI - /* the first and only parameters must be a Confi object */ - /* leggo i parametri di connessione dalla configurazione */ - if (IS_CONFI (parameters->data)) +#ifdef HAVE_LIBZAKCONFI + /* the first and only parameters must be a ZakConfi object */ + if (g_strcmp0 ((gchar *)parameters->data, "{libzakconfi}") == 0) { - if (!get_connection_parameters_from_confi (CONFI (parameters->data), &user_field)) + if (ZAK_IS_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1))) { - host = NULL; - base_dn = NULL; - users_ou = NULL; - groups_ou = NULL; - user_field = NULL; + if (!get_connection_parameters_from_confi (ZAK_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1)), &user_field)) + { + host = NULL; + base_dn = NULL; + users_ou = NULL; + groups_ou = NULL; + user_field = NULL; + } } } #endif diff --git a/tests/Makefile.am b/tests/Makefile.am index c942d71..02e5ab2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,12 +1,17 @@ AM_CPPFLAGS = $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) \ $(LIBZAKAUTHESMBLDAP_CFLAGS) \ + $(LIBZAKCONFI_CFLAGS) \ -I../src LIBS = $(GTK_LIBS) \ - $(LIBZAKAUTHESMBLDAP_LIBS) + $(LIBZAKAUTHESMBLDAP_LIBS) \ + $(LIBZAKCONFI_LIBS) LDADD = ../src/libzakauthesmbldap.la noinst_PROGRAMS = test \ + test_confi \ test_get_password + +EXTRA_DIST = test_confi.conf diff --git a/tests/test_confi.c b/tests/test_confi.c new file mode 100644 index 0000000..a90a356 --- /dev/null +++ b/tests/test_confi.c @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2016 Andrea Zagli + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include + +#include + +#include + +int +main (int argc, char **argv) +{ + ZakAuthe *aute; + ZakConfi *confi; + GSList *params; + + gtk_init (&argc, &argv); + + aute = zak_authe_new (); + + params = NULL; + + confi = zak_confi_new (argv[1]); + + params = g_slist_append (params, "{libzakconfi}"); + params = g_slist_append (params, confi); + + zak_authe_set_config (aute, params); + + g_message ("User %s\n", zak_authe_authe (aute)); + + return 0; +} diff --git a/tests/test_confi.conf b/tests/test_confi.conf new file mode 100644 index 0000000..8054de1 --- /dev/null +++ b/tests/test_confi.conf @@ -0,0 +1,9 @@ +[libzakauthe] +plugin=/usr/local/lib/libzakauthe/plugins/libzakauthesmbldap.so + +[libzakauthe/libzakauthesmbldap/ldap] +host=ldap://ldap.comune.scandicci.fi.it/ +base_dn=dc=comune,dc=scandicci,dc=fi,dc=it +users_ou=ou=Users +groups_ou=ou=Groups +user_field=uid -- 2.49.0