]> git.pld-linux.org Git - packages/findutils.git/blob - findutils-selinux.patch
- updated for 4.2.4
[packages/findutils.git] / findutils-selinux.patch
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
3 @@ -3,8 +3,9 @@
4  bin_PROGRAMS = find
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
11  man_MANS = find.1
12  SUBDIRS = testsuite
13  
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
16 @@ -120,6 +120,10 @@
17  #define MODE_RWX       (S_IXUSR | S_IXGRP | S_IXOTH | MODE_RW)
18  #define MODE_ALL       (S_ISUID | S_ISGID | S_ISVTX | MODE_RWX)
19  
20 +#ifdef WITH_SELINUX
21 +#include <selinux/selinux.h>
22 +#endif /*WITH_SELINUX*/
23 +
24  #if 1
25  #include <stdbool.h>
26  typedef bool boolean;
27 @@ -272,6 +276,9 @@
28      struct perm_val perm;      /* perm */
29      mode_t type;               /* type */
30      FILE *stream;              /* fprint fprint0 */
31 +#ifdef WITH_SELINUX
32 +    security_context_t scontext; /* scontext */
33 +#endif /*WITH_SELINUX*/
34      struct format_val printf_vec; /* printf fprintf */
35    } args;
36  
37 @@ -317,6 +324,11 @@
38  VOID *xmalloc PARAMS((size_t n));
39  VOID *xrealloc PARAMS((VOID *p, size_t n));
40  
41 +#ifdef WITH_SELINUX
42 +boolean pred_scontext PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
43 +extern int (*x_getfilecon) ();
44 +#endif /*WITH_SELINUX*/
45 +
46  /* xstrdup.c */
47  char *xstrdup PARAMS((char *string));
48  
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
51 @@ -302,6 +302,9 @@
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.
58  .SS ACTIONS
59  
60  .IP "\-delete\fR"
61 @@ -529,6 +532,8 @@
62  File's type (like in ls -l), U=unknown type (shouldn't happen)
63  .IP %Y
64  File's type (like %y), plus follow symlinks: L=loop, N=nonexistent
65 +.IP %Z
66 +(SELinux only) file's security context.
67  .PP
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
72 @@ -135,6 +135,9 @@
73  
74  /* Pointer to the function used to stat files. */
75  int (*xstat) ();
76 +#ifdef WITH_SELINUX
77 +int (*x_getfilecon) ();
78 +#endif /* WITH_SELINUX */
79  
80  /* Status value to return to system. */
81  int exit_status;
82 @@ -181,6 +184,10 @@
83    xstat = debug_stat;
84  #else /* !DEBUG_STAT */
85    xstat = lstat;
86 +#ifdef WITH_SELINUX
87 +  int is_selinux_enabled_flag = (is_selinux_enabled() > 0);
88 +  x_getfilecon = lgetfilecon;
89 +#endif /* WITH_SELINUX */
90  #endif /* !DEBUG_STAT */
91  
92    human_block_size (getenv ("FIND_BLOCK_SIZE"), 0, &output_block_size);
93 @@ -202,6 +209,14 @@
94        if (strchr ("-!(),", argv[i][0]) == NULL)
95         usage (_("paths must precede expression"));
96        predicate_name = argv[i];
97 +#ifdef WITH_SELINUX
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);
102 +       }
103 +      }
104 +#endif
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
110 @@ -27,6 +27,10 @@
111  #include "../gnulib/lib/xstrtol.h"
112  
113  
114 +#ifdef WITH_SELINUX
115 +#include <selinux/selinux.h>
116 +#endif /*WITH_SELINUX*/
117 +
118  #if ENABLE_NLS
119  # include <libintl.h>
120  # define _(Text) gettext (Text)
121 @@ -127,6 +131,9 @@
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));
125 +#ifdef WITH_SELINUX
126 +static boolean parse_scontext PARAMS((char *argv[], int *arg_ptr));
127 +#endif /*WITH_SELINUX*/
128  
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 )()));
131 @@ -251,6 +258,10 @@
132    {ARG_TEST,               "wholename",             parse_wholename},   /* GNU, replaces -path */
133    {ARG_TEST,               "xdev",                  parse_xdev},
134    {ARG_TEST,               "xtype",                 parse_xtype},      /* GNU */
135 +#ifdef WITH_SELINUX
136 +  {ARG_TEST,               "context",               parse_scontext},    /* SELINUX */
137 +  {ARG_TEST,               "-context",              parse_scontext},    /* SELINUX */
138 +#endif /*WITH_SELINUX*/
139    {0, 0}
140  };
141  \f
142 @@ -611,7 +622,10 @@
143  
144    dereference = true;
145    xstat = stat;
146 -  no_leaf_check = true;
147 +#ifdef WITH_SELINUX
148 +  x_getfilecon = getfilecon;
149 +#endif /* WITH_SELINUX */
150 +   no_leaf_check = true;
151    return (true);
152  }
153  
154 @@ -720,6 +734,10 @@
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]"));
158 +#ifdef WITH_SELINUX
159 +  puts (_("\
160 +      -context CONTEXT\n"));
161 +#endif /*WITH_SELINUX*/
162    puts (_("\
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 @@
166    return true;
167  }
168  
169 +#ifdef WITH_SELINUX
170 +
171 +static boolean
172 +parse_scontext ( argv, arg_ptr )
173 +     char *argv[];
174 +     int *arg_ptr;
175 +{
176 +  struct predicate *our_pred;
177 +
178 +  if ( (argv == NULL) || (argv[*arg_ptr] == NULL) )
179 +    return( false );
180 +
181 +  our_pred = insert_primary(pred_scontext);
182 +  our_pred->need_stat = false;
183 +#ifdef DEBUG
184 +  our_pred->p_name = find_pred_name (pred_scontext);
185 +#endif /*DEBUG*/
186 +
187 +  our_pred->args.scontext = argv[*arg_ptr];;
188 +
189 +  (*arg_ptr)++;
190 +  return( true );
191 +}
192 +
193 +#endif /*WITH_SELINUX*/
194 +
195  static boolean
196  parse_xtype (char **argv, int *arg_ptr)
197  {
198 @@ -1646,7 +1690,11 @@
199           if (*scan2 == '.')
200             for (scan2++; ISDIGIT (*scan2); scan2++)
201               /* Do nothing. */ ;
202 +#ifdef WITH_SELINUX
203 +         if (strchr ("abcdDfFgGhHiklmnpPstuUyYZ", *scan2))
204 +#else  /* WITH_SELINUX */
205           if (strchr ("abcdDfFgGhHiklmnpPstuUyY", *scan2))
206 +#endif /* WITH_SELINUX */
207             {
208               segmentp = make_segment (segmentp, format, scan2 - format,
209                                        (int) *scan2);
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
212 @@ -27,6 +27,14 @@
213  #include "modetype.h"
214  #include "wait.h"
215  
216 +#ifdef WITH_SELINUX
217 +#include <selinux/selinux.h>
218 +#endif /*WITH_SELINUX*/
219 +
220 +#ifndef FNM_CASEFOLD
221 +#define FNM_CASEFOLD (1<<4)
222 +#endif  /*FNM_CASEFOLD*/
223 +
224  #if ENABLE_NLS
225  # include <libintl.h>
226  # define _(Text) gettext (Text)
227 @@ -69,7 +77,6 @@
228  
229  extern int yesno ();
230  
231 -
232  /* Get or fake the disk device blocksize.
233     Usually defined by sys/param.h (if at all).  */
234  #ifndef DEV_BSIZE
235 @@ -196,6 +203,9 @@
236    {pred_used, "used    "},
237    {pred_user, "user    "},
238    {pred_xtype, "xtype   "},
239 +#ifdef WITH_SELINUX
240 +  {pred_scontext, "context"},
241 +#endif /*WITH_SELINUX*/
242    {0, "none    "}
243  };
244  
245 @@ -719,6 +729,26 @@
246           fprintf (fp, segment->text,
247                    human_readable ((uintmax_t) stat_buf->st_uid, hbuf, 1, 1));
248           break;
249 +#ifdef WITH_SELINUX
250 +      case 'Z':               /* SELinux security context */
251 +        {
252 +          security_context_t scontext;
253 +          int rv;
254 +          rv = (*x_getfilecon)(rel_pathname, &scontext);
255 +
256 +          if ( rv < 0 ) {
257 +            (void) fprintf(stderr, "getfileconf(%s): %s",
258 +                           pathname, strerror(errno));
259 +            (void) fflush(stderr);
260 +          }
261 +          else {
262 +             segment->text[segment->text_len] = 's';
263 +             (void) fprintf (fp, segment->text, scontext);
264 +             freecon(scontext);
265 +          }
266 +        }
267 +        break ;
268 +#endif /* WITH_SELINUX */
269         }
270      }
271    return (true);
272 @@ -1220,6 +1250,34 @@
273      }
274    return (pred_type (pathname, &sbuf, pred_ptr));
275  }
276 +  
277 +
278 +#ifdef WITH_SELINUX
279 +
280 +boolean
281 +pred_scontext ( pathname, stat_buf, pred_ptr )
282 +     char *pathname;
283 +     struct stat *stat_buf;
284 +     struct predicate *pred_ptr;
285 +{
286 +  int rv;
287 +  security_context_t scontext;
288 +
289 +  rv = (* x_getfilecon)(rel_pathname, &scontext);
290 +
291 +  if ( rv < 0 ) {
292 +    (void) fprintf(stderr, "getfilecon(%s): %s\n", pathname, strerror(errno));
293 +    (void) fflush(stderr);
294 +    return ( false );
295 +  }
296 +
297 +  rv= (strcmp( scontext,pred_ptr->args.scontext) == 0 );
298 +  freecon(scontext);
299 +  return rv;
300 +}
301 +
302 +#endif /*WITH_SELINUX*/
303 +
304  \f
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
309 @@ -65,6 +65,9 @@
310    last_pred->no_default_print = false;
311    last_pred->need_stat = true;
312    last_pred->args.str = NULL;
313 +#ifdef WITH_SELINUX
314 +  last_pred->args.scontext = NULL;
315 +#endif
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
321 @@ -216,6 +216,11 @@
322  msgid "paths must precede expression"
323  msgstr "¶cie¿ki musz± poprzedzaæ wyra¿enie"
324  
325 +#: find/find.c:217
326 +#, c-format
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"
329 +
330  #. Command line option not recognized
331  #: find/find.c:247
332  #, c-format
333 @@ -335,6 +340,10 @@
334  "      -wholename WZORZEC -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n"
335  "      -used N -user NAZWA -xtype [bcdpfls]"
336  
337 +#: find/parser.c:738
338 +msgid "      -context CONTEXT\n"
339 +msgstr "      -context KONTEKST\n"
340 +
341  #: find/parser.c:723
342  msgid ""
343  "actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n"
This page took 0.045075 seconds and 3 git commands to generate.