Hi,

On Wed, 2012-10-17 at 14:42 +0200, Daniel Wagner wrote:
> From: Daniel Wagner <daniel.wag...@bmw-carit.de>
> 
> ---
>  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 dd3bda0..70889ec 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;
> +}

This part should have been added earlier, no need to have a separate
patch to factor it out.

The function above gets interesting. The commit message really should
explain how the ident is created via the SELinux security context.
 
> +
>  static void selinux_context_reply(unsigned char *context, unsigned int size,
>                                       void *user_data)
>  {
>       struct create_data *data = user_data;
>       struct policy_data *policy = NULL;
> -     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,


_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to