From: Daniel Wagner <daniel.wag...@bmw-carit.de> --- plugins/session_policy_ivi.c | 50 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-)
diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c index 2c30b05..8a7503a 100644 --- a/plugins/session_policy_ivi.c +++ b/plugins/session_policy_ivi.c @@ -37,13 +37,61 @@ static DBusConnection *connection; +struct create_data { + struct connman_session *session; + connman_session_config_cb callback; + void *user_data; +}; + +static void selinux_context_reply(unsigned char *context, unsigned int size, + void *user_data) +{ + struct create_data *data = user_data; + char *str; + + DBG("session %p", data->session); + + str = g_strndup((const gchar*)context, (gsize) size); + if (str == NULL) + goto out; + + DBG("SELinux context %s", str); + +out: + (*data->callback)(data->session, NULL, data->user_data); + + g_free(data); + g_free(str); +} + static int policy_ivi_create(struct connman_session *session, connman_session_config_cb callback, void *user_data) { + struct create_data *data; + const char *owner; + DBG("session %p", session); - return -ENOMEM; + data = g_try_new0(struct create_data, 1); + if (data == NULL) + return -ENOMEM; + + data->session = session; + data->callback = callback; + data->user_data = user_data; + + owner = connman_session_get_owner(session); + + if (g_dbus_selinux_get_context(connection, owner, + selinux_context_reply, + data) == FALSE) { + connman_error("Could not get SELinux context"); + g_free(data); + return -ENXIO; + } + + return 0; } static void policy_ivi_destroy(struct connman_session *session) -- 1.7.11.4 _______________________________________________ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman