]> git.pld-linux.org Git - packages/findutils.git/blob - findutils-selinux.patch
- unify ftp.gnu.org urls
[packages/findutils.git] / findutils-selinux.patch
1 --- findutils-4.4.0/find/Makefile.am.orig       2007-07-22 14:29:31.000000000 +0200
2 +++ findutils-4.4.0/find/Makefile.am    2008-03-16 01:19:36.539333465 +0100
3 @@ -25,8 +25,9 @@
4  endif
5  
6  EXTRA_DIST = defs.h $(man_MANS)
7 +DEFS = @DEFS@ -DWITH_SELINUX
8  INCLUDES = -I../gnulib/lib -I$(top_srcdir)/lib -I$(top_srcdir)/gnulib/lib -I../intl -DLOCALEDIR=\"$(localedir)\"
9 -LDADD = ./libfindtools.a ../lib/libfind.a ../gnulib/lib/libgnulib.a @INTLLIBS@ @LIB_CLOCK_GETTIME@ @FINDLIBS@
10 +LDADD = ./libfindtools.a ../lib/libfind.a ../gnulib/lib/libgnulib.a @INTLLIBS@ @LIB_CLOCK_GETTIME@ @FINDLIBS@ -lselinux
11  man_MANS = find.1
12  SUBDIRS = . testsuite
13  
14 --- findutils-4.4.0/find/defs.h.orig    2008-03-10 10:37:21.000000000 +0100
15 +++ findutils-4.4.0/find/defs.h 2008-03-16 01:22:53.718566717 +0100
16 @@ -49,6 +49,9 @@
17  #include <stdint.h>            /* for uintmax_t */
18  #include <sys/stat.h> /* S_ISUID etc. */
19  
20 +#ifdef WITH_SELINUX
21 +#include <selinux/selinux.h>
22 +#endif /*WITH_SELINUX*/
23  
24  
25  #ifndef CHAR_BIT
26 @@ -314,6 +317,9 @@
27      struct perm_val perm;      /* perm */
28      struct samefile_file_id samefileid; /* samefile */
29      mode_t type;               /* type */
30 +#ifdef WITH_SELINUX
31 +    security_context_t scontext; /* scontext */
32 +#endif /*WITH_SELINUX*/
33      struct format_val printf_vec; /* printf fprintf fprint ls fls print0 fprint0 print */
34    } args;
35  
36 @@ -589,6 +595,10 @@
37    /* Pointer to the function used to stat files. */
38    int (*xstat) (const char *name, struct stat *statbuf);
39  
40 +#ifdef WITH_SELINUX
41 +  int (*x_getfilecon) ();
42 +#endif /* WITH_SELINUX */
43 +
44  
45    /* Indicate if we can implement safely_chdir() using the O_NOFOLLOW 
46     * flag to open(2). 
47 @@ -657,4 +667,9 @@
48  extern char *program_name;
49  
50  
51 +#ifdef WITH_SELINUX
52 +PREDICATEFUNCTION pred_scontext;
53 +extern int (*x_getfilecon) ();
54 +#endif /*WITH_SELINUX*/
55 +
56  #endif
57 --- findutils-4.4.0/find/find.1.orig    2007-12-19 20:53:14.000000000 +0100
58 +++ findutils-4.4.0/find/find.1 2008-03-16 01:24:14.939206112 +0100
59 @@ -935,6 +935,10 @@
60  .B \-type
61  does not check.
62  
63 +.IP "\-context \fIscontext\fR"
64 +.IP "\-\-context \fIscontext\fR"
65 +(SELinux only) File has the security context \fIscontext\fR.
66 +
67  .SS ACTIONS
68  .IP "\-delete\fR"
69  Delete files; true if removal succeeded.  If the removal failed, an
70 @@ -1340,6 +1344,8 @@
71  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 (don't rely on this, as further format
79 --- findutils-4.4.0/find/parser.c.orig  2008-03-10 10:37:21.000000000 +0100
80 +++ findutils-4.4.0/find/parser.c       2008-03-17 20:23:52.047453360 +0100
81 @@ -53,6 +53,10 @@
82  #include <unistd.h> 
83  #include <sys/stat.h>
84  
85 +#ifdef WITH_SELINUX
86 +#include <selinux/selinux.h>
87 +#endif /*WITH_SELINUX*/
88 +
89  #if ENABLE_NLS
90  # include <libintl.h>
91  # define _(Text) gettext (Text)
92 @@ -156,6 +160,9 @@
93  static boolean parse_warn          PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
94  static boolean parse_xtype         PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
95  static boolean parse_quit          PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
96 +#ifdef WITH_SELINUX
97 +static boolean parse_scontext      PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
98 +#endif /*WITH_SELINUX*/
99  
100  boolean parse_print             PARAMS((const struct parser_table*, char *argv[], int *arg_ptr));
101  
102 @@ -322,6 +329,10 @@
103    {ARG_TEST,       "writable",               parse_accesscheck, pred_writable}, /* GNU, 4.3.0+ */
104    PARSE_OPTION     ("xdev",                  xdev), /* POSIX */
105    PARSE_TEST       ("xtype",                 xtype),        /* GNU */
106 +#ifdef WITH_SELINUX
107 +  PARSE_TEST       ("context",               scontext),      /* SELINUX */
108 +  PARSE_TEST       ("-context",              scontext),      /* SELINUX */
109 +#endif /*WITH_SELINUX*/
110  #ifdef UNIMPLEMENTED_UNIX
111    /* It's pretty ugly for find to know about archive formats.
112       Plus what it could do with cpio archives is very limited.
113 @@ -451,11 +462,17 @@
114         {
115         case SYMLINK_ALWAYS_DEREF:  /* -L */
116           options.xstat = optionl_stat;
117 +#ifdef WITH_SELINUX
118 +         options.x_getfilecon = getfilecon;
119 +#endif /* WITH_SELINUX */
120           options.no_leaf_check = true;
121           break;
122           
123         case SYMLINK_NEVER_DEREF:       /* -P (default) */
124           options.xstat = optionp_stat;
125 +#ifdef WITH_SELINUX
126 +         options.x_getfilecon = lgetfilecon;
127 +#endif /* WITH_SELINUX */
128           /* Can't turn no_leaf_check off because the user might have specified 
129            * -noleaf anyway
130            */
131 @@ -463,6 +480,9 @@
132           
133         case SYMLINK_DEREF_ARGSONLY: /* -H */
134           options.xstat = optionh_stat;
135 +#ifdef WITH_SELINUX
136 +         options.x_getfilecon = getfilecon;
137 +#endif /* WITH_SELINUX */
138           options.no_leaf_check = true;
139         }
140      }
141 @@ -1129,6 +1149,10 @@
142        -readable -writable -executable\n\
143        -wholename PATTERN -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n\
144        -used N -user NAME -xtype [bcdpfls]\n"));
145 +#ifdef WITH_SELINUX
146 +  puts (_("\
147 +      -context CONTEXT\n"));
148 +#endif /*WITH_SELINUX*/
149    puts (_("\
150  actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print \n\
151        -fprint0 FILE -fprint FILE -ls -fls FILE -prune -quit\n\
152 @@ -2392,6 +2416,30 @@
153      }
154  }
155  
156 +#ifdef WITH_SELINUX
157 +
158 +static boolean
159 +parse_scontext (const struct parser_table *entry, char **argv, int *arg_ptr)
160 +{
161 +  struct predicate *our_pred;
162 +
163 +  if ( (argv == NULL) || (argv[*arg_ptr] == NULL) )
164 +    return( false );
165 +
166 +  our_pred = insert_primary_withpred (entry, pred_scontext);
167 +  our_pred->need_stat = our_pred->need_type = false;
168 +#ifdef DEBUG
169 +  our_pred->p_name = find_pred_name (pred_scontext);
170 +#endif /*DEBUG*/
171 +
172 +  our_pred->args.scontext = argv[*arg_ptr];;
173 +
174 +  (*arg_ptr)++;
175 +  return( true );
176 +}
177 +
178 +#endif /*WITH_SELINUX*/
179 +
180  static boolean
181  parse_used (const struct parser_table* entry, char **argv, int *arg_ptr)
182  {
183 @@ -2777,7 +2825,11 @@
184           if (*scan2 == '.')
185             for (scan2++; ISDIGIT (*scan2); scan2++)
186               /* Do nothing. */ ;
187 +#ifdef WITH_SELINUX
188 +         if (strchr ("abcdDfFgGhHiklmMnpPsStuUyYZ", *scan2))
189 +#else  /* WITH_SELINUX */
190           if (strchr ("abcdDfFgGhHiklmMnpPsStuUyY", *scan2))
191 +#endif /* WITH_SELINUX */
192             {
193               segmentp = make_segment (segmentp, format, scan2 - format,
194                                        KIND_FORMAT, *scan2, 0,
195 --- findutils-4.2.11/find/pred.c.orig   2005-01-03 01:15:48.000000000 +0100
196 +++ findutils-4.2.11/find/pred.c        2005-01-09 18:22:25.204312920 +0100
197 @@ -30,6 +30,14 @@
198  #include "filemode.h"
199  #include "wait.h"
200  
201 +#ifdef WITH_SELINUX
202 +#include <selinux/selinux.h>
203 +#endif /*WITH_SELINUX*/
204 +
205 +#ifndef FNM_CASEFOLD
206 +#define FNM_CASEFOLD (1<<4)
207 +#endif  /*FNM_CASEFOLD*/
208 +
209  #if ENABLE_NLS
210  # include <libintl.h>
211  # define _(Text) gettext (Text)
212 @@ -73,7 +81,6 @@
213  
214  extern int yesno ();
215  
216 -
217  /* Get or fake the disk device blocksize.
218     Usually defined by sys/param.h (if at all).  */
219  #ifndef DEV_BSIZE
220 @@ -202,6 +209,9 @@
221    {pred_used, "used    "},
222    {pred_user, "user    "},
223    {pred_xtype, "xtype   "},
224 +#ifdef WITH_SELINUX
225 +  {pred_scontext, "context"},
226 +#endif /*WITH_SELINUX*/
227    {0, "none    "}
228  };
229  
230 @@ -813,6 +823,26 @@
231  
232           }
233           break;
234 +#ifdef WITH_SELINUX
235 +      case 'Z':               /* SELinux security context */
236 +        {
237 +          security_context_t scontext;
238 +          int rv;
239 +          rv = (*options.x_getfilecon)(state.rel_pathname, &scontext);
240 +
241 +          if ( rv < 0 ) {
242 +            (void) fprintf(stderr, "getfileconf(%s): %s",
243 +                           pathname, strerror(errno));
244 +            (void) fflush(stderr);
245 +          }
246 +          else {
247 +             segment->text[segment->text_len] = 's';
248 +             checked_fprintf (dest, segment->text, scontext);
249 +             freecon(scontext);
250 +          }
251 +        }
252 +        break ;
253 +#endif /* WITH_SELINUX */
254         }
255      }
256    return (true);
257 @@ -1366,6 +1396,31 @@
258     */
259    return (pred_type (pathname, &sbuf, pred_ptr));
260  }
261 +  
262 +
263 +#ifdef WITH_SELINUX
264 +
265 +boolean
266 +pred_scontext (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
267 +{
268 +  int rv;
269 +  security_context_t scontext;
270 +
271 +  rv = (*options.x_getfilecon)(state.rel_pathname, &scontext);
272 +
273 +  if ( rv < 0 ) {
274 +    (void) fprintf(stderr, "getfilecon(%s): %s\n", pathname, strerror(errno));
275 +    (void) fflush(stderr);
276 +    return ( false );
277 +  }
278 +
279 +  rv= (strcmp(scontext, pred_ptr->args.scontext) == 0);
280 +  freecon(scontext);
281 +  return rv;
282 +}
283 +
284 +#endif /*WITH_SELINUX*/
285 +
286  \f
287  /*  1) fork to get a child; parent remembers the child pid
288      2) child execs the command requested
289 --- findutils-4.4.0/find/tree.c.orig    2007-12-20 22:40:35.000000000 +0100
290 +++ findutils-4.4.0/find/tree.c 2008-03-17 20:21:28.427267235 +0100
291 @@ -1194,6 +1194,9 @@
292    struct predicate *cur_pred;
293    const struct parser_table *entry_close, *entry_print, *entry_open;
294    int i, oldi;
295 +#ifdef WITH_SELINUX
296 +  int is_selinux_enabled_flag;
297 +#endif /* WITH_SELINUX */
298  
299    predicates = NULL;
300    
301 @@ -1230,6 +1233,14 @@
302         }
303  
304        predicate_name = argv[i];
305 +#ifdef WITH_SELINUX
306 +      if (! is_selinux_enabled_flag) {
307 +       if ((strncmp(predicate_name,"-context",strlen("-context"))==0) ||
308 +           (strncmp(predicate_name,"--context",strlen("--context"))==0)) {
309 +         error (1, 0,_("Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"),predicate_name);
310 +       }
311 +      }
312 +#endif
313        parse_entry = find_parser (predicate_name);
314        if (parse_entry == NULL)
315         {
316 --- findutils-4.4.0/find/util.c.orig    2008-03-10 10:37:22.000000000 +0100
317 +++ findutils-4.4.0/find/util.c 2008-03-16 01:28:33.177920622 +0100
318 @@ -97,6 +97,9 @@
319    new_pred->pred_func = pred_func;
320    new_pred->p_name = entry->parser_name;
321    new_pred->args.str = NULL;
322 +#ifdef WITH_SELINUX
323 +  new_pred->args.scontext = NULL;
324 +#endif
325    new_pred->p_type = PRIMARY_TYPE;
326    new_pred->p_prec = NO_PREC;
327    return new_pred;
328 --- findutils-4.4.0/po/pl.po.orig       2008-03-15 12:43:32.000000000 +0100
329 +++ findutils-4.4.0/po/pl.po    2008-03-17 20:28:05.717905863 +0100
330 @@ -453,6 +453,10 @@
331  "      -wholename WZORZEC -size N[bcwkMG] -true -type [bcdpflsD] -uid N\n"
332  "      -used N -user NAZWA -xtype [bcdpfls]\n"
333  
334 +#: find/parser.c:1154
335 +msgid "      -context CONTEXT\n"
336 +msgstr "      -context KONTEKST\n"
337 +
338  #: find/parser.c:1132
339  msgid ""
340  "actions: -delete -print0 -printf FORMAT -fprintf FILE FORMAT -print \n"
341 @@ -755,6 +759,11 @@
342  msgid "unknown predicate `%s'"
343  msgstr "nieznane wyra¿enie `%s'"
344  
345 +#: find/tree.c:1241
346 +#, c-format
347 +msgid "Error: invalid predicate %s: the kernel is not SELinux-enabled.\n"
348 +msgstr "B³±d: b³êdne wyra¿enie %s: j±dro nie ma w³±czonej obs³ugi SELinuksa.\n"
349 +
350  #: find/tree.c:1257
351  #, c-format
352  msgid "invalid predicate `%s'"
This page took 0.051188 seconds and 3 git commands to generate.