[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] Bugfixes to the handling of %Z in the Red Hat SELinux patch.
From: |
James Youngman |
Subject: |
[PATCH 2/2] Bugfixes to the handling of %Z in the Red Hat SELinux patch. |
Date: |
Sat, 11 Jul 2009 16:05:19 +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 179061a..438f588 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -3058,7 +3058,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 3e95bf2..77c2aac 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
- [PATCH 1/2] find: add SELinux support, James Youngman, 2009/07/11
- [PATCH 2/2] Bugfixes to the handling of %Z in the Red Hat SELinux patch.,
James Youngman <=
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/11
- Message not available
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/13
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/14
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/14
- Re: [PATCH 1/2] find: add SELinux support, Eric Blake, 2009/07/14
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/20
- Re: [PATCH 1/2] find: add SELinux support, Kamil Dudka, 2009/07/20
- Re: [PATCH 1/2] find: add SELinux support, Jim Meyering, 2009/07/30