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
* as haifux_t.
*/
- str = g_strdup((const gchar*)context);
- if (str == NULL)
- return NULL;
-
- DBG("SELinux context %s", str);
-
- tokens = g_strsplit(str, ":", 0);
- if (tokens == NULL) {
- g_free(str);
+ tokens = g_strsplit(context, ":", 0);
+ if (g_strv_length(tokens) < 2) {
+ g_strfreev(tokens);
return NULL;
}
ident = g_strdup(tokens[2]);
g_strfreev(tokens);
- g_free(str);
return ident;
}
if (err < 0)
goto done;
- ident = parse_ident(context);
+ DBG("SELinux context %s", context);
+
+ ident = parse_selinux_type((const char*)context);
if (ident == NULL) {
err = -EINVAL;
goto done;