summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 26f94d6..3087fe4 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 d80a46c..260cec6 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;