1 --- findutils-4.1.20/find/Makefile.am.orig Mon May 26 20:02:34 2003
2 +++ findutils-4.1.20/find/Makefile.am Wed Jan 28 15:15:13 2004
5 find_SOURCES = find.c fstype.c parser.c pred.c tree.c util.c version.c
6 EXTRA_DIST = defs.h $(man_MANS)
7 +DEFS = @DEFS@ -I. -I$(srcdir) -I.. -DWITH_SELINUX
8 INCLUDES = -I../gnulib/lib -I$(top_srcdir)/lib -I$(top_srcdir)/gnulib/lib -I../intl -DLOCALEDIR=\"$(localedir)\"
9 -LDADD = ../lib/libfind.a ../gnulib/lib/libgnulib.a @INTLLIBS@
10 +LDADD = ../lib/libfind.a ../gnulib/lib/libgnulib.a @INTLLIBS@ -lselinux
14 --- findutils-4.2.4/find/defs.h.orig 2004-11-08 20:34:16.000000000 +0100
15 +++ findutils-4.2.4/find/defs.h 2004-11-09 00:40:03.771236728 +0100
17 #define MODE_RWX (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
18 #define MODE_ALL (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
21 +#include <selinux/selinux.h>
22 +#endif /*WITH_SELINUX*/
28 struct perm_val perm; /* perm */
29 mode_t type; /* type */
30 FILE *stream; /* fprint fprint0 */
32 + security_context_t scontext; /* scontext */
33 +#endif /*WITH_SELINUX*/
34 struct format_val printf_vec; /* printf fprintf */
38 VOID *xmalloc PARAMS((size_t n));
39 VOID *xrealloc PARAMS((VOID *p, size_t n));
42 +boolean pred_scontext PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
43 +extern int (*x_getfilecon) ();
44 +#endif /*WITH_SELINUX*/
47 char *xstrdup PARAMS((char *string));
49 --- findutils-4.2.4/find/find.1.orig 2004-11-08 20:49:55.000000000 +0100
50 +++ findutils-4.2.4/find/find.1 2004-11-09 00:40:28.271512120 +0100
52 file of type \fIc\fR; if \-follow has been given, true if \fIc\fR is
53 `l'. In other words, for symbolic links, \-xtype checks the type of
54 the file that \-type does not check.
55 +.IP "\-context \fIscontext\fR"
56 +.IP "\--context \fIscontext\fR"
57 +(SELinux only) File has the security context \fIscontext\fR.
62 File's type (like in ls -l), U=unknown type (shouldn't happen)
64 File's type (like %y), plus follow symlinks: L=loop, N=nonexistent
66 +(SELinux only) file's security context.
68 A `%' character followed by any other character is discarded (but the
69 other character is printed).
70 --- findutils-4.1.7/find/find.c.selinux 2001-05-20 16:39:37.000000000 -0400
71 +++ findutils-4.1.7/find/find.c 2003-10-10 13:06:11.556058225 -0400
74 /* Pointer to the function used to stat files. */
77 +int (*x_getfilecon) ();
78 +#endif /* WITH_SELINUX */
80 /* Status value to return to system. */
84 #else /* !DEBUG_STAT */
87 + int is_selinux_enabled_flag = (is_selinux_enabled() > 0);
88 + x_getfilecon = lgetfilecon;
89 +#endif /* WITH_SELINUX */
90 #endif /* !DEBUG_STAT */
92 human_block_size (getenv ("FIND_BLOCK_SIZE"), 0, &output_block_size);
94 if (strchr ("-!(),", argv[i][0]) == NULL)
95 usage (_("paths must precede expression"));
96 predicate_name = argv[i];
98 + if (! is_selinux_enabled_flag) {
99 + if ((strncmp(predicate_name,"-context",strlen("-context"))==0) ||
100 + (strncmp(predicate_name,"--context",strlen("--context"))==0)) {
101 + error (1, 0,_("Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"),predicate_name);
105 parse_function = find_parser (predicate_name);
106 if (parse_function == NULL)
107 /* Command line option not recognized */
108 --- findutils-4.2.4/find/parser.c.orig 2004-11-08 21:18:32.000000000 +0100
109 +++ findutils-4.2.4/find/parser.c 2004-11-09 00:43:16.106997248 +0100
111 #include "../gnulib/lib/xstrtol.h"
115 +#include <selinux/selinux.h>
116 +#endif /*WITH_SELINUX*/
119 # include <libintl.h>
120 # define _(Text) gettext (Text)
122 static boolean parse_warn PARAMS((char *argv[], int *arg_ptr));
123 static boolean parse_xtype PARAMS((char *argv[], int *arg_ptr));
124 static boolean parse_quit PARAMS((char *argv[], int *arg_ptr));
126 +static boolean parse_scontext PARAMS((char *argv[], int *arg_ptr));
127 +#endif /*WITH_SELINUX*/
129 static boolean insert_regex PARAMS((char *argv[], int *arg_ptr, boolean ignore_case));
130 static boolean insert_type PARAMS((char *argv[], int *arg_ptr, boolean (*which_pred )()));
132 {ARG_TEST, "wholename", parse_wholename}, /* GNU, replaces -path */
133 {ARG_TEST, "xdev", parse_xdev},
134 {ARG_TEST, "xtype", parse_xtype}, /* GNU */
136 + {ARG_TEST, "context", parse_scontext}, /* SELINUX */
137 + {ARG_TEST, "-context", parse_scontext}, /* SELINUX */
138 +#endif /*WITH_SELINUX*/
146 - no_leaf_check = true;
148 + x_getfilecon = getfilecon;
149 +#endif /* WITH_SELINUX */
150 + no_leaf_check = true;
155 -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN\n\
156 -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
157 -used N -user NAME -xtype [bcdpfls]"));
160 + -context CONTEXT\n"));
161 +#endif /*WITH_SELINUX*/
163 actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n\
164 -fls FILE -ok COMMAND ; -print -print0 -printf FORMAT -prune -ls -delete\n\
165 @@ -1488,6 +1506,32 @@
172 +parse_scontext ( argv, arg_ptr )
176 + struct predicate *our_pred;
178 + if ( (argv == NULL) || (argv[*arg_ptr] == NULL) )
181 + our_pred = insert_primary(pred_scontext);
182 + our_pred->need_stat = false;
184 + our_pred->p_name = find_pred_name (pred_scontext);
187 + our_pred->args.scontext = argv[*arg_ptr];;
193 +#endif /*WITH_SELINUX*/
196 parse_xtype (char **argv, int *arg_ptr)
198 @@ -1646,7 +1690,11 @@
200 for (scan2++; ISDIGIT (*scan2); scan2++)
203 + if (strchr ("abcdDfFgGhHiklmnpPstuUyYZ", *scan2))
204 +#else /* WITH_SELINUX */
205 if (strchr ("abcdDfFgGhHiklmnpPstuUyY", *scan2))
206 +#endif /* WITH_SELINUX */
208 segmentp = make_segment (segmentp, format, scan2 - format,
210 --- findutils-4.1.7/find/pred.c.selinux 2001-05-20 16:39:37.000000000 -0400
211 +++ findutils-4.1.7/find/pred.c 2003-10-10 13:15:13.752422594 -0400
213 #include "modetype.h"
217 +#include <selinux/selinux.h>
218 +#endif /*WITH_SELINUX*/
220 +#ifndef FNM_CASEFOLD
221 +#define FNM_CASEFOLD (1<<4)
222 +#endif /*FNM_CASEFOLD*/
225 # include <libintl.h>
226 # define _(Text) gettext (Text)
232 /* Get or fake the disk device blocksize.
233 Usually defined by sys/param.h (if at all). */
236 {pred_used, "used "},
237 {pred_user, "user "},
238 {pred_xtype, "xtype "},
240 + {pred_scontext, "context"},
241 +#endif /*WITH_SELINUX*/
246 fprintf (fp, segment->text,
247 human_readable ((uintmax_t) stat_buf->st_uid, hbuf, 1, 1));
250 + case 'Z': /* SELinux security context */
252 + security_context_t scontext;
254 + rv = (*x_getfilecon)(rel_pathname, &scontext);
257 + (void) fprintf(stderr, "getfileconf(%s): %s",
258 + pathname, strerror(errno));
259 + (void) fflush(stderr);
262 + segment->text[segment->text_len] = 's';
263 + (void) fprintf (fp, segment->text, scontext);
268 +#endif /* WITH_SELINUX */
272 @@ -1220,6 +1250,34 @@
274 return (pred_type (pathname, &sbuf, pred_ptr));
281 +pred_scontext ( pathname, stat_buf, pred_ptr )
283 + struct stat *stat_buf;
284 + struct predicate *pred_ptr;
287 + security_context_t scontext;
289 + rv = (* x_getfilecon)(rel_pathname, &scontext);
292 + (void) fprintf(stderr, "getfilecon(%s): %s\n", pathname, strerror(errno));
293 + (void) fflush(stderr);
297 + rv= (strcmp( scontext,pred_ptr->args.scontext) == 0 );
302 +#endif /*WITH_SELINUX*/
305 /* 1) fork to get a child; parent remembers the child pid
306 2) child execs the command requested
307 --- findutils-4.1.7/find/util.c.selinux 2001-05-20 16:39:37.000000000 -0400
308 +++ findutils-4.1.7/find/util.c 2003-10-10 13:19:10.869534272 -0400
310 last_pred->no_default_print = false;
311 last_pred->need_stat = true;
312 last_pred->args.str = NULL;
314 + last_pred->args.scontext = NULL;
316 last_pred->pred_next = NULL;
317 last_pred->pred_left = NULL;
318 last_pred->pred_right = NULL;
319 --- findutils-4.2.4/po/pl.po.orig 2004-11-09 00:39:40.614757048 +0100
320 +++ findutils-4.2.4/po/pl.po 2004-11-09 00:44:33.436241416 +0100
322 msgid "paths must precede expression"
323 msgstr "¶cie¿ki musz± poprzedzaæ wyra¿enie"
327 +msgid "Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"
328 +msgstr "B³±d: b³êdne wyra¿enie %s: j±dro nie ma w³±czonej obs³ugi SELinuksa.\n"
330 #. Command line option not recognized
334 " -wholename WZORZEC -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n"
335 " -used N -user NAZWA -xtype [bcdpfls]"
337 +#: find/parser.c:738
338 +msgid " -context CONTEXT\n"
339 +msgstr " -context KONTEKST\n"
343 "actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n"