All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Lautrbach <plautrba@redhat.com>
To: "Christian Göttsche" <cgzones@googlemail.com>, selinux@vger.kernel.org
Subject: Re: [PATCH 1/2] libselinux/getconlist: report failures
Date: Wed, 17 Feb 2021 18:00:24 +0100	[thread overview]
Message-ID: <8735xuhbo7.fsf@redhat.com> (raw)
In-Reply-To: <20210203171654.37002-1-cgzones@googlemail.com>

Christian Göttsche <cgzones@googlemail.com> writes:

> Check the given context a priori, to print a more user friendly message,
> opposed to a generic following get_ordered_context_list/_with_level
> failure.
>
> Notify the user about failures of get_ordered_context_list/_with_level,
> so no-context-found and a failure results are distinguishable.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
>  libselinux/utils/getconlist.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libselinux/utils/getconlist.c b/libselinux/utils/getconlist.c
> index 29c16640..76654b75 100644
> --- a/libselinux/utils/getconlist.c
> +++ b/libselinux/utils/getconlist.c
> @@ -58,8 +58,14 @@ int main(int argc, char **argv)
>  			free(level);
>  			return 2;
>  		}
> -	} else
> +	} else {
>  		cur_context = argv[optind + 1];
> +		if (security_check_context(cur_context) != 0) {
> +			fprintf(stderr, "Given context '%s' is invalid.\n", cur_context);
> +			free(level);
> +			return 3;

3 is already used for "memory allocation failure: %d(%s)\n" error
But I'm not sure if it's important



> +		}
> +	}
>  
>  	/* Get the list and print it */
>  	if (level)
> @@ -72,6 +78,11 @@ int main(int argc, char **argv)
>  		for (i = 0; list[i]; i++)
>  			puts(list[i]);
>  		freeconary(list);
> +	} else {
> +		fprintf(stderr, "get_ordered_context_list%s failure: %d(%s)\n",
> +			level ? "_with_level" : "", errno, strerror(errno));
> +		free(level);
> +		return 4;
>  	}
>  
>  	free(level);
> -- 
> 2.30.0


      parent reply	other threads:[~2021-02-17 17:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-03 17:16 [PATCH 1/2] libselinux/getconlist: report failures Christian Göttsche
2021-02-03 17:16 ` [PATCH 2/2] policycoreutils/fixfiles.8: add missing file systems and merge check and verify Christian Göttsche
2021-02-17 17:15   ` Petr Lautrbach
2021-02-19 15:15     ` Petr Lautrbach
2021-02-17 17:00 ` Petr Lautrbach [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735xuhbo7.fsf@redhat.com \
    --to=plautrba@redhat.com \
    --cc=cgzones@googlemail.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.