[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 2/2] chcon: use specified_context directly
From: |
Pádraig Brady |
Subject: |
Re: [PATCH 2/2] chcon: use specified_context directly |
Date: |
Mon, 30 Jun 2014 16:43:07 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 |
On 06/30/2014 04:12 PM, Namhyung Kim wrote:
> Since it's verified by security_check_context() it can be used in
> change_file_context() without converting to context_t everytime.
>
> * src/chcon.c (change_file_context): Use specified_context directly.
> ---
> src/chcon.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/src/chcon.c b/src/chcon.c
> index cd5fba3..fee9ffb 100644
> --- a/src/chcon.c
> +++ b/src/chcon.c
> @@ -170,17 +170,14 @@ change_file_context (int fd, char const *file)
>
> if (compute_context_from_mask (file_context, &context))
> return 1;
> +
> + context_string = context_str (context);
> }
> else
> {
> - /* FIXME: this should be done exactly once, in main. */
> - context = context_new (specified_context);
> - if (!context)
> - abort ();
> + context_string = specified_context;
> }
>
> - context_string = context_str (context);
> -
> if (file_context == NULL || ! STREQ (context_string, file_context))
> {
> int fail = (affect_symlink_referent
> @@ -195,8 +192,11 @@ change_file_context (int fd, char const *file)
> }
> }
>
> - context_free (context);
> - freecon (file_context);
> + if (specified_context == NULL)
> + {
> + context_free (context);
> + freecon (file_context);
> + }
>
> return errors;
> }
>
Nice.
thanks!
Pádraig.