findutils-patches
[Top][All Lists]
Advanced

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

[Findutils-patches] [PATCH 2/2] Bugfixes to the handling of %Z in the Re


From: James Youngman
Subject: [Findutils-patches] [PATCH 2/2] Bugfixes to the handling of %Z in the Red Hat SELinux patch.
Date: Sun, 12 Apr 2009 16:31:37 +0100

* find/pred.c (do_fprintf): If getfilecon fails, print the
relevant segment anyway, with the file context expanding to an
empty string.
* find/parser.c (make_segment): For %Z, set the cost to
NeedsAccessInfo.

Signed-off-by: James Youngman <address@hidden>
---
 find/parser.c |    4 ++++
 find/pred.c   |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/find/parser.c b/find/parser.c
index 0386ec6..bfaf734 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -3057,7 +3057,11 @@ make_segment (struct segment **segment,
     case 'h':                  /* leading directories part of path */
     case 'p':                  /* pathname */
     case 'P':                  /* pathname with ARGV element stripped */
+      *fmt++ = 's';
+      break;
+
     case 'Z':                  /* SELinux security context */
+      mycost = NeedsAccessInfo;
       *fmt++ = 's';
       break;
 
diff --git a/find/pred.c b/find/pred.c
index 784c639..47d5a02 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1057,14 +1057,21 @@ do_fprintf(struct format_val *dest,
                             mode_to_filetype(stat_buf->st_mode & S_IFMT));
          }
          break;
+
        case 'Z':               /* SELinux security context */
          {
            security_context_t scontext;
            int rv = (*options.x_getfilecon) (state.rel_pathname, &scontext);
            if (rv < 0)
              {
+               /* If getfilecon fails, there will in the general case
+                  still be some text to print.   We just make %Z expand
+                  to an empty string. */
+               checked_fprintf (dest, segment->text, "");
+
                error (0, errno, "getfilecon: %s",
                    safely_quote_err_filename (0, pathname));
+               state.exit_status = 1;
              }
            else
              {
-- 
1.5.6.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]