From: Daniel Wagner <[email protected]>
selinux_context_reply() should handle the 'type' conversion of
data it gets from D-Bus.
---
plugins/session_policy_local.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/plugins/session_policy_local.c b/plugins/session_policy_local.c
index 1520765..12d61c2 100644
--- a/plugins/session_policy_local.c
+++ b/plugins/session_policy_local.c
@@ -73,9 +73,9 @@ static void cleanup_policy(gpointer user_data)
g_free(policy);
}
-static char *parse_ident(const unsigned char *context)
+static char *parse_selinux_type(const char *context)
{
- char *str, *ident, **tokens;
+ char *ident, **tokens;
/*
* SELinux combines Role-Based Access Control (RBAC), Type
@@ -95,23 +95,14 @@ static char *parse_ident(const unsigned char *context)
* as haifux_t.
*/
- str = g_strdup((const gchar*)context);
- if (str == NULL)
+ tokens = g_strsplit(context, ":", 0);
+ if (tokens == NULL)
return NULL;
- DBG("SELinux context %s", str);
-
- tokens = g_strsplit(str, ":", 0);
- if (tokens == NULL) {
- g_free(str);
- return NULL;
- }
-
/* Use the SELinux type as identification token. */
ident = g_strdup(tokens[2]);
g_strfreev(tokens);
- g_free(str);
return ident;
}
@@ -160,14 +151,22 @@ static void selinux_context_reply(int error,
struct create_data *data = cbd->data;
struct policy_data *policy;
struct connman_session_config *config = NULL;
- char *ident = NULL;
+ char *ident = NULL, *ctx = NULL;
DBG("session %p", data->session);
if (error < 0)
goto done;
- ident = parse_ident(context);
+ ctx = g_strdup((const gchar*)context);
+ if (ctx == NULL) {
+ error = -ENOMEM;
+ goto done;
+ }
+
+ DBG("SELinux context %s", ctx);
+
+ ident = parse_selinux_type(ctx);
if (ident == NULL) {
error = -EINVAL;
goto done;
@@ -189,6 +188,7 @@ done:
g_free(cbd);
g_free(data);
g_free(ident);
+ g_free(ctx);
}
static int policy_local_create(struct connman_session *session,
--
1.8.2.rc3.16.gce432ca
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman