Add support for overriding the bus type using environment variable
authorImran Zaman <imran.zaman@intel.com>
Fri, 19 Sep 2014 14:27:01 +0000 (17:27 +0300)
committerImran Zaman <imran.zaman@intel.com>
Fri, 19 Sep 2014 14:27:09 +0000 (17:27 +0300)
Change-Id: Ie660e9adf86943cf84e63645c1b8c4d54a5b38ea
Signed-off-by: Imran Zaman <imran.zaman@intel.com>
14 files changed:
configure
configure.ac
dists/debian/changelog
dists/rpm/gum-suse.spec
dists/rpm/tizen/packaging/gumd.changes
dists/rpm/tizen/packaging/gumd.spec
docs/building.xml
docs/html/index.html
docs/html/um-building.html
src/daemon/main.c
src/lib/gum-group-service.c
src/lib/gum-user-service.c
test/data/services/org.tizen.SecurityAccounts.gUserManagement.service [deleted file]
test/data/test-gumd-dbus.conf

index 5e0a88c..5aafafa 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for gumd 0.0.4.
+# Generated by GNU Autoconf 2.69 for gumd 0.0.5.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='gumd'
 PACKAGE_TARNAME='gumd'
-PACKAGE_VERSION='0.0.4'
-PACKAGE_STRING='gumd 0.0.4'
+PACKAGE_VERSION='0.0.5'
+PACKAGE_STRING='gumd 0.0.5'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL='https://github.com/01org/gumd'
 
@@ -1402,7 +1402,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures gumd 0.0.4 to adapt to many kinds of systems.
+\`configure' configures gumd 0.0.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1472,7 +1472,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of gumd 0.0.4:";;
+     short | recursive ) echo "Configuration of gumd 0.0.5:";;
    esac
   cat <<\_ACEOF
 
@@ -1631,7 +1631,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-gumd configure 0.0.4
+gumd configure 0.0.5
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1996,7 +1996,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by gumd $as_me 0.0.4, which was
+It was created by gumd $as_me 0.0.5, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2864,7 +2864,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='gumd'
- VERSION='0.0.4'
+ VERSION='0.0.5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -13921,7 +13921,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by gumd $as_me 0.0.4, which was
+This file was extended by gumd $as_me 0.0.5, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13988,7 +13988,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-gumd config.status 0.0.4
+gumd config.status 0.0.5
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
index 39eb923..6541b97 100644 (file)
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.60])
-AC_INIT([gumd], [0.0.4],[],[],[https://github.com/01org/gumd])
+AC_INIT([gumd], [0.0.5],[],[],[https://github.com/01org/gumd])
 AC_CONFIG_SRCDIR([src/daemon/main.c])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([build-aux])
index 90ff3dc..37fba42 100644 (file)
@@ -1,3 +1,9 @@
+gumd (0.0.5-1) unstable; urgency=low
+
+  * Add support for overriding the bus type using environment variable
+
+ -- Imran Zaman <imran.zaman@intel.com>  Fri, 19 Sep  2014 18:00:00 +0300
+
 gumd (0.0.4-5) unstable; urgency=low
 
   * Added primary group name for new user in the configuration file
index acc824f..2edf4eb 100644 (file)
@@ -7,8 +7,8 @@
 
 Name: gumd
 Summary: User management daemon and client library
-Version: 0.0.4
-Release: 5
+Version: 0.0.5
+Release: 1
 Group: System/Daemons
 License: LGPL-2.1+
 Source: %{name}-%{version}.tar.gz
@@ -135,6 +135,9 @@ mkdir -p %{_sysconfdir}/%{name}/groupdel.d
 
 
 %changelog
+* Fri Sep 19 2014 Imran Zaman <imran.zaman@intel.com>
+- Add support for overriding the bus type using environment variable
+
 * Mon Sep 08 2014 Imran Zaman <imran.zaman@intel.com>
 - Added primary group name for new user in the configuration file
 
index 6485c7f..6eee629 100644 (file)
@@ -1,3 +1,6 @@
+* Fri Sep 19 2014 Imran Zaman <imran.zaman@intel.com>
+- Add support for overriding the bus type using environment variable
+
 * Mon Sep 08 2014 Imran Zaman <imran.zaman@intel.com>
 - Added primary group name for new user in the configuration file
 
index 163950c..6e2b2dd 100644 (file)
@@ -6,8 +6,8 @@
 
 Name: gumd
 Summary: User management daemon and client library
-Version: 0.0.4
-Release: 5
+Version: 0.0.5
+Release: 1
 Group: Security/Accounts
 License: LGPL-2.1+
 Source: %{name}-%{version}.tar.gz
index c02f169..157c64c 100644 (file)
             </para>
           </listitem>
         </itemizedlist>
+       This setting can be overridden at runtime by setting GUM_BUS_TYPE
+       environment variable to "p2p" or "system". Note that the environment
+       needs to be set for both daemon and client side.
       </para>
     </formalpara>
 
index 26295a4..fc56827 100644 (file)
@@ -15,7 +15,7 @@
 <div>
 <div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">gumd API Reference Manual</p></th></tr></table></div>
 <div><p class="releaseinfo">This document discusses the details of user management 
-        daemon (gumd) and client library (libgum) with version 0.0.4
+        daemon (gumd) and client library (libgum) with version 0.0.5
 .
         </p></div>
 </div>
index 5516e67..9c1bd2a 100644 (file)
             </p></li>
 </ul></div>
 <p>
+       This setting can be overridden at runtime by setting GUM_BUS_TYPE
+       environment variable to "p2p" or "system". Note that the environment
+       needs to be set for both daemon and client side.
       </p>
 </div>
 <div class="refsect1">
index 9b0ecbf..2fce257 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * This file is part of gumd
  *
- * Copyright (C) 2012 - 2013 Intel Corporation.
+ * Copyright (C) 2012 - 2014 Intel Corporation.
  *
  * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
  *          Imran Zaman <imran.zaman@intel.com>
 #include "dbus/gumd-dbus-server-msg-bus.h"
 #include "dbus/gumd-dbus-server-p2p.h"
 
+static const gchar *_bus_type =
+#ifdef GUM_BUS_TYPE_P2P
+    "p2p";
+#else
+    "system";
+#endif
 static GumdDbusServer *_server = NULL;
 static guint _sig_source_id[3];
 
@@ -70,12 +76,15 @@ static gboolean
 _start_dbus_server (
                GMainLoop *main_loop)
 {
-
-#ifdef GUM_BUS_TYPE_P2P
-    _server = GUMD_DBUS_SERVER (gumd_dbus_server_p2p_new ());
-#else
-    _server = GUMD_DBUS_SERVER (gumd_dbus_server_msg_bus_new ());
-#endif
+    const gchar *env;
+
+    env = getenv ("GUM_BUS_TYPE");
+    if (env)
+        _bus_type = env;
+    if (g_strcmp0 (_bus_type, "p2p") == 0)
+        _server = GUMD_DBUS_SERVER (gumd_dbus_server_p2p_new ());
+    else
+        _server = GUMD_DBUS_SERVER (gumd_dbus_server_msg_bus_new ());
 
     if (!_server) {
        return FALSE;
index ea6529b..299ff83 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * This file is part of gum
  *
- * Copyright (C) 2013 Intel Corporation.
+ * Copyright (C) 2013 - 2014 Intel Corporation.
  *
  * Contact: Imran Zaman <imran.zaman@intel.com>
  *
 
 #include "gum-group-service.h"
 
+static const gchar *_bus_type =
+#ifdef GUM_BUS_TYPE_P2P
+    "p2p";
+#else
+    "system";
+#endif
 static GHashTable *group_service_objects = NULL;
 static GMutex mutex;
 
@@ -99,6 +105,7 @@ _on_group_service_destroyed (
 GumDbusGroupService *
 gum_group_service_get_instance ()
 {
+    const gchar *env;
     GumDbusGroupService *group_service = NULL;
     GDBusConnection *connection = NULL;
     GError *error = NULL;
@@ -109,16 +116,19 @@ gum_group_service_get_instance ()
         return group_service;
     }
 
-#ifdef GUM_BUS_TYPE_P2P
-    gchar *bus_address = g_strdup_printf (GUM_DBUS_ADDRESS,
+    env = getenv ("GUM_BUS_TYPE");
+    if (env)
+        _bus_type = env;
+    if (g_strcmp0 (_bus_type, "p2p") == 0) {
+        gchar *bus_address = g_strdup_printf (GUM_DBUS_ADDRESS,
             g_get_user_runtime_dir());
-    connection = g_dbus_connection_new_for_address_sync (bus_address,
+        connection = g_dbus_connection_new_for_address_sync (bus_address,
             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL, NULL, &error);
-    g_free (bus_address);
-#else
-    connection = g_bus_get_sync (GUM_BUS_TYPE, NULL, &error);
-    bus_name = GUM_SERVICE;
-#endif
+        g_free (bus_address);
+    } else {
+        connection = g_bus_get_sync (GUM_BUS_TYPE, NULL, &error);
+        bus_name = GUM_SERVICE;
+    }
 
     group_service = gum_dbus_group_service_proxy_new_sync (connection,
             G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, bus_name,
index 664a0ee..baa5877 100644 (file)
@@ -3,7 +3,7 @@
 /*
  * This file is part of gum
  *
- * Copyright (C) 2013 Intel Corporation.
+ * Copyright (C) 2013 - 2014 Intel Corporation.
  *
  * Contact: Imran Zaman <imran.zaman@intel.com>
  *
 
 #include "gum-user-service.h"
 
+static const gchar *_bus_type =
+#ifdef GUM_BUS_TYPE_P2P
+    "p2p";
+#else
+    "system";
+#endif
 static GHashTable *user_service_objects = NULL;
 static GMutex mutex;
 
@@ -99,6 +105,7 @@ _on_user_service_destroyed (
 GumDbusUserService *
 gum_user_service_get_instance ()
 {
+    const gchar *env;
     GumDbusUserService *user_service = NULL;
     GDBusConnection *connection = NULL;
     GError *error = NULL;
@@ -109,16 +116,19 @@ gum_user_service_get_instance ()
         return user_service;
     }
 
-#ifdef GUM_BUS_TYPE_P2P
-    gchar *bus_address = g_strdup_printf (GUM_DBUS_ADDRESS,
+    env = getenv ("GUM_BUS_TYPE");
+    if (env)
+        _bus_type = env;
+    if (g_strcmp0 (_bus_type, "p2p") == 0) {
+        gchar *bus_address = g_strdup_printf (GUM_DBUS_ADDRESS,
             g_get_user_runtime_dir());
-    connection = g_dbus_connection_new_for_address_sync (bus_address,
+        connection = g_dbus_connection_new_for_address_sync (bus_address,
             G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, NULL, NULL, &error);
-    g_free (bus_address);
-#else
-    connection = g_bus_get_sync (GUM_BUS_TYPE, NULL, &error);
-    bus_name = GUM_SERVICE;
-#endif
+        g_free (bus_address);
+    } else {
+        connection = g_bus_get_sync (GUM_BUS_TYPE, NULL, &error);
+        bus_name = GUM_SERVICE;
+    }
 
     user_service = gum_dbus_user_service_proxy_new_sync (connection,
             G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, bus_name,
diff --git a/test/data/services/org.tizen.SecurityAccounts.gUserManagement.service b/test/data/services/org.tizen.SecurityAccounts.gUserManagement.service
deleted file mode 100644 (file)
index e10e16e..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.tizen.SecurityAccounts.gUserManagement
-Exec=/home/imran/work/um/gumd/src/daemon/gumd
index 9336fb2..5590592 100644 (file)
@@ -1,5 +1,5 @@
 <busconfig>
-    <type>session</type>
+    <type>p2p</type>
     <listen>unix:tmpdir=/tmp/</listen>
     <servicedir>/home/imran/work/um/gumd/test/data/services</servicedir>
     <policy context="default">