config: clean up configuration management
authorJussi Laako <jussi.laako@linux.intel.com>
Fri, 23 Aug 2013 13:58:02 +0000 (16:58 +0300)
committerJussi Laako <jussi.laako@linux.intel.com>
Fri, 23 Aug 2013 14:37:08 +0000 (17:37 +0300)
23 files changed:
configure.ac
docs/building.xml
docs/gsignond-docs.sgml
gsignond.conf.in
include/gsignond/gsignond-config-db.h [deleted file]
include/gsignond/gsignond-config-general.h
include/gsignond/gsignond-config.h
src/common/Makefile.am
src/common/db/gsignond-secret-storage.c
src/common/gsignond-config.c
src/common/gsignond-plugin-loader.c
src/common/gsignond-storage-manager.c
src/daemon/Makefile.am
src/daemon/db/gsignond-db-metadata-database.c
src/daemon/gsignond-daemon.c
src/daemon/plugins/Makefile.am
src/daemon/plugins/gsignond-plugin-proxy-factory.c
src/daemon/plugins/gsignond-plugin-remote.c
src/extensions/tizen/tizen-storage-manager.c
test/daemon/daemon-test.c
test/daemon/daemontest.conf [new file with mode: 0644]
test/plugins/pluginproxytest.c
test/plugins/pluginremotetest.c

index 7a19ea3..48e0113 100644 (file)
@@ -104,12 +104,28 @@ AC_ARG_ENABLE(keychain,
                          system context "sysctx"],
               [enable_keychain=$enableval])
 if test "x$enable_keychain" != "x" ; then
-    AC_DEFINE_UNQUOTED(KEYCHAIN_SYSCTX, ["$enable_keychain"], [Keychain system context])
-    AC_SUBST(KEYCHAIN_SYSCTX, ["#KeychainSystemContext = $enable_keychain"])
+    AC_DEFINE_UNQUOTED(KEYCHAIN_SYSCTX,
+                      ["$enable_keychain"],
+                      [Keychain system context])
+    AC_SUBST(KEYCHAIN_SYSCTX,
+            ["#KeychainSystemContext = $enable_keychain"])
 else
-    AC_SUBST(KEYCHAIN_SYSCTX, ["#KeychainSystemContext = \"\""])
+    AC_SUBST(KEYCHAIN_SYSCTX,
+            ["#KeychainSystemContext = \"\""])
 fi
 
+AC_ARG_ENABLE(storagedir,
+             [  --enable-storagedir=path
+                         enable storage at location "path"
+                         instead of default "/var/db"],
+              [enable_storagedir=$enableval],
+             [enable_storagedir="/var/db"])
+AC_DEFINE_UNQUOTED(BASE_STORAGE_DIR,
+                  ["$enable_storagedir"],
+                  [Base path for user specific storage directories])
+AC_SUBST(BASE_STORAGE_DIR,
+        ["#StoragePath = $enable_storagedir"])
+
 AC_ARG_ENABLE(debug,
              [  --enable-debug          enable debug features],
              [enable_debug=yes], [enable_debug=no])
index 77ec355..c0854c3 100644 (file)
             through config.h.
         </para>
     </formalpara>
+    
+    <formalpara>
+        <title><systemitem>--enable-storagedir=path</systemitem></title>
+        
+        <para>
+            Sets the base path for user specific storage directories where
+            database files will be located.
+            Default location is <filename>/var/db</filename>
+        </para>
+    </formalpara>
 
   </refsect1>
   <refsect1 id="building-packages">
index abd68c2..a5e9cf9 100644 (file)
@@ -24,7 +24,6 @@
     <title>GSignond configuration</title>
     <xi:include href="xml/gsignond-config.xml"/>
     <xi:include href="xml/gsignond-config-general.xml"/>
-    <xi:include href="xml/gsignond-config-db.xml"/>
     <xi:include href="xml/gsignond-config-dbus.xml"/>
   </chapter>
 
index 090ef74..608f239 100644 (file)
@@ -7,23 +7,13 @@
 #
 [General]
 
-# Directory for binary executables.
-#BinDir =
-#
 # Define extension / platform adaptation module to use.
 # 'default' is a dummy one with no encrypted storage, but with basic Unix
 # discretionary access control.
 #Extension = default
 #
-# Extension directory where extension modules are located.
-#ExtensionsDir =
-#
 # Base path where user specific database directories will be located.
-# Default: /var/db
-#StoragePath =
-#
-# Location for authentication plugins.
-#PluginDir =
+@BASE_STORAGE_DIR@
 #
 # Timeout for unloading cached plugin instances.
 #PluginTimeout = 0
 @KEYCHAIN_SYSCTX@
 
 #
-# Database related settings.
-#
-[Storage]
-
-# File name for the metadata database. (excluding path)
-#MetadataDBFilename = metadata.db
-#
-# File name for the credential database. (excluding path)
-#SecretDBFilename = secret.db
-
-#
 # D-Bus related settings.
 #
 [ObjectTimeouts]
diff --git a/include/gsignond/gsignond-config-db.h b/include/gsignond/gsignond-config-db.h
deleted file mode 100644 (file)
index 555a711..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* vi: set et sw=4 ts=4 cino=t0,(0: */
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of gsignond
- *
- * Copyright (C) 2012 Intel Corporation.
- *
- * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#ifndef __GSIGNOND_CONFIG_DB_H_
-#define __GSIGNOND_CONFIG_DB_H_
-
-/**
- * SECTION:gsignond-config-db
- * @title: Database configuration
- * @short_description: gSSO database configuration keys
- * @include: gsignond/gsignond-config.h
- *
- * Database configuration keys are defined below. See #GSignondConfig for how to use them.
- */
-
-/**
- * GSIGNOND_CONFIG_DB_SSO:
- * 
- * A prefix for database keys. Should be used only when defining new keys.
- */
-#define GSIGNOND_CONFIG_DB_SSO                  "Storage"
-/**
- * GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME:
- * 
- * The filename of the credentials database.
- * 
- * Default value: "secret.db".
- */
-#define GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME   GSIGNOND_CONFIG_DB_SSO \
-                                                "/SecretDBFilename"
-/**
- * GSIGNOND_CONFIG_DB_METADATA_DB_FILENAME:
- * 
- * The filename of the metadata database.
- * 
- * Default value: "metadata.db".
- */
-#define GSIGNOND_CONFIG_DB_METADATA_DB_FILENAME GSIGNOND_CONFIG_DB_SSO \
-                                                "/MetadataDBFilename"
-
-#endif /* __GSIGNOND_DB_CONFIG_H_ */
index 3b27468..65e1650 100644 (file)
@@ -41,6 +41,7 @@
  * A prefix for general keys. Should be used only when defining new keys.
  */
 #define GSIGNOND_CONFIG_GENERAL                 "General"
+
 /**
  * GSIGNOND_CONFIG_GENERAL_STORAGE_PATH:
  * 
 #define GSIGNOND_CONFIG_GENERAL_STORAGE_PATH    GSIGNOND_CONFIG_GENERAL \
                                                 "/StoragePath"
 /**
- * GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR:
- * 
- * The path where gSSO is looking for available extension modules.
- * 
- * Default value: $(pkglibdir)/extensions, can be overriden in debug 
- * builds by setting SSO_EXTENSIONS_DIR environment variable.
- */
-#define GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR  GSIGNOND_CONFIG_GENERAL \
-                                                "/ExtensionsDir"
-/**
- * GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR:
- * 
- * The path where gSSO is looking for available plugins.
- * 
- * Default value: $(pkglibdir)/plugins, can be overriden in debug 
- * builds by setting SSO_PLUGINS_DIR environment variable.
- */
-#define GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR     GSIGNOND_CONFIG_GENERAL \
-                                                "/PluginsDir"
-/**
- * GSIGNOND_CONFIG_GENERAL_BIN_DIR:
- * 
- * The path where gSSO is looking for the gsignond-plugind binary when it needs
- * to start a plugin process. Can be used for finding other supplementary binaries in 
- * the future.
- * 
- * Default value: $(bindir), can be overriden in debug 
- * builds by setting SSO_BIN_DIR environment variable.
- */
-#define GSIGNOND_CONFIG_GENERAL_BIN_DIR         GSIGNOND_CONFIG_GENERAL \
-                                                "/BinDir"
-/**
  * GSIGNOND_CONFIG_GENERAL_EXTENSION:
  * 
  * The name of the gSSO extension to use. If not specified, the default 
@@ -99,6 +68,9 @@
  * 
  * Path provided by #GSignondStorageManager for storing user-specific
  * information, including secret and metadata databases.
+ *
+ * This is run-time value and any value read from configuration file
+ * is overwritten.
  * 
  * Value provided by the default implementation: 
  * #GSIGNOND_CONFIG_GENERAL_STORAGE_PATH + "/gsignond." + g_get_user_name().
index edcdaa4..6fc97cc 100644 (file)
@@ -30,7 +30,6 @@
 #include <glib-object.h>
 
 #include "gsignond-config-general.h"
-#include "gsignond-config-db.h"
 #include "gsignond-config-dbus.h"
 
 G_BEGIN_DECLS
index b89d47e..c419db8 100644 (file)
@@ -33,7 +33,6 @@ libgsignond_common_la_CPPFLAGS = \
     -I. \
     $(GSIGNOND_CFLAGS) \
     -DGSIGNOND_PLUGINS_DIR='"$(pluginsdir)"' \
-    -DGSIGNOND_EXTENSIONS_DIR='"$(extensionsdir)"' \
     -DGSIGNOND_BIN_DIR='"$(bindir)"' \
     -DGSIGNOND_SYSCONF_DIR='"$(sysconfdir)"' \
     $(NULL)
index 97e021d..42a8f57 100644 (file)
@@ -29,6 +29,8 @@
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-secret-storage.h"
 
+#define GSIGNOND_SECRET_DB_FILENAME     "secret.db"
+
 /**
  * SECTION:gsignond-secret-storage
  * @short_description: provides access to the database that stores user credentials and identity/method cache
@@ -129,7 +131,6 @@ static gboolean
 _open_db (GSignondSecretStorage *self)
 {
     const gchar *dir = NULL;
-    const gchar *filename = NULL;
     gchar *db_filename = NULL;
     gboolean ret = FALSE;
 
@@ -142,13 +143,7 @@ _open_db (GSignondSecretStorage *self)
         ERR ("No directory specified in config object for secret db...");
         return FALSE;
     }
-    filename = gsignond_config_get_string (self->config,
-            GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME);
-    if (!filename) {
-        ERR ("Database filename not specified");
-        return FALSE;
-    }
-    db_filename = g_build_filename (dir, filename, NULL);
+    db_filename = g_build_filename (dir, GSIGNOND_SECRET_DB_FILENAME, NULL);
     if (!db_filename) {
         ERR ("Invalid db filename...");
         return FALSE;
@@ -376,7 +371,7 @@ gsignond_secret_storage_init (GSignondSecretStorage *self)
  *
  * Opens (and initializes) the database. The implementation should take
  * care of creating the DB, if it doesn't exist, and it should use
- * #GSIGNOND_CONFIG_GENERAL_SECURE_DIR and #GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME
+ * #GSIGNOND_CONFIG_GENERAL_SECURE_DIR
  * to determine database location in the filesystem.
  * 
  * The default implementation is using SQLite for the storage.
index 855777d..1a80063 100644 (file)
@@ -32,7 +32,6 @@
 
 #include "gsignond/gsignond-config.h"
 #include "gsignond/gsignond-config-general.h"
-#include "gsignond/gsignond-config-db.h"
 #include "gsignond/gsignond-config-dbus.h"
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-dictionary.h"
@@ -85,9 +84,6 @@
  */
 
 
-#define GSIGNOND_DB_METADATA_DEFAULT_DB_FILENAME "metadata.db"
-#define GSIGNOND_DB_SECRET_DEFAULT_DB_FILENAME "secret.db"
-
 struct _GSignondConfigPrivate
 {
     gchar *config_file_path;
@@ -98,19 +94,6 @@ struct _GSignondConfigPrivate
 
 G_DEFINE_TYPE (GSignondConfig, gsignond_config, G_TYPE_OBJECT);
 
-
-static void
-_set_storage_path (GSignondConfig *self, const gchar *value)
-{
-    gchar *storage_path = g_build_filename (value,
-                                            "gsignond.general",
-                                            NULL);
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_GENERAL_STORAGE_PATH,
-                                storage_path);
-    g_free (storage_path);
-}
-
 static gboolean
 _load_config (GSignondConfig *self)
 {
@@ -204,12 +187,6 @@ _load_config (GSignondConfig *self)
 
             INFO ("found config : '%s/%s' - '%s'", groups[i], keys[j], value);
 
-            /* construct a full storage path for wipe safety */
-            if (g_strcmp0 (key, GSIGNOND_CONFIG_GENERAL_STORAGE_PATH) == 0)
-                _set_storage_path (self, value);
-            else
-                gsignond_config_set_string (self, key, value);
-
             g_free (key);
             g_free (value);
         }
@@ -224,67 +201,6 @@ _load_config (GSignondConfig *self)
     return TRUE;
 }
 
-#ifdef ENABLE_DEBUG
-static void
-_load_environment (GSignondConfig *self)
-{
-    const gchar *e_val = 0;
-    guint timeout = 0;
-    
-    e_val = g_getenv ("SSO_DAEMON_TIMEOUT");
-    if (e_val && (timeout = atoi(e_val)))
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_DBUS_DAEMON_TIMEOUT,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_IDENTITY_TIMEOUT");
-    if (e_val && (timeout = atoi(e_val)))
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_DBUS_IDENTITY_TIMEOUT,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_AUTH_SESSION_TIMEOUT");
-    if (e_val && (timeout = atoi(e_val)))
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_DBUS_AUTH_SESSION_TIMEOUT,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_PLUGIN_TIMEOUT");
-    if (e_val && (timeout = atoi(e_val)))
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_PLUGIN_TIMEOUT,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_PLUGINS_DIR");
-    if (e_val) 
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_EXTENSIONS_DIR");
-    if (e_val) 
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_BIN_DIR");
-    if (e_val)
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_GENERAL_BIN_DIR,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_EXTENSION");
-    if (e_val)
-        gsignond_config_set_string (self,
-                                    GSIGNOND_CONFIG_GENERAL_EXTENSION,
-                                    e_val);
-
-    e_val = g_getenv ("SSO_STORAGE_PATH");
-    if (e_val)
-        _set_storage_path (self, e_val);
-}
-#endif  /* ENABLE_DEBUG */
-
 /**
  * gsignond_config_get_integer:
  * @self: an instance of #GSignondConfig
@@ -408,32 +324,8 @@ gsignond_config_init (GSignondConfig *self)
     self->priv->config_file_path = NULL;
     self->priv->config_table = gsignond_dictionary_new();
     
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR,
-                                (GSIGNOND_PLUGINS_DIR));
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR,
-                                (GSIGNOND_EXTENSIONS_DIR));
-    gsignond_config_set_string (self,
-                             (GSIGNOND_CONFIG_GENERAL_BIN_DIR),
-                             (GSIGNOND_BIN_DIR));
-
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_GENERAL_STORAGE_PATH,
-                                "/var/db");
-
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_DB_SECRET_DB_FILENAME,
-                                GSIGNOND_DB_SECRET_DEFAULT_DB_FILENAME);
-    gsignond_config_set_string (self,
-                                GSIGNOND_CONFIG_DB_METADATA_DB_FILENAME,
-                                GSIGNOND_DB_METADATA_DEFAULT_DB_FILENAME);
-
     if (!_load_config (self))
         WARN ("load configuration failed, using default settings");
-#   ifdef ENABLE_DEBUG
-    _load_environment (self);
-#   endif
 }
 
 static void
index 99dd5bd..e55bb76 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <gmodule.h>
 
+#include "config.h"
+
 #include "gsignond/gsignond-log.h"
 #include "gsignond-plugin-loader.h"
 
@@ -34,11 +36,18 @@ gsignond_load_plugin(
         GSignondConfig* config,
         gchar* plugin_type)
 {
-    gchar* plugin_filename = g_module_build_path (
-            gsignond_config_get_string (config,
-                    GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type);
-    GSignondPlugin *plugin = gsignond_load_plugin_with_filename (plugin_type,
-            plugin_filename);
+    const gchar *plugin_path = GSIGNOND_PLUGINS_DIR;
+    gchar *plugin_filename;
+    GSignondPlugin *plugin;
+
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv("SSO_PLUGINS_DIR");
+    if (env_val)
+        plugin_path = env_val;
+#   endif
+    plugin_filename = g_module_build_path (plugin_path, plugin_type);
+    plugin = gsignond_load_plugin_with_filename (plugin_type,
+                                                 plugin_filename);
     g_free(plugin_filename);
     return plugin;
 }
index 7df6c27..e565a15 100644 (file)
@@ -28,6 +28,8 @@
 
 #include <glib/gstdio.h>
 
+#include "config.h"
+
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-storage-manager.h"
 #include "gsignond/gsignond-utils.h"
@@ -81,14 +83,14 @@ _set_config (GSignondStorageManager *self, GSignondConfig *config)
     const gchar *storage_path = gsignond_config_get_string (
                                        self->config,
                                        GSIGNOND_CONFIG_GENERAL_STORAGE_PATH);
-    if (storage_path)
-        self->location = g_build_filename (storage_path,
-                                           user_dir,
-                                           NULL);
-    else
-        self->location = g_build_filename ("/var/db",
-                                           user_dir,
-                                           NULL);
+    if (!storage_path)
+        storage_path = BASE_STORAGE_DIR;
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv("SSO_STORAGE_PATH");
+    if (env_val)
+        storage_path = env_val;
+#   endif
+    self->location = g_build_filename (storage_path, user_dir, NULL);
     g_free (user_dir);
     DBG ("secure dir %s", self->location);
 }
index 2feb112..e4b94a1 100644 (file)
@@ -25,7 +25,6 @@ gsignond_includedir = $(includedir)/gsignond
 gsignond_pubhdr = ../../include/gsignond
 gsignond_include_HEADERS = \
        $(gsignond_pubhdr)/gsignond-access-control-manager.h \
-       $(gsignond_pubhdr)/gsignond-config-db.h \
        $(gsignond_pubhdr)/gsignond-config-dbus.h \
        $(gsignond_pubhdr)/gsignond-config-general.h \
        $(gsignond_pubhdr)/gsignond-config.h \
@@ -64,6 +63,7 @@ gsignond_CFLAGS = \
     -I$(top_builddir) \
     -I$(top_srcdir)/include/ \
     -I$(top_srcdir)/src/ \
+    -DGSIGNOND_EXTENSIONS_DIR='"$(extensionsdir)"' \
     $(GSIGNOND_CFLAGS) \
     $(NULL)
 
index 8b76b3a..29da387 100644 (file)
@@ -33,6 +33,8 @@
 #include "common/db/gsignond-db-error.h"
 #include "gsignond-db-metadata-database.h"
 
+#define GSIGNOND_METADATA_DB_FILENAME   "metadata.db"
+
 #define RETURN_IF_NOT_OPEN(obj, retval) \
     if (gsignond_db_sql_database_is_open (obj) == FALSE) { \
         GError* last_error = gsignond_db_create_error( \
@@ -904,18 +906,14 @@ _gsignond_db_metadata_database_clear (
 gboolean
 gsignond_db_metadata_database_open (GSignondDbMetadataDatabase *self)
 {
-    const gchar *filename = NULL;
-
     g_return_val_if_fail (GSIGNOND_DB_IS_METADATA_DATABASE (self), FALSE);
 
     if (gsignond_db_sql_database_is_open (GSIGNOND_DB_SQL_DATABASE (self)))
         return TRUE;
 
-    filename = gsignond_config_get_string (self->config,
-            GSIGNOND_CONFIG_DB_METADATA_DB_FILENAME);
-
     return _gsignond_db_metadata_database_open (
-            GSIGNOND_DB_SQL_DATABASE (self), filename,
+            GSIGNOND_DB_SQL_DATABASE (self),
+            GSIGNOND_METADATA_DB_FILENAME,
             SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
 }
 
index 735e6e4..9960cb9 100644 (file)
  * 02110-1301 USA
  */
 
-#include "gsignond-daemon.h"
-
 #include <gmodule.h>
 
+#include "config.h"
+
+#include "gsignond-daemon.h"
+
 #include "gsignond/gsignond-config.h"
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-error.h"
@@ -209,15 +211,18 @@ _init_extensions (GSignondDaemon *self)
 {
     gboolean res = TRUE;
     gboolean symfound;
-    const gchar *ext_path;
+    const gchar *ext_path = GSIGNOND_EXTENSIONS_DIR;
     const gchar *ext_name;
     gchar *mod_name;
     gchar *mod_filename;
     gchar *initf_name;
     GSignondExtension* (*ext_init) (void);
 
-    ext_path = gsignond_config_get_string (self->priv->config, 
-        GSIGNOND_CONFIG_GENERAL_EXTENSIONS_DIR);
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv ("SSO_EXTENSIONS_DIR");
+    if (env_val)
+        ext_path = env_val;
+#   endif
     ext_name = gsignond_config_get_string (self->priv->config,
         GSIGNOND_CONFIG_GENERAL_EXTENSION);
     if (ext_name && !ext_path) return FALSE;
index 796bea6..be18be1 100644 (file)
@@ -7,6 +7,8 @@ libgsignond_plugins_la_CPPFLAGS = \
     -I$(top_srcdir)/src \
     -I$(top_srcdir)/include \
     -I$(top_builddir)/src \
+    -DGSIGNOND_BIN_DIR='"$(bindir)"' \
+    -DGSIGNOND_PLUGINS_DIR='"$(pluginsdir)"' \
     $(GSIGNOND_CFLAGS)
 
 libgsignond_plugins_la_LIBADD =    \
index 4f94e4a..aac3c7a 100644 (file)
@@ -26,6 +26,8 @@
 #include <string.h>
 #include <stdio.h>
 
+#include "config.h"
+
 #include "gsignond/gsignond-log.h"
 #include "common/gsignond-plugin-loader.h"
 #include "gsignond-plugin-proxy-factory.h"
@@ -47,8 +49,14 @@ static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, };
 
 static void _enumerate_plugins(GSignondPluginProxyFactory* self)
 {
-    GDir* plugin_dir = g_dir_open(gsignond_config_get_string (self->config, 
-        GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), 0, NULL);
+    const gchar *plugin_path = GSIGNOND_PLUGINS_DIR;
+
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv("SSO_PLUGINS_DIR");
+    if (env_val)
+        plugin_path = env_val;
+#   endif
+    GDir* plugin_dir = g_dir_open(plugin_path, 0, NULL);
     if (plugin_dir == NULL) {
         WARN ("plugin directory empty");
         return;
@@ -61,11 +69,7 @@ static void _enumerate_plugins(GSignondPluginProxyFactory* self)
     
     self->methods = g_malloc0(sizeof(gchar*) * (n_plugins + 1));
 
-    DBG ("enumerate plugins in %s (factory=%p)",
-         gsignond_config_get_string (self->config,
-                                     GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR),
-                                     self
-        );
+    DBG ("enumerate plugins in %s (factory=%p)", plugin_path, self);
     gchar **method_iter = self->methods;
     while (1) {
         const gchar* plugin_soname = g_dir_read_name(plugin_dir);
index 7d6291a..1de047a 100644 (file)
@@ -23,6 +23,8 @@
  * 02110-1301 USA
  */
 
+#include "config.h"
+
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-error.h"
 #include "gsignond/gsignond-plugin-interface.h"
@@ -677,6 +679,17 @@ gsignond_plugin_remote_new (
     GSignondPluginRemote *plugin = NULL;
     GSignondPipeStream *stream = NULL;
     gboolean ret = FALSE;
+    const gchar *bin_path = GSIGNOND_BIN_DIR;
+    const gchar *plugin_path = GSIGNOND_PLUGINS_DIR;
+
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv("SSO_BIN_DIR");
+    if (env_val)
+        bin_path = env_val;
+    env_val = g_getenv("SSO_PLUGINS_DIR");
+    if (env_val)
+        plugin_path = env_val;
+#   endif
 
     /* This guarantees that writes to a pipe will never cause
      * a process terminanation via SIGPIPE, and instead a proper
@@ -685,10 +698,8 @@ gsignond_plugin_remote_new (
 
     /* Spawn child process */
     argv = g_malloc0 ((3 + 1) * sizeof (gchar *));
-    argv[0] = g_build_filename (gsignond_config_get_string (config,
-            GSIGNOND_CONFIG_GENERAL_BIN_DIR), GSIGNOND_PLUGIND_NAME, NULL);
-    argv[1] = g_module_build_path (gsignond_config_get_string (config,
-            GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type);
+    argv[0] = g_build_filename (bin_path, GSIGNOND_PLUGIND_NAME, NULL);
+    argv[1] = g_module_build_path (plugin_path, plugin_type);
     argv[2] = g_strdup(plugin_type);
     ret = g_spawn_async_with_pipes (NULL, argv, NULL,
             G_SPAWN_DO_NOT_REAP_CHILD, NULL,
index d098e9e..a142cb8 100644 (file)
@@ -33,6 +33,8 @@
 #include <mntent.h>
 #include <ecryptfs.h>
 
+#include "config.h"
+
 #include "tizen-storage-manager.h"
 #include "gsignond/gsignond-log.h"
 #include "gsignond/gsignond-utils.h"
@@ -79,16 +81,16 @@ _set_config (ExtensionTizenStorageManager *self, GSignondConfig *config)
 
     gchar *user_dir = g_strdup_printf ("gsignond.%s", g_get_user_name ());
     const gchar *storage_path = gsignond_config_get_string (
-                                       config,
+                                       parent->config,
                                        GSIGNOND_CONFIG_GENERAL_STORAGE_PATH);
-    if (storage_path)
-        parent->location = g_build_filename (storage_path,
-                                             user_dir,
-                                             NULL);
-    else
-        parent->location = g_build_filename ("/var/db",
-                                             user_dir,
-                                             NULL);
+    if (!storage_path)
+        storage_path = BASE_STORAGE_DIR;
+#   ifdef ENABLE_DEBUG
+    const gchar *env_val = g_getenv("SSO_STORAGE_PATH");
+    if (env_val)
+        storage_path = env_val;
+#   endif
+    parent->location = g_build_filename (storage_path, user_dir, NULL);
     g_free (user_dir);
     self->priv->cdir = g_strdup_printf ("%s.efs", parent->location);
     DBG ("location %s encryption point %s", parent->location, self->priv->cdir);
index 2f4e470..355e639 100644 (file)
@@ -93,12 +93,9 @@ setup_daemon (void)
     fail_if(exe_name == NULL);
     
     fail_if (g_setenv ("G_MESSAGES_DEBUG", "all", TRUE) == FALSE);
-    fail_if (g_setenv ("SSO_IDENTITY_TIMEOUT", "5", TRUE) == FALSE);
-    fail_if (g_setenv ("SSO_DAEMON_TIMEOUT", "5", TRUE) == FALSE);
-    fail_if (g_setenv ("SSO_AUTH_SESSION_TIMEOUT", "5", TRUE) == FALSE);
+    fail_if (g_setenv ("GSIGNOND_CONFIG", "daemontest.conf", TRUE) == FALSE);
     fail_if (g_setenv ("SSO_STORAGE_PATH", "/tmp/gsignond", TRUE) == FALSE);
     fail_if (g_setenv ("SSO_KEYCHAIN_SYSCTX", exe_name, TRUE) == FALSE);
-    fail_if (g_setenv ("SSO_PLUGIN_TIMEOUT", "5", TRUE) == FALSE);
 
     DBG ("Programe pid %d, name : %s\n", getpid(), exe_name);
     free(exe_name);
diff --git a/test/daemon/daemontest.conf b/test/daemon/daemontest.conf
new file mode 100644 (file)
index 0000000..22b29cd
--- /dev/null
@@ -0,0 +1,33 @@
+#
+# This group contains top-level settings.
+#
+[General]
+
+# Define extension / platform adaptation module to use.
+# 'default' is a dummy one with no encrypted storage, but with basic Unix
+# discretionary access control.
+#Extension = default
+#
+# Base path where user specific database directories will be located.
+#StoragePath = /tmp/gsignond
+#
+# Timeout for unloading cached plugin instances.
+PluginTimeout = 5
+#
+# System security context of the keychain UI
+#KeychainSystemContext = ""
+
+#
+# D-Bus related settings.
+#
+[ObjectTimeouts]
+
+# Timeout for the daemon. Daemon will exit after specified idle time.
+DaemonTimeout = 5
+#
+# Timeout for the identity objects.
+IdentityTimeout = 5
+#
+# Timeout for the authentication session objects.
+AuthSessionTimeout = 5
+
index 811b541..5574e85 100644 (file)
@@ -556,12 +556,11 @@ START_TEST (test_pluginproxyfactory_proxy_timeout)
     GSignondConfig *config = NULL;
 
     /* CASE 1: proxy timeout disabled */
-    g_setenv ("SSO_PLUGIN_TIMEOUT", "0", TRUE);
-  
     config = gsignond_config_new();
     fail_if(config == NULL);
+    gsignond_config_set_integer (config, GSIGNOND_CONFIG_PLUGIN_TIMEOUT, 0);
 
-    factory = gsignond_plugin_proxy_factory_new ( config);
+    factory = gsignond_plugin_proxy_factory_new (config);
     fail_if (factory == NULL);
 
     proxy1 = gsignond_plugin_proxy_factory_get_plugin (factory, "ssotest");
@@ -580,10 +579,9 @@ START_TEST (test_pluginproxyfactory_proxy_timeout)
     g_object_unref (factory);
 
     /* CASE 2: proxy timeout enbled */ 
-    g_setenv ("SSO_PLUGIN_TIMEOUT", "1", TRUE);
-
     config = gsignond_config_new();
     fail_if(config == NULL);
+    gsignond_config_set_integer (config, GSIGNOND_CONFIG_PLUGIN_TIMEOUT, 1);
 
     factory = gsignond_plugin_proxy_factory_new (config);
     fail_if (factory == NULL);
@@ -603,9 +601,9 @@ START_TEST (test_pluginproxyfactory_proxy_timeout)
     g_object_unref(factory);
 
     /* CASE 3: proxy timeout enable - request recently closed plugin */
-    g_setenv ("SSO_PLUGIN_TIMEOUT", "2", TRUE);
     config = gsignond_config_new ();
     fail_if (config == NULL);
+    gsignond_config_set_integer (config, GSIGNOND_CONFIG_PLUGIN_TIMEOUT, 2);
 
     factory = gsignond_plugin_proxy_factory_new(config);
     fail_if (factory == NULL);
index 18d1475..fde7565 100644 (file)
@@ -533,25 +533,22 @@ START_TEST (test_plugind_daemon)
     GSignondPluginDaemon *daemon = NULL;
     const gchar *plugin_type = "password";
 
-    GSignondConfig* config = gsignond_config_new ();
-    fail_if(config == NULL);
+    const gchar *plugin_dir = g_getenv("SSO_PLUGINS_DIR");
+    fail_if (plugin_dir == NULL);
 
-    gchar *plugin_path = g_module_build_path (gsignond_config_get_string (
-                config, GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), "nonexisting");
+    gchar *plugin_path = g_module_build_path (plugin_dir, "nonexisting");
     fail_if (plugin_path == NULL);
     daemon = gsignond_plugin_daemon_new (plugin_path, "nonexisting", 0, 1);
     g_free (plugin_path);
     fail_if (daemon != NULL);
 
-    plugin_path = g_module_build_path (gsignond_config_get_string (
-            config, GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type);
+    plugin_path = g_module_build_path (plugin_dir, plugin_type);
     fail_if (plugin_path == NULL);
     daemon = gsignond_plugin_daemon_new (plugin_path, plugin_type, 0, 1);
     g_free (plugin_path);
     fail_if (daemon == NULL);
     g_object_unref (daemon);
     daemon = NULL;
-    g_object_unref(config);
 }
 END_TEST