From 4b7fbdd9bbbd807e2ff299918141dc238f40b8e4 Mon Sep 17 00:00:00 2001 From: Imran Zaman Date: Fri, 19 Sep 2014 17:27:01 +0300 Subject: [PATCH] Add support for overriding the bus type using environment variable Change-Id: Ie660e9adf86943cf84e63645c1b8c4d54a5b38ea Signed-off-by: Imran Zaman --- configure | 20 ++++++++-------- configure.ac | 2 +- dists/debian/changelog | 6 +++++ dists/rpm/gum-suse.spec | 7 ++++-- dists/rpm/tizen/packaging/gumd.changes | 3 +++ dists/rpm/tizen/packaging/gumd.spec | 4 ++-- docs/building.xml | 3 +++ docs/html/index.html | 2 +- docs/html/um-building.html | 3 +++ src/daemon/main.c | 23 ++++++++++++------ src/lib/gum-group-service.c | 28 +++++++++++++++------- src/lib/gum-user-service.c | 28 +++++++++++++++------- ....tizen.SecurityAccounts.gUserManagement.service | 3 --- test/data/test-gumd-dbus.conf | 2 +- 14 files changed, 89 insertions(+), 45 deletions(-) delete mode 100644 test/data/services/org.tizen.SecurityAccounts.gUserManagement.service diff --git a/configure b/configure index 5e0a88c..5aafafa 100755 --- 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\\" diff --git a/configure.ac b/configure.ac index 39eb923..6541b97 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/dists/debian/changelog b/dists/debian/changelog index 90ff3dc..37fba42 100644 --- a/dists/debian/changelog +++ b/dists/debian/changelog @@ -1,3 +1,9 @@ +gumd (0.0.5-1) unstable; urgency=low + + * Add support for overriding the bus type using environment variable + + -- Imran Zaman 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 diff --git a/dists/rpm/gum-suse.spec b/dists/rpm/gum-suse.spec index acc824f..2edf4eb 100644 --- a/dists/rpm/gum-suse.spec +++ b/dists/rpm/gum-suse.spec @@ -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 +- Add support for overriding the bus type using environment variable + * Mon Sep 08 2014 Imran Zaman - Added primary group name for new user in the configuration file diff --git a/dists/rpm/tizen/packaging/gumd.changes b/dists/rpm/tizen/packaging/gumd.changes index 6485c7f..6eee629 100644 --- a/dists/rpm/tizen/packaging/gumd.changes +++ b/dists/rpm/tizen/packaging/gumd.changes @@ -1,3 +1,6 @@ +* Fri Sep 19 2014 Imran Zaman +- Add support for overriding the bus type using environment variable + * Mon Sep 08 2014 Imran Zaman - Added primary group name for new user in the configuration file diff --git a/dists/rpm/tizen/packaging/gumd.spec b/dists/rpm/tizen/packaging/gumd.spec index 163950c..6e2b2dd 100644 --- a/dists/rpm/tizen/packaging/gumd.spec +++ b/dists/rpm/tizen/packaging/gumd.spec @@ -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 diff --git a/docs/building.xml b/docs/building.xml index c02f169..157c64c 100644 --- a/docs/building.xml +++ b/docs/building.xml @@ -166,6 +166,9 @@ + 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. diff --git a/docs/html/index.html b/docs/html/index.html index 26295a4..fc56827 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -15,7 +15,7 @@

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 .

diff --git a/docs/html/um-building.html b/docs/html/um-building.html index 5516e67..9c1bd2a 100644 --- a/docs/html/um-building.html +++ b/docs/html/um-building.html @@ -146,6 +146,9 @@

+ 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.

diff --git a/src/daemon/main.c b/src/daemon/main.c index 9b0ecbf..2fce257 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -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 * Imran Zaman @@ -41,6 +41,12 @@ #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; diff --git a/src/lib/gum-group-service.c b/src/lib/gum-group-service.c index ea6529b..299ff83 100644 --- a/src/lib/gum-group-service.c +++ b/src/lib/gum-group-service.c @@ -3,7 +3,7 @@ /* * This file is part of gum * - * Copyright (C) 2013 Intel Corporation. + * Copyright (C) 2013 - 2014 Intel Corporation. * * Contact: Imran Zaman * @@ -31,6 +31,12 @@ #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, diff --git a/src/lib/gum-user-service.c b/src/lib/gum-user-service.c index 664a0ee..baa5877 100644 --- a/src/lib/gum-user-service.c +++ b/src/lib/gum-user-service.c @@ -3,7 +3,7 @@ /* * This file is part of gum * - * Copyright (C) 2013 Intel Corporation. + * Copyright (C) 2013 - 2014 Intel Corporation. * * Contact: Imran Zaman * @@ -31,6 +31,12 @@ #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 index e10e16e..0000000 --- a/test/data/services/org.tizen.SecurityAccounts.gUserManagement.service +++ /dev/null @@ -1,3 +0,0 @@ -[D-BUS Service] -Name=org.tizen.SecurityAccounts.gUserManagement -Exec=/home/imran/work/um/gumd/src/daemon/gumd diff --git a/test/data/test-gumd-dbus.conf b/test/data/test-gumd-dbus.conf index 9336fb2..5590592 100644 --- a/test/data/test-gumd-dbus.conf +++ b/test/data/test-gumd-dbus.conf @@ -1,5 +1,5 @@ - session + p2p unix:tmpdir=/tmp/ /home/imran/work/um/gumd/test/data/services -- 2.7.4