summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAws Ismail <aws.ismail@windriver.com>2012-08-10 14:32:30 -0400
committerMark Hatle <mark.hatle@windriver.com>2012-08-10 15:08:22 -0500
commitb4b777458fa279831374aee049bacb7d117b9832 (patch)
tree4cb2bb70097be3f1722ee126a3bd0ece68c9d0bf
parent5e1ce09acf1ad182321a6d532b2ed42f21788e5a (diff)
downloadmeta-selinux-b4b777458fa279831374aee049bacb7d117b9832.tar.gz
Fetch selinux-at module from gnulib repo
[ CQID: WIND00365962 ] Rather than following the approach in findutils-with-selinux-gnulib.patch, the import-gnulib configuration was modified to enable fetching the latest updates related to selinux support. Specifically, selinux-at module is now in fetched in gnulib in order for it be used by findutils if selinux is enabled. Signed-off-by: Aws Ismail <aws.ismail@windriver.com>
-rw-r--r--recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-gnulib.patch1294
-rw-r--r--recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-supplemental.patch32
-rw-r--r--recipes-extended/findutils/findutils_4.4.2.bbappend11
3 files changed, 41 insertions, 1296 deletions
diff --git a/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-gnulib.patch b/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-gnulib.patch
deleted file mode 100644
index 866ecdc..0000000
--- a/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-gnulib.patch
+++ /dev/null
@@ -1,1294 +0,0 @@
1Subject: [PATCH] findutils: support selinux and gnulib
2
3Upstream-Status: Inappropriate [configuration]
4
5This is modified from a F13 SRPM patch.
6
7Once the selinux-at module appears on the list within import-gnulib.config,
8this patch is no longer needed.
9
10Signed-off-by: Xin Ouyang <Xin.Ouyang@windriver.com>
11---
12 aclocal.m4 | 2 +
13 gnulib/lib/Makefile.am | 44 +++++++
14 gnulib/lib/at-func.c | 98 ++++++++++----
15 gnulib/lib/getfilecon.c | 87 ++++++++++++
16 gnulib/lib/openat.c | 285 ++++++++++++++++++++--------------------
17 gnulib/lib/openat.h | 88 ++++++-------
18 gnulib/lib/se-context.in.h | 34 +++++
19 gnulib/lib/se-selinux.in.h | 103 +++++++++++++++
20 gnulib/lib/selinux-at.c | 72 ++++++++++
21 gnulib/lib/selinux-at.h | 52 ++++++++
22 gnulib/m4/gnulib-comp.m4 | 12 ++
23 gnulib/m4/include_next.m4 | 29 +++-
24 gnulib/m4/selinux-context-h.m4 | 16 +++
25 gnulib/m4/selinux-selinux-h.m4 | 57 ++++++++
26 14 files changed, 753 insertions(+), 226 deletions(-)
27 create mode 100644 gnulib/lib/getfilecon.c
28 create mode 100644 gnulib/lib/se-context.in.h
29 create mode 100644 gnulib/lib/se-selinux.in.h
30 create mode 100644 gnulib/lib/selinux-at.c
31 create mode 100644 gnulib/lib/selinux-at.h
32 create mode 100644 gnulib/m4/selinux-context-h.m4
33 create mode 100644 gnulib/m4/selinux-selinux-h.m4
34
35diff --git a/aclocal.m4 b/aclocal.m4
36index 1f97dda..61ad660 100644
37--- a/aclocal.m4
38+++ b/aclocal.m4
39@@ -1039,6 +1039,8 @@ m4_include([gnulib/m4/rpmatch.m4])
40 m4_include([gnulib/m4/same.m4])
41 m4_include([gnulib/m4/save-cwd.m4])
42 m4_include([gnulib/m4/savedir.m4])
43+m4_include([gnulib/m4/selinux-context-h.m4])
44+m4_include([gnulib/m4/selinux-selinux-h.m4])
45 m4_include([gnulib/m4/setenv.m4])
46 m4_include([gnulib/m4/ssize_t.m4])
47 m4_include([gnulib/m4/st_dm_mode.m4])
48diff --git a/gnulib/lib/Makefile.am b/gnulib/lib/Makefile.am
49index 59ed5f2..7f105a9 100644
50--- a/gnulib/lib/Makefile.am
51+++ b/gnulib/lib/Makefile.am
52@@ -1007,6 +1007,50 @@ EXTRA_libgnulib_a_SOURCES += savedir.c
53
54 ## end gnulib module savedir
55
56+## begin gnulib module selinux-at
57+
58+
59+EXTRA_DIST += selinux-at.c selinux-at.h
60+
61+EXTRA_libgnulib_a_SOURCES += selinux-at.c
62+
63+## end gnulib module selinux-at
64+
65+## begin gnulib module selinux-h
66+
67+libgnulib_a_SOURCES += se-context.in.h se-selinux.in.h
68+
69+BUILT_SOURCES += selinux/selinux.h
70+selinux/selinux.h: se-selinux.in.h
71+ $(AM_V_at)$(MKDIR_P) selinux
72+ $(AM_V_GEN)rm -f $@-t $@ && \
73+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
74+ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
75+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
76+ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
77+ -e 's|@''NEXT_SELINUX_SELINUX_H''@|$(NEXT_SELINUX_SELINUX_H)|g' \
78+ < $(srcdir)/se-selinux.in.h; \
79+ } > $@-t && \
80+ chmod a-x $@-t && \
81+ mv $@-t $@
82+MOSTLYCLEANFILES += selinux/selinux.h selinux/selinux.h-t
83+
84+BUILT_SOURCES += $(SELINUX_CONTEXT_H)
85+selinux/context.h: se-context.in.h
86+ $(AM_V_at)$(MKDIR_P) selinux
87+ $(AM_V_GEN)rm -f $@-t $@ && \
88+ cp $(srcdir)/se-context.in.h $@-t && \
89+ chmod a-x $@-t && \
90+ mv $@-t $@
91+MOSTLYCLEANFILES += selinux/context.h selinux/context.h-t
92+MOSTLYCLEANDIRS += selinux
93+
94+EXTRA_DIST += getfilecon.c
95+
96+EXTRA_libgnulib_a_SOURCES += getfilecon.c
97+
98+## end gnulib module selinux-h
99+
100 ## begin gnulib module setenv
101
102
103diff --git a/gnulib/lib/at-func.c b/gnulib/lib/at-func.c
104index c7963fe..73be401 100644
105--- a/gnulib/lib/at-func.c
106+++ b/gnulib/lib/at-func.c
107@@ -1,5 +1,5 @@
108 /* Define an at-style functions like fstatat, unlinkat, fchownat, etc.
109- Copyright (C) 2006 Free Software Foundation, Inc.
110+ Copyright (C) 2006, 2009 Free Software Foundation, Inc.
111
112 This program is free software: you can redistribute it and/or modify
113 it under the terms of the GNU General Public License as published by
114@@ -16,62 +16,106 @@
115
116 /* written by Jim Meyering */
117
118-#define CALL_FUNC(F) \
119- (AT_FUNC_USE_F1_COND \
120+#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
121+#include "openat.h"
122+#include "openat-priv.h"
123+#include "save-cwd.h"
124+
125+#ifdef AT_FUNC_USE_F1_COND
126+# define CALL_FUNC(F) \
127+ (flag == AT_FUNC_USE_F1_COND \
128 ? AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS) \
129 : AT_FUNC_F2 (F AT_FUNC_POST_FILE_ARGS))
130+# define VALIDATE_FLAG(F) \
131+ if (flag & ~AT_FUNC_USE_F1_COND) \
132+ { \
133+ errno = EINVAL; \
134+ return FUNC_FAIL; \
135+ }
136+#else
137+# define CALL_FUNC(F) (AT_FUNC_F1 (F AT_FUNC_POST_FILE_ARGS))
138+# define VALIDATE_FLAG(F) /* empty */
139+#endif
140+
141+#ifdef AT_FUNC_RESULT
142+# define FUNC_RESULT AT_FUNC_RESULT
143+#else
144+# define FUNC_RESULT int
145+#endif
146+
147+#ifdef AT_FUNC_FAIL
148+# define FUNC_FAIL AT_FUNC_FAIL
149+#else
150+# define FUNC_FAIL -1
151+#endif
152
153-/* Call AT_FUNC_F1 or AT_FUNC_F2 (testing AT_FUNC_USE_F1_COND to
154- determine which) to operate on FILE, which is in the directory
155- open on descriptor FD. If possible, do it without changing the
156+/* Call AT_FUNC_F1 to operate on FILE, which is in the directory
157+ open on descriptor FD. If AT_FUNC_USE_F1_COND is defined to a value,
158+ AT_FUNC_POST_FILE_PARAM_DECLS must inlude a parameter named flag;
159+ call AT_FUNC_F2 if FLAG is 0 or fail if FLAG contains more bits than
160+ AT_FUNC_USE_F1_COND. Return int and fail with -1 unless AT_FUNC_RESULT
161+ or AT_FUNC_FAIL are defined. If possible, do it without changing the
162 working directory. Otherwise, resort to using save_cwd/fchdir,
163 then AT_FUNC_F?/restore_cwd. If either the save_cwd or the restore_cwd
164 fails, then give a diagnostic and exit nonzero. */
165-int
166+FUNC_RESULT
167 AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
168 {
169+ /* Be careful to choose names unlikely to conflict with
170+ AT_FUNC_POST_FILE_PARAM_DECLS. */
171 struct saved_cwd saved_cwd;
172 int saved_errno;
173- int err;
174+ FUNC_RESULT err;
175+
176+ VALIDATE_FLAG (flag);
177
178 if (fd == AT_FDCWD || IS_ABSOLUTE_FILE_NAME (file))
179 return CALL_FUNC (file);
180
181 {
182- char buf[OPENAT_BUFFER_SIZE];
183- char *proc_file = openat_proc_name (buf, fd, file);
184+ char proc_buf[OPENAT_BUFFER_SIZE];
185+ char *proc_file = openat_proc_name (proc_buf, fd, file);
186 if (proc_file)
187 {
188- int proc_result = CALL_FUNC (proc_file);
189- int proc_errno = errno;
190- if (proc_file != buf)
191- free (proc_file);
192- /* If the syscall succeeds, or if it fails with an unexpected
193- errno value, then return right away. Otherwise, fall through
194- and resort to using save_cwd/restore_cwd. */
195- if (0 <= proc_result)
196- return proc_result;
197- if (! EXPECTED_ERRNO (proc_errno))
198- {
199- errno = proc_errno;
200- return proc_result;
201- }
202+ FUNC_RESULT proc_result = CALL_FUNC (proc_file);
203+ int proc_errno = errno;
204+ if (proc_file != proc_buf)
205+ free (proc_file);
206+ /* If the syscall succeeds, or if it fails with an unexpected
207+ errno value, then return right away. Otherwise, fall through
208+ and resort to using save_cwd/restore_cwd. */
209+ if (FUNC_FAIL != proc_result)
210+ return proc_result;
211+ if (! EXPECTED_ERRNO (proc_errno))
212+ {
213+ errno = proc_errno;
214+ return proc_result;
215+ }
216 }
217 }
218
219 if (save_cwd (&saved_cwd) != 0)
220 openat_save_fail (errno);
221+ if (0 <= fd && fd == saved_cwd.desc)
222+ {
223+ /* If saving the working directory collides with the user's
224+ requested fd, then the user's fd must have been closed to
225+ begin with. */
226+ free_cwd (&saved_cwd);
227+ errno = EBADF;
228+ return FUNC_FAIL;
229+ }
230
231 if (fchdir (fd) != 0)
232 {
233 saved_errno = errno;
234 free_cwd (&saved_cwd);
235 errno = saved_errno;
236- return -1;
237+ return FUNC_FAIL;
238 }
239
240 err = CALL_FUNC (file);
241- saved_errno = (err < 0 ? errno : 0);
242+ saved_errno = (err == FUNC_FAIL ? errno : 0);
243
244 if (restore_cwd (&saved_cwd) != 0)
245 openat_restore_fail (errno);
246@@ -83,3 +127,5 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS)
247 return err;
248 }
249 #undef CALL_FUNC
250+#undef FUNC_RESULT
251+#undef FUNC_FAIL
252diff --git a/gnulib/lib/getfilecon.c b/gnulib/lib/getfilecon.c
253new file mode 100644
254index 0000000..d712307
255--- /dev/null
256+++ b/gnulib/lib/getfilecon.c
257@@ -0,0 +1,87 @@
258+/* wrap getfilecon, lgetfilecon, and fgetfilecon
259+ Copyright (C) 2009 Free Software Foundation, Inc.
260+
261+ This program is free software; you can redistribute it and/or modify
262+ it under the terms of the GNU General Public License as published by
263+ the Free Software Foundation; either version 3, or (at your option)
264+ any later version.
265+
266+ This program is distributed in the hope that it will be useful,
267+ but WITHOUT ANY WARRANTY; without even the implied warranty of
268+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
269+ GNU General Public License for more details.
270+
271+ You should have received a copy of the GNU General Public License
272+ along with this program; if not, write to the Free Software Foundation,
273+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
274+
275+/* written by Jim Meyering */
276+
277+#include <config.h>
278+
279+#include <selinux/selinux.h>
280+
281+#include <sys/types.h>
282+#include <errno.h>
283+#include <string.h>
284+
285+/* FIXME: remove this once there is an errno-gnu module
286+ that guarantees the definition of ENODATA. */
287+#ifndef ENODATA
288+# define ENODATA ENOTSUP
289+#endif
290+
291+#undef getfilecon
292+#undef lgetfilecon
293+#undef fgetfilecon
294+int getfilecon (char const *file, security_context_t *con);
295+int lgetfilecon (char const *file, security_context_t *con);
296+int fgetfilecon (int fd, security_context_t *con);
297+
298+/* getfilecon, lgetfilecon, and fgetfilecon can all misbehave, be it
299+ via an old version of libselinux where these would return 0 and set the
300+ result context to NULL, or via a modern kernel+lib operating on a file
301+ from a disk whose attributes were set by a kernel from around 2006.
302+ In that latter case, the functions return a length of 10 for the
303+ "unlabeled" context. Map both failures to a return value of -1, and
304+ set errno to ENOTSUP in the first case, and ENODATA in the latter. */
305+
306+static inline int
307+map_to_failure (int ret, security_context_t *con)
308+{
309+ if (ret == 0)
310+ {
311+ errno = ENOTSUP;
312+ return -1;
313+ }
314+
315+ if (ret == 10 && strcmp (*con, "unlabeled") == 0)
316+ {
317+ freecon (*con);
318+ errno = ENODATA;
319+ return -1;
320+ }
321+
322+ return ret;
323+}
324+
325+int
326+rpl_getfilecon (char const *file, security_context_t *con)
327+{
328+ int ret = getfilecon (file, con);
329+ return map_to_failure (ret, con);
330+}
331+
332+int
333+rpl_lgetfilecon (char const *file, security_context_t *con)
334+{
335+ int ret = lgetfilecon (file, con);
336+ return map_to_failure (ret, con);
337+}
338+
339+int
340+rpl_fgetfilecon (int fd, security_context_t *con)
341+{
342+ int ret = fgetfilecon (fd, con);
343+ return map_to_failure (ret, con);
344+}
345diff --git a/gnulib/lib/openat.c b/gnulib/lib/openat.c
346index 73f24b0..2b15bb5 100644
347--- a/gnulib/lib/openat.c
348+++ b/gnulib/lib/openat.c
349@@ -1,5 +1,5 @@
350 /* provide a replacement openat function
351- Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
352+ Copyright (C) 2004-2009 Free Software Foundation, Inc.
353
354 This program is free software: you can redistribute it and/or modify
355 it under the terms of the GNU General Public License as published by
356@@ -22,13 +22,108 @@
357
358 #include <stdarg.h>
359 #include <stddef.h>
360+#include <string.h>
361+#include <sys/stat.h>
362
363 #include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
364-#include "fcntl--.h"
365-#include "lstat.h"
366 #include "openat-priv.h"
367 #include "save-cwd.h"
368
369+#if HAVE_OPENAT
370+
371+# undef openat
372+
373+/* Like openat, but work around Solaris 9 bugs with trailing slash. */
374+int
375+rpl_openat (int dfd, char const *filename, int flags, ...)
376+{
377+ mode_t mode;
378+ int fd;
379+
380+ mode = 0;
381+ if (flags & O_CREAT)
382+ {
383+ va_list arg;
384+ va_start (arg, flags);
385+
386+ /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
387+ creates crashing code when 'mode_t' is smaller than 'int'. */
388+ mode = va_arg (arg, PROMOTED_MODE_T);
389+
390+ va_end (arg);
391+ }
392+
393+#if OPEN_TRAILING_SLASH_BUG
394+ /* If the filename ends in a slash and one of O_CREAT, O_WRONLY, O_RDWR
395+ is specified, then fail.
396+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
397+ says that
398+ "A pathname that contains at least one non-slash character and that
399+ ends with one or more trailing slashes shall be resolved as if a
400+ single dot character ( '.' ) were appended to the pathname."
401+ and
402+ "The special filename dot shall refer to the directory specified by
403+ its predecessor."
404+ If the named file already exists as a directory, then
405+ - if O_CREAT is specified, open() must fail because of the semantics
406+ of O_CREAT,
407+ - if O_WRONLY or O_RDWR is specified, open() must fail because POSIX
408+ <http://www.opengroup.org/susv3/functions/open.html> says that it
409+ fails with errno = EISDIR in this case.
410+ If the named file does not exist or does not name a directory, then
411+ - if O_CREAT is specified, open() must fail since open() cannot create
412+ directories,
413+ - if O_WRONLY or O_RDWR is specified, open() must fail because the
414+ file does not contain a '.' directory. */
415+ if (flags & (O_CREAT | O_WRONLY | O_RDWR))
416+ {
417+ size_t len = strlen (filename);
418+ if (len > 0 && filename[len - 1] == '/')
419+ {
420+ errno = EISDIR;
421+ return -1;
422+ }
423+ }
424+#endif
425+
426+ fd = openat (dfd, filename, flags, mode);
427+
428+#if OPEN_TRAILING_SLASH_BUG
429+ /* If the filename ends in a slash and fd does not refer to a directory,
430+ then fail.
431+ Rationale: POSIX <http://www.opengroup.org/susv3/basedefs/xbd_chap04.html>
432+ says that
433+ "A pathname that contains at least one non-slash character and that
434+ ends with one or more trailing slashes shall be resolved as if a
435+ single dot character ( '.' ) were appended to the pathname."
436+ and
437+ "The special filename dot shall refer to the directory specified by
438+ its predecessor."
439+ If the named file without the slash is not a directory, open() must fail
440+ with ENOTDIR. */
441+ if (fd >= 0)
442+ {
443+ /* We know len is positive, since open did not fail with ENOENT. */
444+ size_t len = strlen (filename);
445+ if (filename[len - 1] == '/')
446+ {
447+ struct stat statbuf;
448+
449+ if (fstat (fd, &statbuf) >= 0 && !S_ISDIR (statbuf.st_mode))
450+ {
451+ close (fd);
452+ errno = ENOTDIR;
453+ return -1;
454+ }
455+ }
456+ }
457+#endif
458+
459+ return fd;
460+}
461+
462+#else /* !HAVE_OPENAT */
463+
464 /* Replacement for Solaris' openat function.
465 <http://www.google.com/search?q=openat+site:docs.sun.com>
466 First, try to simulate it via open ("/proc/self/fd/FD/FILE").
467@@ -47,12 +142,9 @@ openat (int fd, char const *file, int flags, ...)
468 va_list arg;
469 va_start (arg, flags);
470
471- /* If mode_t is narrower than int, use the promoted type (int),
472- not mode_t. Use sizeof to guess whether mode_t is narrower;
473- we don't know of any practical counterexamples. */
474- mode = (sizeof (mode_t) < sizeof (int)
475- ? va_arg (arg, int)
476- : va_arg (arg, mode_t));
477+ /* We have to use PROMOTED_MODE_T instead of mode_t, otherwise GCC 4
478+ creates crashing code when 'mode_t' is smaller than 'int'. */
479+ mode = va_arg (arg, PROMOTED_MODE_T);
480
481 va_end (arg);
482 }
483@@ -73,7 +165,7 @@ openat (int fd, char const *file, int flags, ...)
484
485 int
486 openat_permissive (int fd, char const *file, int flags, mode_t mode,
487- int *cwd_errno)
488+ int *cwd_errno)
489 {
490 struct saved_cwd saved_cwd;
491 int saved_errno;
492@@ -88,18 +180,18 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode,
493 char *proc_file = openat_proc_name (buf, fd, file);
494 if (proc_file)
495 {
496- int open_result = open (proc_file, flags, mode);
497- int open_errno = errno;
498- if (proc_file != buf)
499- free (proc_file);
500- /* If the syscall succeeds, or if it fails with an unexpected
501- errno value, then return right away. Otherwise, fall through
502- and resort to using save_cwd/restore_cwd. */
503- if (0 <= open_result || ! EXPECTED_ERRNO (open_errno))
504- {
505- errno = open_errno;
506- return open_result;
507- }
508+ int open_result = open (proc_file, flags, mode);
509+ int open_errno = errno;
510+ if (proc_file != buf)
511+ free (proc_file);
512+ /* If the syscall succeeds, or if it fails with an unexpected
513+ errno value, then return right away. Otherwise, fall through
514+ and resort to using save_cwd/restore_cwd. */
515+ if (0 <= open_result || ! EXPECTED_ERRNO (open_errno))
516+ {
517+ errno = open_errno;
518+ return open_result;
519+ }
520 }
521 }
522
523@@ -107,9 +199,18 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode,
524 if (! save_ok)
525 {
526 if (! cwd_errno)
527- openat_save_fail (errno);
528+ openat_save_fail (errno);
529 *cwd_errno = errno;
530 }
531+ if (0 <= fd && fd == saved_cwd.desc)
532+ {
533+ /* If saving the working directory collides with the user's
534+ requested fd, then the user's fd must have been closed to
535+ begin with. */
536+ free_cwd (&saved_cwd);
537+ errno = EBADF;
538+ return -1;
539+ }
540
541 err = fchdir (fd);
542 saved_errno = errno;
543@@ -119,11 +220,17 @@ openat_permissive (int fd, char const *file, int flags, mode_t mode,
544 err = open (file, flags, mode);
545 saved_errno = errno;
546 if (save_ok && restore_cwd (&saved_cwd) != 0)
547- {
548- if (! cwd_errno)
549- openat_restore_fail (errno);
550- *cwd_errno = errno;
551- }
552+ {
553+ if (! cwd_errno)
554+ {
555+ /* Don't write a message to just-created fd 2. */
556+ saved_errno = errno;
557+ if (err == STDERR_FILENO)
558+ close (err);
559+ openat_restore_fail (saved_errno);
560+ }
561+ *cwd_errno = errno;
562+ }
563 }
564
565 free_cwd (&saved_cwd);
566@@ -144,125 +251,15 @@ openat_needs_fchdir (void)
567 char buf[OPENAT_BUFFER_SIZE];
568 char *proc_file = openat_proc_name (buf, fd, ".");
569 if (proc_file)
570- {
571- needs_fchdir = false;
572- if (proc_file != buf)
573- free (proc_file);
574- }
575+ {
576+ needs_fchdir = false;
577+ if (proc_file != buf)
578+ free (proc_file);
579+ }
580 close (fd);
581 }
582
583 return needs_fchdir;
584 }
585
586-#if !HAVE_FDOPENDIR
587-
588-/* Replacement for Solaris' function by the same name.
589- <http://www.google.com/search?q=fdopendir+site:docs.sun.com>
590- First, try to simulate it via opendir ("/proc/self/fd/FD"). Failing
591- that, simulate it by doing save_cwd/fchdir/opendir(".")/restore_cwd.
592- If either the save_cwd or the restore_cwd fails (relatively unlikely),
593- then give a diagnostic and exit nonzero.
594- Otherwise, this function works just like Solaris' fdopendir.
595-
596- W A R N I N G:
597- Unlike the other fd-related functions here, this one
598- effectively consumes its FD parameter. The caller should not
599- close or otherwise manipulate FD if this function returns successfully. */
600-DIR *
601-fdopendir (int fd)
602-{
603- struct saved_cwd saved_cwd;
604- int saved_errno;
605- DIR *dir;
606-
607- char buf[OPENAT_BUFFER_SIZE];
608- char *proc_file = openat_proc_name (buf, fd, ".");
609- if (proc_file)
610- {
611- dir = opendir (proc_file);
612- saved_errno = errno;
613- }
614- else
615- {
616- dir = NULL;
617- saved_errno = EOPNOTSUPP;
618- }
619-
620- /* If the syscall fails with an expected errno value, resort to
621- save_cwd/restore_cwd. */
622- if (! dir && EXPECTED_ERRNO (saved_errno))
623- {
624- if (save_cwd (&saved_cwd) != 0)
625- openat_save_fail (errno);
626-
627- if (fchdir (fd) != 0)
628- {
629- dir = NULL;
630- saved_errno = errno;
631- }
632- else
633- {
634- dir = opendir (".");
635- saved_errno = errno;
636-
637- if (restore_cwd (&saved_cwd) != 0)
638- openat_restore_fail (errno);
639- }
640-
641- free_cwd (&saved_cwd);
642- }
643-
644- if (dir)
645- close (fd);
646- if (proc_file != buf)
647- free (proc_file);
648- errno = saved_errno;
649- return dir;
650-}
651-
652-#endif
653-
654-/* Replacement for Solaris' function by the same name.
655- <http://www.google.com/search?q=fstatat+site:docs.sun.com>
656- First, try to simulate it via l?stat ("/proc/self/fd/FD/FILE").
657- Failing that, simulate it via save_cwd/fchdir/(stat|lstat)/restore_cwd.
658- If either the save_cwd or the restore_cwd fails (relatively unlikely),
659- then give a diagnostic and exit nonzero.
660- Otherwise, this function works just like Solaris' fstatat. */
661-
662-#define AT_FUNC_NAME fstatat
663-#define AT_FUNC_F1 lstat
664-#define AT_FUNC_F2 stat
665-#define AT_FUNC_USE_F1_COND flag == AT_SYMLINK_NOFOLLOW
666-#define AT_FUNC_POST_FILE_PARAM_DECLS , struct stat *st, int flag
667-#define AT_FUNC_POST_FILE_ARGS , st
668-#include "at-func.c"
669-#undef AT_FUNC_NAME
670-#undef AT_FUNC_F1
671-#undef AT_FUNC_F2
672-#undef AT_FUNC_USE_F1_COND
673-#undef AT_FUNC_POST_FILE_PARAM_DECLS
674-#undef AT_FUNC_POST_FILE_ARGS
675-
676-/* Replacement for Solaris' function by the same name.
677- <http://www.google.com/search?q=unlinkat+site:docs.sun.com>
678- First, try to simulate it via (unlink|rmdir) ("/proc/self/fd/FD/FILE").
679- Failing that, simulate it via save_cwd/fchdir/(unlink|rmdir)/restore_cwd.
680- If either the save_cwd or the restore_cwd fails (relatively unlikely),
681- then give a diagnostic and exit nonzero.
682- Otherwise, this function works just like Solaris' unlinkat. */
683-
684-#define AT_FUNC_NAME unlinkat
685-#define AT_FUNC_F1 rmdir
686-#define AT_FUNC_F2 unlink
687-#define AT_FUNC_USE_F1_COND flag == AT_REMOVEDIR
688-#define AT_FUNC_POST_FILE_PARAM_DECLS , int flag
689-#define AT_FUNC_POST_FILE_ARGS /* empty */
690-#include "at-func.c"
691-#undef AT_FUNC_NAME
692-#undef AT_FUNC_F1
693-#undef AT_FUNC_F2
694-#undef AT_FUNC_USE_F1_COND
695-#undef AT_FUNC_POST_FILE_PARAM_DECLS
696-#undef AT_FUNC_POST_FILE_ARGS
697+#endif /* !HAVE_OPENAT */
698diff --git a/gnulib/lib/openat.h b/gnulib/lib/openat.h
699index b5e4f11..433b998 100644
700--- a/gnulib/lib/openat.h
701+++ b/gnulib/lib/openat.h
702@@ -1,5 +1,5 @@
703 /* provide a replacement openat function
704- Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
705+ Copyright (C) 2004-2006, 2008-2009 Free Software Foundation, Inc.
706
707 This program is free software: you can redistribute it and/or modify
708 it under the terms of the GNU General Public License as published by
709@@ -16,6 +16,9 @@
710
711 /* written by Jim Meyering */
712
713+#ifndef _GL_HEADER_OPENAT
714+#define _GL_HEADER_OPENAT
715+
716 #include <fcntl.h>
717
718 #include <sys/types.h>
719@@ -25,7 +28,7 @@
720 #include <stdbool.h>
721
722 #ifndef __attribute__
723-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
724+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
725 # define __attribute__(x) /* empty */
726 # endif
727 #endif
728@@ -34,46 +37,10 @@
729 # define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
730 #endif
731
732-/* Work around a bug in Solaris 9 and 10: AT_FDCWD is positive. Its
733- value exceeds INT_MAX, so its use as an int doesn't conform to the
734- C standard, and GCC and Sun C complain in some cases. If the bug
735- is present, undef AT_FDCWD here, so it can be redefined below. */
736-#if 0 < AT_FDCWD && AT_FDCWD == 0xffd19553
737-# undef AT_FDCWD
738-#endif
739-
740-/* Use the same bit pattern as Solaris 9, but with the proper
741- signedness. The bit pattern is important, in case this actually is
742- Solaris with the above workaround. */
743-#ifndef AT_FDCWD
744-# define AT_FDCWD (-3041965)
745-#endif
746-
747-/* Use the same values as Solaris 9. This shouldn't matter, but
748- there's no real reason to differ. */
749-#ifndef AT_SYMLINK_NOFOLLOW
750-# define AT_SYMLINK_NOFOLLOW 4096
751-# define AT_REMOVEDIR 1
752-#endif
753-
754-#ifdef __OPENAT_PREFIX
755+#if !HAVE_OPENAT
756
757-# undef openat
758-# define __OPENAT_CONCAT(x, y) x ## y
759-# define __OPENAT_XCONCAT(x, y) __OPENAT_CONCAT (x, y)
760-# define __OPENAT_ID(y) __OPENAT_XCONCAT (__OPENAT_PREFIX, y)
761-# define openat __OPENAT_ID (openat)
762-int openat (int fd, char const *file, int flags, /* mode_t mode */ ...);
763 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
764 int *cwd_errno);
765-# if ! HAVE_FDOPENDIR
766-# define fdopendir __OPENAT_ID (fdopendir)
767-# endif
768-DIR *fdopendir (int fd);
769-# define fstatat __OPENAT_ID (fstatat)
770-int fstatat (int fd, char const *file, struct stat *st, int flag);
771-# define unlinkat __OPENAT_ID (unlinkat)
772-int unlinkat (int fd, char const *file, int flag);
773 bool openat_needs_fchdir (void);
774
775 #else
776@@ -84,19 +51,8 @@ bool openat_needs_fchdir (void);
777
778 #endif
779
780-#if HAVE_OPENAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK
781-int rpl_fstatat (int fd, char const *file, struct stat *st, int flag);
782-# if !COMPILING_FSTATAT
783-# undef fstatat
784-# define fstatat rpl_fstatat
785-# endif
786-#endif
787-
788-int mkdirat (int fd, char const *file, mode_t mode);
789 void openat_restore_fail (int) ATTRIBUTE_NORETURN;
790 void openat_save_fail (int) ATTRIBUTE_NORETURN;
791-int fchmodat (int fd, char const *file, mode_t mode, int flag);
792-int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
793
794 /* Using these function names makes application code
795 slightly more readable than it would be with
796@@ -124,3 +80,35 @@ lchmodat (int fd, char const *file, mode_t mode)
797 {
798 return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
799 }
800+
801+static inline int
802+statat (int fd, char const *name, struct stat *st)
803+{
804+ return fstatat (fd, name, st, 0);
805+}
806+
807+static inline int
808+lstatat (int fd, char const *name, struct stat *st)
809+{
810+ return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
811+}
812+
813+#if GNULIB_FACCESSAT
814+/* For now, there are no wrappers named laccessat or leuidaccessat,
815+ since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
816+ since access rights on symlinks are of limited utility. */
817+
818+static inline int
819+accessat (int fd, char const *file, int mode)
820+{
821+ return faccessat (fd, file, mode, 0);
822+}
823+
824+static inline int
825+euidaccessat (int fd, char const *file, int mode)
826+{
827+ return faccessat (fd, file, mode, AT_EACCESS);
828+}
829+#endif
830+
831+#endif /* _GL_HEADER_OPENAT */
832diff --git a/gnulib/lib/se-context.in.h b/gnulib/lib/se-context.in.h
833new file mode 100644
834index 0000000..a34a7fb
835--- /dev/null
836+++ b/gnulib/lib/se-context.in.h
837@@ -0,0 +1,34 @@
838+#ifndef SELINUX_CONTEXT_H
839+# define SELINUX_CONTEXT_H
840+
841+# include <errno.h>
842+
843+#ifndef _GL_UNUSED_PARAMETER
844+# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
845+# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__))
846+# else
847+# define _GL_UNUSED_PARAMETER
848+# endif
849+#endif
850+
851+typedef int context_t;
852+static inline context_t context_new (char const *s _GL_UNUSED_PARAMETER)
853+ { errno = ENOTSUP; return 0; }
854+static inline char *context_str (context_t con _GL_UNUSED_PARAMETER)
855+ { errno = ENOTSUP; return (void *) 0; }
856+static inline void context_free (context_t c _GL_UNUSED_PARAMETER) {}
857+
858+static inline int context_user_set (context_t sc _GL_UNUSED_PARAMETER,
859+ char const *s _GL_UNUSED_PARAMETER)
860+ { errno = ENOTSUP; return -1; }
861+static inline int context_role_set (context_t sc _GL_UNUSED_PARAMETER,
862+ char const *s _GL_UNUSED_PARAMETER)
863+ { errno = ENOTSUP; return -1; }
864+static inline int context_range_set (context_t sc _GL_UNUSED_PARAMETER,
865+ char const *s _GL_UNUSED_PARAMETER)
866+ { errno = ENOTSUP; return -1; }
867+static inline int context_type_set (context_t sc _GL_UNUSED_PARAMETER,
868+ char const *s _GL_UNUSED_PARAMETER)
869+ { errno = ENOTSUP; return -1; }
870+
871+#endif
872diff --git a/gnulib/lib/se-selinux.in.h b/gnulib/lib/se-selinux.in.h
873new file mode 100644
874index 0000000..d683101
875--- /dev/null
876+++ b/gnulib/lib/se-selinux.in.h
877@@ -0,0 +1,103 @@
878+/* Replacement <selinux/selinux.h> for platforms that lack it.
879+ Copyright (C) 2008-2011 Free Software Foundation, Inc.
880+
881+ This program is free software: you can redistribute it and/or modify
882+ it under the terms of the GNU General Public License as published by
883+ the Free Software Foundation; either version 3 of the License, or
884+ (at your option) any later version.
885+
886+ This program is distributed in the hope that it will be useful,
887+ but WITHOUT ANY WARRANTY; without even the implied warranty of
888+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
889+ GNU General Public License for more details.
890+
891+ You should have received a copy of the GNU General Public License
892+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
893+
894+#ifndef _GL_SELINUX_SELINUX_H
895+# define _GL_SELINUX_SELINUX_H
896+
897+# if __GNUC__ >= 3
898+@PRAGMA_SYSTEM_HEADER@
899+# endif
900+@PRAGMA_COLUMNS@
901+
902+# if HAVE_SELINUX_SELINUX_H
903+
904+#@INCLUDE_NEXT@ @NEXT_SELINUX_SELINUX_H@
905+
906+# else
907+
908+# include <sys/types.h>
909+# include <errno.h>
910+
911+#ifndef _GL_UNUSED_PARAMETER
912+# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
913+# define _GL_UNUSED_PARAMETER __attribute__ ((__unused__))
914+# else
915+# define _GL_UNUSED_PARAMETER
916+# endif
917+#endif
918+
919+# if !GNULIB_defined_security_types
920+
921+typedef unsigned short security_class_t;
922+# define security_context_t char*
923+# define is_selinux_enabled() 0
924+
925+static inline int getcon (security_context_t *con _GL_UNUSED_PARAMETER)
926+ { errno = ENOTSUP; return -1; }
927+static inline void freecon (security_context_t con _GL_UNUSED_PARAMETER) {}
928+
929+
930+static inline int getfscreatecon (security_context_t *con _GL_UNUSED_PARAMETER)
931+ { errno = ENOTSUP; return -1; }
932+static inline int setfscreatecon (security_context_t con _GL_UNUSED_PARAMETER)
933+ { errno = ENOTSUP; return -1; }
934+static inline int matchpathcon (char const *file _GL_UNUSED_PARAMETER,
935+ mode_t m _GL_UNUSED_PARAMETER,
936+ security_context_t *con _GL_UNUSED_PARAMETER)
937+ { errno = ENOTSUP; return -1; }
938+static inline int getfilecon (char const *file _GL_UNUSED_PARAMETER,
939+ security_context_t *con _GL_UNUSED_PARAMETER)
940+ { errno = ENOTSUP; return -1; }
941+static inline int lgetfilecon (char const *file _GL_UNUSED_PARAMETER,
942+ security_context_t *con _GL_UNUSED_PARAMETER)
943+ { errno = ENOTSUP; return -1; }
944+static inline int fgetfilecon (int fd,
945+ security_context_t *con _GL_UNUSED_PARAMETER)
946+ { errno = ENOTSUP; return -1; }
947+static inline int setfilecon (char const *file _GL_UNUSED_PARAMETER,
948+ security_context_t con _GL_UNUSED_PARAMETER)
949+ { errno = ENOTSUP; return -1; }
950+static inline int lsetfilecon (char const *file _GL_UNUSED_PARAMETER,
951+ security_context_t con _GL_UNUSED_PARAMETER)
952+ { errno = ENOTSUP; return -1; }
953+static inline int fsetfilecon (int fd _GL_UNUSED_PARAMETER,
954+ security_context_t con _GL_UNUSED_PARAMETER)
955+ { errno = ENOTSUP; return -1; }
956+
957+static inline int security_check_context
958+ (security_context_t con _GL_UNUSED_PARAMETER)
959+ { errno = ENOTSUP; return -1; }
960+static inline int security_check_context_raw
961+ (security_context_t con _GL_UNUSED_PARAMETER)
962+ { errno = ENOTSUP; return -1; }
963+static inline int setexeccon (security_context_t con _GL_UNUSED_PARAMETER)
964+ { errno = ENOTSUP; return -1; }
965+static inline int security_compute_create
966+ (security_context_t scon _GL_UNUSED_PARAMETER,
967+ security_context_t tcon _GL_UNUSED_PARAMETER,
968+ security_class_t tclass _GL_UNUSED_PARAMETER,
969+ security_context_t *newcon _GL_UNUSED_PARAMETER)
970+ { errno = ENOTSUP; return -1; }
971+static inline int matchpathcon_init_prefix
972+ (char const *path _GL_UNUSED_PARAMETER,
973+ char const *prefix _GL_UNUSED_PARAMETER)
974+ { errno = ENOTSUP; return -1; }
975+
976+# define GNULIB_defined_security_types 1
977+# endif
978+
979+# endif
980+#endif /* _GL_SELINUX_SELINUX_H */
981diff --git a/gnulib/lib/selinux-at.c b/gnulib/lib/selinux-at.c
982new file mode 100644
983index 0000000..65f938b
984--- /dev/null
985+++ b/gnulib/lib/selinux-at.c
986@@ -0,0 +1,72 @@
987+/* openat-style fd-relative functions for SE Linux
988+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
989+
990+ This program is free software: you can redistribute it and/or modify
991+ it under the terms of the GNU General Public License as published by
992+ the Free Software Foundation, either version 3 of the License, or
993+ (at your option) any later version.
994+
995+ This program is distributed in the hope that it will be useful,
996+ but WITHOUT ANY WARRANTY; without even the implied warranty of
997+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
998+ GNU General Public License for more details.
999+
1000+ You should have received a copy of the GNU General Public License
1001+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1002+
1003+/* written by Jim Meyering */
1004+
1005+#include <config.h>
1006+
1007+#include "selinux-at.h"
1008+#include "openat.h"
1009+
1010+#include <stdlib.h>
1011+#include <unistd.h>
1012+#include <errno.h>
1013+#include <fcntl.h>
1014+
1015+#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
1016+#include "save-cwd.h"
1017+
1018+#include "openat-priv.h"
1019+
1020+#define AT_FUNC_NAME getfileconat
1021+#define AT_FUNC_F1 getfilecon
1022+#define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con
1023+#define AT_FUNC_POST_FILE_ARGS , con
1024+#include "at-func.c"
1025+#undef AT_FUNC_NAME
1026+#undef AT_FUNC_F1
1027+#undef AT_FUNC_POST_FILE_PARAM_DECLS
1028+#undef AT_FUNC_POST_FILE_ARGS
1029+
1030+#define AT_FUNC_NAME lgetfileconat
1031+#define AT_FUNC_F1 lgetfilecon
1032+#define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t *con
1033+#define AT_FUNC_POST_FILE_ARGS , con
1034+#include "at-func.c"
1035+#undef AT_FUNC_NAME
1036+#undef AT_FUNC_F1
1037+#undef AT_FUNC_POST_FILE_PARAM_DECLS
1038+#undef AT_FUNC_POST_FILE_ARGS
1039+
1040+#define AT_FUNC_NAME setfileconat
1041+#define AT_FUNC_F1 setfilecon
1042+#define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con
1043+#define AT_FUNC_POST_FILE_ARGS , con
1044+#include "at-func.c"
1045+#undef AT_FUNC_NAME
1046+#undef AT_FUNC_F1
1047+#undef AT_FUNC_POST_FILE_PARAM_DECLS
1048+#undef AT_FUNC_POST_FILE_ARGS
1049+
1050+#define AT_FUNC_NAME lsetfileconat
1051+#define AT_FUNC_F1 lsetfilecon
1052+#define AT_FUNC_POST_FILE_PARAM_DECLS , security_context_t con
1053+#define AT_FUNC_POST_FILE_ARGS , con
1054+#include "at-func.c"
1055+#undef AT_FUNC_NAME
1056+#undef AT_FUNC_F1
1057+#undef AT_FUNC_POST_FILE_PARAM_DECLS
1058+#undef AT_FUNC_POST_FILE_ARGS
1059diff --git a/gnulib/lib/selinux-at.h b/gnulib/lib/selinux-at.h
1060new file mode 100644
1061index 0000000..1d84c19
1062--- /dev/null
1063+++ b/gnulib/lib/selinux-at.h
1064@@ -0,0 +1,52 @@
1065+/* Prototypes for openat-style fd-relative SELinux functions
1066+ Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1067+
1068+ This program is free software: you can redistribute it and/or modify
1069+ it under the terms of the GNU General Public License as published by
1070+ the Free Software Foundation, either version 3 of the License, or
1071+ (at your option) any later version.
1072+
1073+ This program is distributed in the hope that it will be useful,
1074+ but WITHOUT ANY WARRANTY; without even the implied warranty of
1075+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1076+ GNU General Public License for more details.
1077+
1078+ You should have received a copy of the GNU General Public License
1079+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
1080+
1081+#include <selinux/selinux.h>
1082+#include <selinux/context.h>
1083+
1084+/* These are the dir-fd-relative variants of the functions without the
1085+ "at" suffix. For example, getfileconat (AT_FDCWD, file, &c) is usually
1086+ equivalent to getfilecon (file, &c). The emulation is accomplished
1087+ by first attempting getfilecon ("/proc/self/fd/DIR_FD/FILE", &c).
1088+ Failing that, simulate it via save_cwd/fchdir/getfilecon/restore_cwd.
1089+ If either the save_cwd or the restore_cwd fails (relatively unlikely),
1090+ then give a diagnostic and exit nonzero. */
1091+
1092+/* dir-fd-relative getfilecon. Set *CON to the SELinux security context
1093+ of the file specified by DIR_FD and FILE and return the length of *CON.
1094+ DIR_FD and FILE are interpreted as for fstatat[*]. A non-NULL *CON
1095+ must be freed with freecon. Upon error, set *CON to NULL, set errno
1096+ and return -1.
1097+ [*] with flags=0 here, with flags=AT_SYMLINK_NOFOLLOW for lgetfileconat */
1098+int getfileconat (int dir_fd, char const *file, security_context_t *con);
1099+
1100+/* dir-fd-relative lgetfilecon. This function is just like getfileconat,
1101+ except when DIR_FD and FILE specify a symlink: lgetfileconat operates on
1102+ the symlink, while getfileconat operates on the referent of the symlink. */
1103+int lgetfileconat (int dir_fd, char const *file, security_context_t *con);
1104+
1105+/* dir-fd-relative setfilecon. Set the SELinux security context of
1106+ the file specified by DIR_FD and FILE to CON. DIR_FD and FILE are
1107+ interpreted as for fstatat[*]. Upon success, return 0.
1108+ Otherwise, return -1 and set errno. */
1109+int setfileconat (int dir_fd, char const *file, security_context_t con);
1110+
1111+/* dir-fd-relative lsetfilecon. This function is just like setfileconat,
1112+ except that rather than dereferencing a symlink, this function affects it. */
1113+/* dir-fd-relative lsetfilecon. This function is just like setfileconat,
1114+ except when DIR_FD and FILE specify a symlink: lsetfileconat operates on
1115+ the symlink, while setfileconat operates on the referent of the symlink. */
1116+int lsetfileconat (int dir_fd, char const *file, security_context_t con);
1117diff --git a/gnulib/m4/gnulib-comp.m4 b/gnulib/m4/gnulib-comp.m4
1118index 1efe223..87f11dd 100644
1119--- a/gnulib/m4/gnulib-comp.m4
1120+++ b/gnulib/m4/gnulib-comp.m4
1121@@ -165,6 +165,11 @@ AC_DEFUN([gl_INIT],
1122 gl_SAME
1123 gl_SAVE_CWD
1124 gl_SAVEDIR
1125+ AC_CHECK_HEADERS([selinux/flask.h])
1126+ AC_LIBOBJ([selinux-at])
1127+ gl_HEADERS_SELINUX_SELINUX_H
1128+ gl_HEADERS_SELINUX_CONTEXT_H
1129+ AC_REQUIRE([AC_C_INLINE])
1130 gl_FUNC_SETENV
1131 gl_FUNC_UNSETENV
1132 gt_TYPE_SSIZE_T
1133@@ -425,6 +430,7 @@ AC_DEFUN([gl_FILE_LIST], [
1134 lib/getdate.h
1135 lib/getdate.y
1136 lib/getdelim.c
1137+ lib/getfilecon.c
1138 lib/getline.c
1139 lib/getopt.c
1140 lib/getopt.in.h
1141@@ -506,6 +512,10 @@ AC_DEFUN([gl_FILE_LIST], [
1142 lib/save-cwd.h
1143 lib/savedir.c
1144 lib/savedir.h
1145+ lib/se-context.in.h
1146+ lib/se-selinux.in.h
1147+ lib/selinux-at.c
1148+ lib/selinux-at.h
1149 lib/setenv.c
1150 lib/setenv.h
1151 lib/stat-macros.h
1152@@ -688,6 +698,8 @@ AC_DEFUN([gl_FILE_LIST], [
1153 m4/same.m4
1154 m4/save-cwd.m4
1155 m4/savedir.m4
1156+ m4/selinux-context-h.m4
1157+ m4/selinux-selinux-h.m4
1158 m4/setenv.m4
1159 m4/size_max.m4
1160 m4/ssize_t.m4
1161diff --git a/gnulib/m4/include_next.m4 b/gnulib/m4/include_next.m4
1162index 7ce472b..79edd7c 100644
1163--- a/gnulib/m4/include_next.m4
1164+++ b/gnulib/m4/include_next.m4
1165@@ -36,18 +36,35 @@ EOF
1166 CPPFLAGS="$save_CPPFLAGS"
1167 rm -rf conftestd1 conftestd2
1168 ])
1169+ PRAGMA_SYSTEM_HEADER=
1170 if test $gl_cv_have_include_next = yes; then
1171-
1172- dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
1173- dnl to use @INCLUDE_NEXT@ instead.
1174- AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
1175- [Define if your compiler supports the #include_next directive.])
1176-
1177 INCLUDE_NEXT=include_next
1178+ if test -n "$GCC"; then
1179+ PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
1180+ fi
1181 else
1182 INCLUDE_NEXT=include
1183 fi
1184 AC_SUBST([INCLUDE_NEXT])
1185+ AC_SUBST([PRAGMA_SYSTEM_HEADER])
1186+ AC_CACHE_CHECK([whether system header files limit the line length],
1187+ [gl_cv_pragma_columns],
1188+ [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
1189+ AC_EGREP_CPP([choke me],
1190+ [
1191+#ifdef __TANDEM
1192+choke me
1193+#endif
1194+ ],
1195+ [gl_cv_pragma_columns=yes],
1196+ [gl_cv_pragma_columns=no])
1197+ ])
1198+ if test $gl_cv_pragma_columns = yes; then
1199+ PRAGMA_COLUMNS="#pragma COLUMNS 10000"
1200+ else
1201+ PRAGMA_COLUMNS=
1202+ fi
1203+ AC_SUBST([PRAGMA_COLUMNS])
1204 ])
1205
1206 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
1207diff --git a/gnulib/m4/selinux-context-h.m4 b/gnulib/m4/selinux-context-h.m4
1208new file mode 100644
1209index 0000000..6b0bed1
1210--- /dev/null
1211+++ b/gnulib/m4/selinux-context-h.m4
1212@@ -0,0 +1,16 @@
1213+# serial 1 -*- Autoconf -*-
1214+# Copyright (C) 2006, 2007 Free Software Foundation, Inc.
1215+# This file is free software; the Free Software Foundation
1216+# gives unlimited permission to copy and/or distribute it,
1217+# with or without modifications, as long as this notice is preserved.
1218+
1219+# From Jim Meyering
1220+# Provide <selinux/context.h>, if necessary.
1221+
1222+AC_DEFUN([gl_HEADERS_SELINUX_CONTEXT_H],
1223+[
1224+ AC_CHECK_HEADERS([selinux/context.h],
1225+ [SELINUX_CONTEXT_H=],
1226+ [SELINUX_CONTEXT_H=selinux/context.h])
1227+ AC_SUBST([SELINUX_CONTEXT_H])
1228+])
1229diff --git a/gnulib/m4/selinux-selinux-h.m4 b/gnulib/m4/selinux-selinux-h.m4
1230new file mode 100644
1231index 0000000..767c4f7
1232--- /dev/null
1233+++ b/gnulib/m4/selinux-selinux-h.m4
1234@@ -0,0 +1,57 @@
1235+# serial 3 -*- Autoconf -*-
1236+# Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
1237+# This file is free software; the Free Software Foundation
1238+# gives unlimited permission to copy and/or distribute it,
1239+# with or without modifications, as long as this notice is preserved.
1240+
1241+# From Jim Meyering
1242+# Provide <selinux/selinux.h>, if necessary.
1243+# If it is already present, provide wrapper functions to guard against
1244+# misbehavior from getfilecon, lgetfilecon, and fgetfilecon.
1245+
1246+AC_DEFUN([gl_HEADERS_SELINUX_SELINUX_H],
1247+[
1248+ AC_REQUIRE([gl_LIBSELINUX])
1249+ AC_CHECK_HEADERS([selinux/selinux.h])
1250+
1251+ if test "$ac_cv_header_selinux_selinux_h" = yes; then
1252+ # We do have <selinux/selinux.h>, so do compile getfilecon.c
1253+ # and arrange to use its wrappers.
1254+ AC_LIBOBJ([getfilecon])
1255+ gl_CHECK_NEXT_HEADERS([selinux/selinux.h])
1256+ AC_DEFINE([getfilecon], [rpl_getfilecon],
1257+ [Always use our getfilecon wrapper.])
1258+ AC_DEFINE([lgetfilecon], [rpl_lgetfilecon],
1259+ [Always use our lgetfilecon wrapper.])
1260+ AC_DEFINE([fgetfilecon], [rpl_fgetfilecon],
1261+ [Always use our fgetfilecon wrapper.])
1262+ fi
1263+
1264+ case "$ac_cv_search_setfilecon:$ac_cv_header_selinux_selinux_h" in
1265+ no:*) # already warned
1266+ ;;
1267+ *:no)
1268+ AC_MSG_WARN([libselinux was found but selinux/selinux.h is missing.])
1269+ AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
1270+ esac
1271+])
1272+
1273+AC_DEFUN([gl_LIBSELINUX],
1274+[
1275+ AC_REQUIRE([AC_CANONICAL_HOST])
1276+ AC_REQUIRE([AC_CANONICAL_BUILD])
1277+ LIB_SELINUX=
1278+ gl_save_LIBS=$LIBS
1279+ AC_SEARCH_LIBS([setfilecon], [selinux],
1280+ [test "$ac_cv_search_setfilecon" = "none required" ||
1281+ LIB_SELINUX=$ac_cv_search_setfilecon])
1282+ AC_SUBST([LIB_SELINUX])
1283+ LIBS=$gl_save_LIBS
1284+
1285+ # Warn if SELinux is found but libselinux is absent;
1286+ if test "$ac_cv_search_setfilecon" = no &&
1287+ test "$host" = "$build" && test -d /selinux; then
1288+ AC_MSG_WARN([This system supports SELinux but libselinux is missing.])
1289+ AC_MSG_WARN([AC_PACKAGE_NAME will be compiled without SELinux support.])
1290+ fi
1291+])
1292--
12931.7.9.6
1294
diff --git a/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-supplemental.patch b/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-supplemental.patch
new file mode 100644
index 0000000..f4db6ac
--- /dev/null
+++ b/recipes-extended/findutils/findutils-4.4.2/findutils-with-selinux-supplemental.patch
@@ -0,0 +1,32 @@
1Subject: [PATCH] Fetch support for selinux in gnulib
2
3This eliminates the need for the following patch:
4findutils: support selinux and gnulib
5
6This is done by fetching the latest gnulib updates
7up to the point where the selinux-at module was
8introduced from coreutils.
9
10Upstream-Status: Backport
11
12diff --git a/import-gnulib.config b/import-gnulib.config
13index f2e8998..fa24d99 100644
14--- a/import-gnulib.config
15+++ b/import-gnulib.config
16@@ -1,7 +1,8 @@
17 # findutils gnulib.config -*- sh -*-
18
19 # What version of gnulib to use?
20-gnulib_version="e5573b1bad88bfabcda181b9e0125fb0c52b7d3b"
21+gnulib_version="7dfa1250265017223e36c72713a7521421b4d27c"
22 destdir="gnulib"
23
24 # Random extra gnulib files needed for findutils.
25@@ -68,6 +69,7 @@ realloc
26 regex
27 rpmatch
28 savedir
29+selinux-at
30 stat-macros
31 stat-time
32 stpcpy
diff --git a/recipes-extended/findutils/findutils_4.4.2.bbappend b/recipes-extended/findutils/findutils_4.4.2.bbappend
index eb94cfa..5488839 100644
--- a/recipes-extended/findutils/findutils_4.4.2.bbappend
+++ b/recipes-extended/findutils/findutils_4.4.2.bbappend
@@ -1,10 +1,17 @@
1PR .= ".2" 1PR .= ".3"
2 2
3FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:" 3FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
4 4
5SRC_URI += "git://git.yoctogit.savannah.gnu.org/gnulib.git"
5SRC_URI += "file://findutils-with-selinux.patch" 6SRC_URI += "file://findutils-with-selinux.patch"
6SRC_URI += "file://findutils-with-selinux-gnulib.patch" 7SRC_URI += "file://findutils-with-selinux-supplemental.patch"
8SRCREV = "7dfa1250265017223e36c72713a7521421b4d27c"
7 9
8DEPENDS += "${@base_contains('DISTRO_FEATURES', 'selinux', 'libselinux', '', d)}" 10DEPENDS += "${@base_contains('DISTRO_FEATURES', 'selinux', 'libselinux', '', d)}"
9 11
10EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'selinux', '--with-selinux', '--without-selinux', d)}" 12EXTRA_OECONF += "${@base_contains('DISTRO_FEATURES', 'selinux', '--with-selinux', '--without-selinux', d)}"
13
14#Make sure we call import-gnulib to reflect on the new changes to its config.
15do_configure_prepend () {
16 ${S}/import-gnulib.sh
17}