On Sunday 12 of April 2009 17:31:37 James Youngman wrote: > * 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 <[email protected]> > --- > 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 > {
Seems ok to me. Thanks! Kamil
