From: Daniel Wagner <[email protected]>
---
plugins/session_policy_ivi.c | 36 ++++++++++++++++++++++++++++--------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/plugins/session_policy_ivi.c b/plugins/session_policy_ivi.c
index 9d3f457..25be047 100644
--- a/plugins/session_policy_ivi.c
+++ b/plugins/session_policy_ivi.c
@@ -90,20 +90,40 @@ static struct connman_session_config *new_config(void)
return config;
}
+static char *parse_ident(unsigned char *context, unsigned int size)
+{
+ char *str, *ident, **tokens;
+
+ str = g_strndup((const gchar*)context, (gsize) size);
+ if (str == NULL)
+ return NULL;
+
+ DBG("SELinux context %s", str);
+
+ tokens = g_strsplit(str, ":", 0);
+ if (tokens == NULL) {
+ g_free(str);
+ return NULL;
+ }
+
+ ident = g_strdup(tokens[2]);
+ g_strfreev(tokens);
+
+ DBG("ident: %s", ident);
+
+ return ident;
+}
+
static void selinux_context_reply(unsigned char *context, unsigned int size,
void *user_data)
{
struct create_data *data = user_data;
struct policy_data *policy;
- char *str;
+ char *ident;
DBG("session %p", data->session);
- str = g_strndup((const gchar*)context, (gsize) size);
- if (str == NULL)
- goto err;
-
- DBG("SELinux context %s", str);
+ ident = parse_ident(context, size);
policy = g_try_new0(struct policy_data, 1);
if (policy == NULL)
@@ -118,7 +138,7 @@ static void selinux_context_reply(unsigned char *context,
unsigned int size,
(*data->callback)(data->session, policy->config, data->user_data);
g_free(data);
- g_free(str);
+ g_free(ident);
return;
err:
@@ -127,7 +147,7 @@ err:
cleanup_policy(policy);
g_free(data);
- g_free(str);
+ g_free(ident);
}
static int policy_ivi_create(struct connman_session *session,
--
1.7.12.1.382.gb0576a6
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman