]> git.pld-linux.org Git - packages/findutils.git/blob - findutils-selinux.patch
- updated for 4.2.11
[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.11/find/defs.h.orig   2005-01-03 01:06:10.000000000 +0100
15 +++ findutils-4.2.11/find/defs.h        2005-01-09 18:10:03.183117288 +0100
16 @@ -126,6 +126,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 @@ -290,6 +294,9 @@
28      struct dir_id   fileid;    /* samefile */
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 @@ -477,6 +484,10 @@
38    
39    /* Pointer to the function used to stat files. */
40    int (*xstat) (const char *name, struct stat *statbuf);
41 +
42 +#ifdef WITH_SELINUX
43 +  int (*x_getfilecon) ();
44 +#endif /* WITH_SELINUX */
45  };
46  extern struct options options;
47  
48 @@ -511,4 +522,9 @@
49  # define fchdir(fd) (-1)
50  #endif
51  
52 +#ifdef WITH_SELINUX
53 +boolean pred_scontext PARAMS((char *pathname, struct stat *stat_buf, struct predicate *pred_ptr));
54 +extern int (*x_getfilecon) ();
55 +#endif /*WITH_SELINUX*/
56 +
57  #endif
58 --- findutils-4.2.6/find/find.1.orig    2004-11-21 10:52:17.000000000 +0100
59 +++ findutils-4.2.6/find/find.1 2004-11-21 22:52:25.469719184 +0100
60 @@ -396,6 +396,9 @@
61  link to a file of type \fIc\fR; if the \-L option has been given, true
62  if \fIc\fR is `l'.  In other words, for symbolic links, \-xtype checks
63  the type of the file that \-type does not check.
64 +.IP "\-context \fIscontext\fR"
65 +.IP "\--context \fIscontext\fR"
66 +(SELinux only) File has the security context \fIscontext\fR.
67  
68  .SS ACTIONS
69  .IP "\-delete\fR"
70 @@ -633,6 +636,8 @@
71  File's type (like in ls -l), U=unknown type (shouldn't happen)
72  .IP %Y
73  File's type (like %y), plus follow symlinks: L=loop, N=nonexistent
74 +.IP %Z
75 +(SELinux only) file's security context.
76  .PP
77  A `%' character followed by any other character is discarded (but the
78  other character is printed).
79 --- findutils-4.2.11/find/find.c.orig   2005-01-03 01:10:13.000000000 +0100
80 +++ findutils-4.2.11/find/find.c        2005-01-09 18:11:42.808971856 +0100
81 @@ -238,11 +238,17 @@
82      {
83      case SYMLINK_ALWAYS_DEREF:  /* -L */
84        options.xstat = optionl_stat;
85 +#ifdef WITH_SELINUX
86 +      options.x_getfilecon = getfilecon;
87 +#endif /* WITH_SELINUX */
88        options.no_leaf_check = true;
89        break;
90        
91      case SYMLINK_NEVER_DEREF:  /* -P (default) */
92        options.xstat = optionp_stat;
93 +#ifdef WITH_SELINUX
94 +      options.x_getfilecon = lgetfilecon;
95 +#endif /* WITH_SELINUX */
96        /* Can't turn no_leaf_check off because the user might have specified 
97         * -noleaf anyway
98         */
99 @@ -250,6 +256,9 @@
100        
101      case SYMLINK_DEREF_ARGSONLY: /* -H */
102        options.xstat = optionh_stat;
103 +#ifdef WITH_SELINUX
104 +      options.x_getfilecon = getfilecon;
105 +#endif /* WITH_SELINUX */
106        options.no_leaf_check = true;
107      }
108  
109 @@ -272,6 +281,9 @@
110    struct predicate *cur_pred;
111    char *predicate_name;                /* Name of predicate being parsed. */
112    int end_of_leading_options = 0; /* First arg after any -H/-L etc. */
113 +#ifdef WITH_SELINUX
114 +  int is_selinux_enabled_flag;
115 +#endif /* WITH_SELINUX */
116    program_name = argv[0];
117  
118  #ifdef HAVE_SETLOCALE
119 @@ -301,6 +313,9 @@
120    options.ignore_readdir_race = false;
121  
122    state.exit_status = 0;
123 +#ifdef WITH_SELINUX
124 +  is_selinux_enabled_flag = (is_selinux_enabled() > 0);
125 +#endif /* WITH_SELINUX */
126  
127  #if defined(DEBUG_STAT)
128    options.xstat = debug_stat;
129 @@ -382,6 +397,14 @@
130        if (strchr ("-!(),", argv[i][0]) == NULL)
131         usage (_("paths must precede expression"));
132        predicate_name = argv[i];
133 +#ifdef WITH_SELINUX
134 +      if (! is_selinux_enabled_flag) {
135 +       if ((strncmp(predicate_name,"-context",strlen("-context"))==0) ||
136 +           (strncmp(predicate_name,"--context",strlen("--context"))==0)) {
137 +         error (1, 0,_("Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"),predicate_name);
138 +       }
139 +      }
140 +#endif
141        parse_function = find_parser (predicate_name);
142        if (parse_function == NULL)
143         /* Command line option not recognized */
144 --- findutils-4.2.11/find/parser.c.orig 2005-01-03 01:10:27.000000000 +0100
145 +++ findutils-4.2.11/find/parser.c      2005-01-09 18:12:19.498394216 +0100
146 @@ -28,6 +28,10 @@
147  #include "../gnulib/lib/xalloc.h"
148  
149  
150 +#ifdef WITH_SELINUX
151 +#include <selinux/selinux.h>
152 +#endif /*WITH_SELINUX*/
153 +
154  #if ENABLE_NLS
155  # include <libintl.h>
156  # define _(Text) gettext (Text)
157 @@ -129,6 +133,9 @@
158  static boolean parse_warn PARAMS((char *argv[], int *arg_ptr));
159  static boolean parse_xtype PARAMS((char *argv[], int *arg_ptr));
160  static boolean parse_quit PARAMS((char *argv[], int *arg_ptr));
161 +#ifdef WITH_SELINUX
162 +static boolean parse_scontext PARAMS((char *argv[], int *arg_ptr));
163 +#endif /*WITH_SELINUX*/
164  
165  static boolean insert_regex PARAMS((char *argv[], int *arg_ptr, boolean ignore_case));
166  static boolean insert_type PARAMS((char *argv[], int *arg_ptr, boolean (*which_pred )()));
167 @@ -254,6 +261,10 @@
168    {ARG_TEST,               "wholename",             parse_wholename},   /* GNU, replaces -path */
169    {ARG_OPTION,             "xdev",                  parse_xdev},
170    {ARG_TEST,               "xtype",                 parse_xtype},      /* GNU */
171 +#ifdef WITH_SELINUX
172 +  {ARG_TEST,               "context",               parse_scontext},    /* SELINUX */
173 +  {ARG_TEST,               "-context",              parse_scontext},    /* SELINUX */
174 +#endif /*WITH_SELINUX*/
175    {0, 0, 0}
176  };
177  \f
178 @@ -726,6 +737,10 @@
179        -nouser -nogroup -path PATTERN -perm [+-]MODE -regex PATTERN\n\
180        -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
181        -used N -user NAME -xtype [bcdpfls]\n"));
182 +#ifdef WITH_SELINUX
183 +  puts (_("\
184 +      -context CONTEXT\n"));
185 +#endif /*WITH_SELINUX*/
186    puts (_("\
187  actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n\
188        -fls FILE -ok COMMAND ; -print -print0 -printf FORMAT -prune -ls -delete\n\
189 @@ -1542,6 +1557,32 @@
190    return true;
191  }
192  
193 +#ifdef WITH_SELINUX
194 +
195 +static boolean
196 +parse_scontext ( argv, arg_ptr )
197 +     char *argv[];
198 +     int *arg_ptr;
199 +{
200 +  struct predicate *our_pred;
201 +
202 +  if ( (argv == NULL) || (argv[*arg_ptr] == NULL) )
203 +    return( false );
204 +
205 +  our_pred = insert_primary(pred_scontext);
206 +  our_pred->need_stat = false;
207 +#ifdef DEBUG
208 +  our_pred->p_name = find_pred_name (pred_scontext);
209 +#endif /*DEBUG*/
210 +
211 +  our_pred->args.scontext = argv[*arg_ptr];;
212 +
213 +  (*arg_ptr)++;
214 +  return( true );
215 +}
216 +
217 +#endif /*WITH_SELINUX*/
218 +
219  static boolean
220  parse_xtype (char **argv, int *arg_ptr)
221  {
222 @@ -1702,7 +1743,11 @@
223           if (*scan2 == '.')
224             for (scan2++; ISDIGIT (*scan2); scan2++)
225               /* Do nothing. */ ;
226 +#ifdef WITH_SELINUX
227 +         if (strchr ("abcdDfFgGhHiklmMnpPstuUyYZ", *scan2))
228 +#else  /* WITH_SELINUX */
229           if (strchr ("abcdDfFgGhHiklmMnpPstuUyY", *scan2))
230 +#endif /* WITH_SELINUX */
231             {
232               segmentp = make_segment (segmentp, format, scan2 - format,
233                                        (int) *scan2);
234 --- findutils-4.2.11/find/pred.c.orig   2005-01-03 01:15:48.000000000 +0100
235 +++ findutils-4.2.11/find/pred.c        2005-01-09 18:22:25.204312920 +0100
236 @@ -30,6 +30,14 @@
237  #include "filemode.h"
238  #include "wait.h"
239  
240 +#ifdef WITH_SELINUX
241 +#include <selinux/selinux.h>
242 +#endif /*WITH_SELINUX*/
243 +
244 +#ifndef FNM_CASEFOLD
245 +#define FNM_CASEFOLD (1<<4)
246 +#endif  /*FNM_CASEFOLD*/
247 +
248  #if ENABLE_NLS
249  # include <libintl.h>
250  # define _(Text) gettext (Text)
251 @@ -73,7 +81,6 @@
252  
253  extern int yesno ();
254  
255 -
256  /* Get or fake the disk device blocksize.
257     Usually defined by sys/param.h (if at all).  */
258  #ifndef DEV_BSIZE
259 @@ -202,6 +209,9 @@
260    {pred_used, "used    "},
261    {pred_user, "user    "},
262    {pred_xtype, "xtype   "},
263 +#ifdef WITH_SELINUX
264 +  {pred_scontext, "context"},
265 +#endif /*WITH_SELINUX*/
266    {0, "none    "}
267  };
268  
269 @@ -813,6 +823,26 @@
270  
271           }
272           break;
273 +#ifdef WITH_SELINUX
274 +      case 'Z':               /* SELinux security context */
275 +        {
276 +          security_context_t scontext;
277 +          int rv;
278 +          rv = (*options.x_getfilecon)(state.rel_pathname, &scontext);
279 +
280 +          if ( rv < 0 ) {
281 +            (void) fprintf(stderr, "getfileconf(%s): %s",
282 +                           pathname, strerror(errno));
283 +            (void) fflush(stderr);
284 +          }
285 +          else {
286 +             segment->text[segment->text_len] = 's';
287 +             (void) fprintf (fp, segment->text, scontext);
288 +             freecon(scontext);
289 +          }
290 +        }
291 +        break ;
292 +#endif /* WITH_SELINUX */
293         }
294      }
295    return (true);
296 @@ -1366,6 +1396,31 @@
297     */
298    return (pred_type (pathname, &sbuf, pred_ptr));
299  }
300 +  
301 +
302 +#ifdef WITH_SELINUX
303 +
304 +boolean
305 +pred_scontext (char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
306 +{
307 +  int rv;
308 +  security_context_t scontext;
309 +
310 +  rv = (*options.x_getfilecon)(state.rel_pathname, &scontext);
311 +
312 +  if ( rv < 0 ) {
313 +    (void) fprintf(stderr, "getfilecon(%s): %s\n", pathname, strerror(errno));
314 +    (void) fflush(stderr);
315 +    return ( false );
316 +  }
317 +
318 +  rv= (strcmp(scontext, pred_ptr->args.scontext) == 0);
319 +  freecon(scontext);
320 +  return rv;
321 +}
322 +
323 +#endif /*WITH_SELINUX*/
324 +
325  \f
326  /*  1) fork to get a child; parent remembers the child pid
327      2) child execs the command requested
328 --- findutils-4.1.7/find/util.c.selinux 2001-05-20 16:39:37.000000000 -0400
329 +++ findutils-4.1.7/find/util.c 2003-10-10 13:19:10.869534272 -0400
330 @@ -65,6 +65,9 @@
331    last_pred->no_default_print = false;
332    last_pred->need_stat = true;
333    last_pred->args.str = NULL;
334 +#ifdef WITH_SELINUX
335 +  last_pred->args.scontext = NULL;
336 +#endif
337    last_pred->pred_next = NULL;
338    last_pred->pred_left = NULL;
339    last_pred->pred_right = NULL;
340 --- findutils-4.2.8/po/pl.po.orig       2004-11-26 00:55:08.041685696 +0100
341 +++ findutils-4.2.8/po/pl.po    2004-11-26 01:02:56.090531456 +0100
342 @@ -216,6 +216,11 @@
343  msgid "paths must precede expression"
344  msgstr "¶cie¿ki musz± poprzedzaæ wyra¿enie"
345  
346 +#: find/find.c:217
347 +#, c-format
348 +msgid "Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"
349 +msgstr "B³±d: b³êdne wyra¿enie %s: j±dro nie ma w³±czonej obs³ugi SELinuksa.\n"
350 +
351  #. Command line option not recognized
352  #: find/find.c:427
353  #, c-format
354 @@ -375,6 +380,10 @@
355  "      -wholename WZORZEC -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n"
356  "      -used N -user NAZWA -xtype [bcdpfls]"
357  
358 +#: find/parser.c:738
359 +msgid "      -context CONTEXT\n"
360 +msgstr "      -context KONTEKST\n"
361 +
362  #: find/parser.c:725
363  msgid ""
364  "actions: -exec COMMAND ; -fprint FILE -fprint0 FILE -fprintf FILE FORMAT\n"
This page took 0.101148 seconds and 3 git commands to generate.