[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCHx7] Misc patches



Richard W.M. Jones wrote:

>>From 91c9e00ddc528318b485137b7749e0315c76bb49 Mon Sep 17 00:00:00 2001
> From: Richard Jones <rjones centos5x32 home annexia org>
> Date: Thu, 13 Aug 2009 14:43:57 +0100
> Subject: [PATCH 6/7] selinux: Don't fail if libselinux is not found.
>
> ---
>  daemon/selinux.c |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/daemon/selinux.c b/daemon/selinux.c
> index ad5eaa1..575baf5 100644
> --- a/daemon/selinux.c
> +++ b/daemon/selinux.c
> @@ -30,8 +30,6 @@
>  #include "daemon.h"
>  #include "actions.h"
>
> -#ifdef HAVE_LIBSELINUX
> -
>  /* setcon is only valid under the following circumstances:
>   * - single threaded
>   * - enforcing=0
> @@ -39,7 +37,7 @@
>  int
>  do_setcon (const char *context)
>  {
> -#ifdef HAVE_SETCON
> +#if defined(HAVE_LIBSELINUX) && defined(HAVE_SETCON)

Looks correct.
[but there's a bug in the context below]

FWIW (yes, this can be sensitive -- I'm not trying to push),
I find this to be more readable, since there's far less syntax to endure:

  #if HAVE_LIBSELINUX && HAVE_SETCON

>    if (setcon ((char *) context) == -1) {
>      reply_with_perror ("setcon");
>      return -1;
> @@ -55,7 +53,7 @@ do_setcon (const char *context)
>  char *
>  do_getcon (void)
>  {
> -#ifdef HAVE_GETCON
> +#if defined(HAVE_LIBSELINUX) && defined(HAVE_GETCON)
>    security_context_t context;
>    char *r;
>
> @@ -77,5 +75,3 @@ do_getcon (void)
>    return -1;

That should be "return NULL", not return -1.

>  #endif
>  }
> -
> -#endif /* HAVE_LIBSELINUX */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]