summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang zhengguang <zhengguang.zhang@intel.com>2014-10-11 15:06:14 +0800
committerZhang zhengguang <zhengguang.zhang@intel.com>2014-11-07 15:12:44 +0800
commit113ccd0ca92ab8fe8a6e6c2db190cbcbeebe912d (patch)
tree5fd4aa178c6ce5043aa31450eff91bf6c9418acc
parent58bd810c3a61593a3c7494f843fc5dfc1d411769 (diff)
downloadconnman-113ccd0ca92ab8fe8a6e6c2db190cbcbeebe912d.tar.gz
connman-113ccd0ca92ab8fe8a6e6c2db190cbcbeebe912d.tar.bz2
connman-113ccd0ca92ab8fe8a6e6c2db190cbcbeebe912d.zip
multi-user: Add function to get dbus user id synchronously
Change-Id: Ic41643e5f8b6e1a28ce00e0456d961fe2de7a7fb
-rw-r--r--include/dbus.h4
-rw-r--r--src/dbus.c25
2 files changed, 29 insertions, 0 deletions
diff --git a/include/dbus.h b/include/dbus.h
index 26f94d63..3087fe40 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -180,6 +180,10 @@ int connman_dbus_get_connection_unix_user(DBusConnection *connection,
connman_dbus_get_connection_unix_user_cb_t func,
void *user_data);
+int connman_dbus_get_connection_unix_user_sync(DBusConnection *connection,
+ const char *bus_name,
+ unsigned int *user_id);
+
typedef void (* connman_dbus_get_context_cb_t) (const unsigned char *context,
void *user_data, int err);
diff --git a/src/dbus.c b/src/dbus.c
index d80a46ce..260cec69 100644
--- a/src/dbus.c
+++ b/src/dbus.c
@@ -524,6 +524,31 @@ err:
return err;
}
+int connman_dbus_get_connection_unix_user_sync(DBusConnection *connection,
+ const char *bus_name,
+ unsigned int *user_id)
+{
+ unsigned long uid;
+ DBusError err;
+
+ dbus_error_init(&err);
+
+ uid = dbus_bus_get_unix_user(connection, bus_name, &err);
+
+ if (uid == (unsigned long)-1) {
+ DBG("Can not get unix user ID!");
+ if (dbus_error_is_set(&err)) {
+ DBG("%s", err.message);
+ dbus_error_free(&err);
+ }
+ return -1;
+ }
+
+ *user_id = (unsigned int)uid;
+
+ return 0;
+}
+
static unsigned char *parse_context(DBusMessage *msg)
{
DBusMessageIter iter, array;