new upstream release 8.23, synchronize the old differences in ls SELinux options with upstream

This commit is contained in:
Ondřej Vašík 2014-07-22 14:01:39 +02:00
parent 2af6179bec
commit 9c33d82fb4
10 changed files with 105 additions and 759 deletions

2
.gitignore vendored
View File

@ -11,3 +11,5 @@
/coreutils-8.20.tar.xz
/coreutils-8.21.tar.xz
/coreutils-8.22.tar.xz
/coreutils-8.23.tar.xz
/coreutils-8.23.tar.xz.sig

View File

@ -1,109 +0,0 @@
From 2b3b5bfcd5f4161d17c0bc3d43f6edcfc4a2b294 Mon Sep 17 00:00:00 2001
From: Nicolas Looss <nicolas.iooss@m4x.org>
Date: Sat, 4 Jan 2014 03:03:51 +0000
Subject: [PATCH] copy: fix a segfault in SELinux context copying code
* src/selinux.c (restorecon_private): On ArchLinux the
`fakeroot cp -a file1 file2` command segfaulted due
to getfscreatecon() returning a NULL context.
So map this to the sometimes ignored ENODATA error,
rather than crashing.
* tests/cp/no-ctx.sh: Add a new test case.
* tests/local.mk: Reference the new test.
---
src/selinux.c | 5 ++++
tests/cp/no-ctx.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/local.mk | 1 +
3 files changed, 59 insertions(+), 0 deletions(-)
create mode 100755 tests/cp/no-ctx.sh
diff --git a/src/selinux.c b/src/selinux.c
index cd38a81..016db16 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -192,6 +192,11 @@ restorecon_private (char const *path, bool local)
{
if (getfscreatecon (&tcon) < 0)
return rc;
+ if (!tcon)
+ {
+ errno = ENODATA;
+ return rc;
+ }
rc = lsetfilecon (path, tcon);
freecon (tcon);
return rc;
diff --git a/tests/cp/no-ctx.sh b/tests/cp/no-ctx.sh
new file mode 100755
index 0000000..59d30de
--- /dev/null
+++ b/tests/cp/no-ctx.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Ensure we handle file systems returning no SELinux context,
+# which triggered a segmentation fault in coreutils-8.22.
+# This test is skipped on systems that lack LD_PRELOAD support; that's fine.
+# Similarly, on a system that lacks lgetfilecon altogether, skipping it is fine.
+
+# Copyright (C) 2014 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ cp
+require_gcc_shared_
+
+# Replace each getfilecon and lgetfilecon call with a call to these stubs.
+cat > k.c <<'EOF' || skip_
+#include <selinux/selinux.h>
+#include <errno.h>
+
+int getfilecon (const char *path, security_context_t *con)
+{ errno=ENODATA; return -1; }
+int lgetfilecon (const char *path, security_context_t *con)
+{ errno=ENODATA; return -1; }
+EOF
+
+# Then compile/link it:
+$CC -shared -fPIC -O2 k.c -o k.so \
+ || skip_ 'failed to build SELinux shared library'
+
+touch file_src
+
+# New file with SELinux context optionally included
+LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1
+
+# Existing file with SELinux context optionally included
+LD_PRELOAD=./k.so cp -a file_src file_dst || fail=1
+
+# ENODATA should give an immediate error when required to preserve ctx
+# This is debatable, and maybe we should not fail when no context available?
+LD_PRELOAD=./k.so cp --preserve=context file_src file_dst && fail=1
+
+Exit $fail
diff --git a/tests/local.mk b/tests/local.mk
index dc7341c..9d556f6 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -161,6 +161,7 @@ all_tests = \
tests/rm/ext3-perf.sh \
tests/rm/cycle.sh \
tests/cp/link-heap.sh \
+ tests/cp/no-ctx.sh \
tests/misc/tty-eof.pl \
tests/tail-2/inotify-hash-abuse.sh \
tests/tail-2/inotify-hash-abuse2.sh \
--
1.7.7.6

View File

@ -1,67 +0,0 @@
diff -urNp coreutils-8.22-orig/gnulib-tests/test-parse-datetime.c coreutils-8.22/gnulib-tests/test-parse-datetime.c
--- coreutils-8.22-orig/gnulib-tests/test-parse-datetime.c 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/gnulib-tests/test-parse-datetime.c 2014-03-02 20:33:25.691688592 +0100
@@ -419,5 +419,21 @@ main (int argc _GL_UNUSED, char **argv)
starting with a high-bit-set byte would be treated like "0". */
ASSERT ( ! parse_datetime (&result, "\xb0", &now));
+ /* Exercise TZ="" parsing code. */
+ /* These two would infloop or segfault before Feb 2014. */
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\"\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\" \"", &now));
+ /* Exercise invalid patterns. */
+ ASSERT ( ! parse_datetime (&result, "TZ=\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\\"", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\n", &now));
+ ASSERT ( ! parse_datetime (&result, "TZ=\"\\n\"", &now));
+ /* Exercise valid patterns. */
+ ASSERT ( parse_datetime (&result, "TZ=\"\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\" ", &now));
+ ASSERT ( parse_datetime (&result, " TZ=\"\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now));
+ ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now));
+
return 0;
}
diff -urNp coreutils-8.22-orig/lib/parse-datetime.y coreutils-8.22/lib/parse-datetime.y
--- coreutils-8.22-orig/lib/parse-datetime.y 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/lib/parse-datetime.y 2014-03-02 20:32:23.246124920 +0100
@@ -1303,8 +1303,6 @@ parse_datetime (struct timespec *result,
char tz1buf[TZBUFSIZE];
bool large_tz = TZBUFSIZE < tzsize;
bool setenv_ok;
- /* Free tz0, in case this is the 2nd or subsequent time through. */
- free (tz0);
tz0 = get_tz (tz0buf);
z = tz1 = large_tz ? xmalloc (tzsize) : tz1buf;
for (s = tzbase; *s != '"'; s++)
@@ -1316,7 +1314,12 @@ parse_datetime (struct timespec *result,
if (!setenv_ok)
goto fail;
tz_was_altered = true;
+
p = s + 1;
+ while (c = *p, c_isspace (c))
+ p++;
+
+ break;
}
}
diff -urNp coreutils-8.22-orig/tests/misc/date.pl coreutils-8.22/tests/misc/date.pl
--- coreutils-8.22-orig/tests/misc/date.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/date.pl 2014-03-02 20:30:43.200328295 +0100
@@ -287,6 +287,13 @@ my @Tests =
{ERR => "date: invalid date '\\260'\n"},
{EXIT => 1},
],
+
+ # From coreutils-5.3.0 to 8.22 inclusive
+ # this would either infinite loop or crash
+ ['invalid-TZ-crash', "-d 'TZ=\"\"\"'",
+ {ERR => "date: invalid date 'TZ=\"\"\"'\n"},
+ {EXIT => 1},
+ ],
);
# Repeat the cross-dst test, using Jan 1, 2005 and every interval from 1..364.

View File

@ -1,20 +0,0 @@
diff -urNp coreutils-8.22-orig/tests/dd/sparse.sh coreutils-8.22/tests/dd/sparse.sh
--- coreutils-8.22-orig/tests/dd/sparse.sh 2013-12-04 06:48:30.000000000 -0800
+++ coreutils-8.22/tests/dd/sparse.sh 2014-04-12 17:48:22.301975386 -0700
@@ -61,8 +61,15 @@ if test $(kb_alloc file.in) -gt 3000; th
dd if=file.in of=file.out bs=2M conv=sparse
test 2500 -lt $(kb_alloc file.out) || fail=1
+ # Note we recreate a sparse file first to avoid
+ # speculative preallocation seen in XFS, where a write() that
+ # extends a file can preallocate some extra space that
+ # a subsequent seek will not convert to a hole.
+ rm -f file.out
+ truncate --size=3M file.out
+
# Ensure that this 1MiB string of NULs *is* converted to a hole.
- dd if=file.in of=file.out bs=1M conv=sparse
+ dd if=file.in of=file.out bs=1M conv=sparse,notrunc
test $(kb_alloc file.out) -lt 2500 || fail=1
fi

View File

@ -83,8 +83,8 @@ diff -urNp coreutils-8.21-orig/src/df.c coreutils-8.21/src/df.c
see SIZE format below\n\
+ --direct show statistics for a file instead of mount point\n\
--total produce a grand total\n\
-h, --human-readable print sizes in human readable format (e.g., 1K 234M 2G)\
\n\
-h, --human-readable print sizes in powers of 1024 (e.g., 1023M)\n\
-H, --si print sizes in powers of 1000 (e.g., 1.1G)\n\
@@ -1305,6 +1325,9 @@ main (int argc, char **argv)
xstrtol_fatal (e, oi, c, long_options, optarg);
}

View File

@ -1,6 +1,6 @@
diff -urNp coreutils-8.22-orig/lib/linebuffer.h coreutils-8.22/lib/linebuffer.h
--- coreutils-8.22-orig/lib/linebuffer.h 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/lib/linebuffer.h 2014-01-08 13:55:56.106375471 +0100
diff -urNp coreutils-8.23-orig/lib/linebuffer.h coreutils-8.23/lib/linebuffer.h
--- coreutils-8.23-orig/lib/linebuffer.h 2014-05-29 14:05:50.000000000 +0200
+++ coreutils-8.23/lib/linebuffer.h 2014-07-22 13:45:52.700651881 +0200
@@ -21,6 +21,11 @@
# include <stdio.h>
@ -23,9 +23,9 @@ diff -urNp coreutils-8.22-orig/lib/linebuffer.h coreutils-8.22/lib/linebuffer.h
};
/* Initialize linebuffer LINEBUFFER for use. */
diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
--- coreutils-8.22-orig/src/cut.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/cut.c 2014-01-08 13:55:56.108375451 +0100
diff -urNp coreutils-8.23-orig/src/cut.c coreutils-8.23/src/cut.c
--- coreutils-8.23-orig/src/cut.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/cut.c 2014-07-22 13:48:06.225671732 +0200
@@ -28,6 +28,11 @@
#include <assert.h>
#include <getopt.h>
@ -130,7 +130,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
+ /* Output characters that are at the given positions. */
+ character_mode,
+
/* Output the given delimeter-separated fields. */
/* Output the given delimiter-separated fields. */
field_mode
};
@ -143,12 +143,12 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
+ if this program runs on multibyte locale. */
+static int force_singlebyte_mode;
+
/* If true do not output lines containing no delimeter characters.
/* If true do not output lines containing no delimiter characters.
Otherwise, all such lines are printed. This option is valid only
with field mode. */
@@ -126,6 +201,9 @@ static bool complement;
/* The delimeter character for field mode. */
/* The delimiter character for field mode. */
static unsigned char delim;
+#if HAVE_WCHAR_H
+static wchar_t wcdelim;
@ -156,7 +156,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
/* True if the --output-delimiter=STRING option was specified. */
static bool output_delimiter_specified;
@@ -188,7 +266,7 @@ Print selected parts of lines from each
@@ -188,7 +266,7 @@ Print selected parts of lines from each
-f, --fields=LIST select only these fields; also print any line\n\
that contains no delimiter character, unless\n\
the -s option is specified\n\
@ -258,7 +258,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
/* Read from stream STREAM, printing to standard output any selected fields. */
static void
@@ -629,13 +786,211 @@ cut_fields (FILE *stream)
@@ -649,13 +806,211 @@ cut_fields (FILE *stream)
}
}
@ -473,7 +473,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
}
/* Process file FILE to standard output.
@@ -687,6 +1038,7 @@ main (int argc, char **argv)
@@ -707,6 +1062,7 @@ main (int argc, char **argv)
bool ok;
bool delim_specified = false;
char *spec_list_string IF_LINT ( = NULL);
@ -481,7 +481,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
initialize_main (&argc, &argv);
set_program_name (argv[0]);
@@ -709,7 +1061,6 @@ main (int argc, char **argv)
@@ -729,7 +1085,6 @@ main (int argc, char **argv)
switch (optc)
{
case 'b':
@ -489,7 +489,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
/* Build the byte list. */
if (operating_mode != undefined_mode)
FATAL_ERROR (_("only one type of list may be specified"));
@@ -717,6 +1068,14 @@ main (int argc, char **argv)
@@ -737,6 +1092,14 @@ main (int argc, char **argv)
spec_list_string = optarg;
break;
@ -504,7 +504,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
case 'f':
/* Build the field list. */
if (operating_mode != undefined_mode)
@@ -728,10 +1087,38 @@ main (int argc, char **argv)
@@ -748,10 +1111,38 @@ main (int argc, char **argv)
case 'd':
/* New delimiter. */
/* Interpret -d '' to mean 'use the NUL byte as the delimiter.' */
@ -547,7 +547,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
break;
case OUTPUT_DELIMITER_OPTION:
@@ -744,6 +1131,7 @@ main (int argc, char **argv)
@@ -764,6 +1155,7 @@ main (int argc, char **argv)
break;
case 'n':
@ -555,7 +555,7 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
break;
case 's':
@@ -783,15 +1171,34 @@ main (int argc, char **argv)
@@ -803,15 +1195,34 @@ main (int argc, char **argv)
}
if (!delim_specified)
@ -596,9 +596,9 @@ diff -urNp coreutils-8.22-orig/src/cut.c coreutils-8.22/src/cut.c
}
if (optind == argc)
diff -urNp coreutils-8.22-orig/src/expand.c coreutils-8.22/src/expand.c
--- coreutils-8.22-orig/src/expand.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/expand.c 2014-01-08 13:55:56.110375431 +0100
diff -urNp coreutils-8.23-orig/src/expand.c coreutils-8.23/src/expand.c
--- coreutils-8.23-orig/src/expand.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/expand.c 2014-07-22 13:45:52.704651900 +0200
@@ -37,12 +37,34 @@
#include <stdio.h>
#include <getopt.h>
@ -791,9 +791,9 @@ diff -urNp coreutils-8.22-orig/src/expand.c coreutils-8.22/src/expand.c
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
diff -urNp coreutils-8.22-orig/src/fold.c coreutils-8.22/src/fold.c
--- coreutils-8.22-orig/src/fold.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/fold.c 2014-01-08 13:55:56.111375421 +0100
diff -urNp coreutils-8.23-orig/src/fold.c coreutils-8.23/src/fold.c
--- coreutils-8.23-orig/src/fold.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/fold.c 2014-07-22 13:45:52.705651904 +0200
@@ -22,12 +22,34 @@
#include <getopt.h>
#include <sys/types.h>
@ -1191,9 +1191,9 @@ diff -urNp coreutils-8.22-orig/src/fold.c coreutils-8.22/src/fold.c
break;
case 's': /* Break at word boundaries. */
diff -urNp coreutils-8.22-orig/src/join.c coreutils-8.22/src/join.c
--- coreutils-8.22-orig/src/join.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/join.c 2014-01-08 13:55:56.113375401 +0100
diff -urNp coreutils-8.23-orig/src/join.c coreutils-8.23/src/join.c
--- coreutils-8.23-orig/src/join.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/join.c 2014-07-22 13:45:52.707651912 +0200
@@ -22,18 +22,32 @@
#include <sys/types.h>
#include <getopt.h>
@ -1686,9 +1686,9 @@ diff -urNp coreutils-8.22-orig/src/join.c coreutils-8.22/src/join.c
break;
case 'z':
diff -urNp coreutils-8.22-orig/src/pr.c coreutils-8.22/src/pr.c
--- coreutils-8.22-orig/src/pr.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/pr.c 2014-01-08 13:55:56.118375350 +0100
diff -urNp coreutils-8.23-orig/src/pr.c coreutils-8.23/src/pr.c
--- coreutils-8.23-orig/src/pr.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/pr.c 2014-07-22 13:45:52.713651936 +0200
@@ -312,6 +312,24 @@
#include <getopt.h>
@ -2452,9 +2452,9 @@ diff -urNp coreutils-8.22-orig/src/pr.c coreutils-8.22/src/pr.c
/* We've just printed some files and need to clean up things before
looking for more options and printing the next batch of files.
diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
--- coreutils-8.22-orig/src/sort.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/sort.c 2014-01-08 13:55:56.123375301 +0100
diff -urNp coreutils-8.23-orig/src/sort.c coreutils-8.23/src/sort.c
--- coreutils-8.23-orig/src/sort.c 2014-07-14 00:09:52.000000000 +0200
+++ coreutils-8.23/src/sort.c 2014-07-22 13:45:52.719651960 +0200
@@ -29,6 +29,14 @@
#include <sys/wait.h>
#include <signal.h>
@ -3333,7 +3333,7 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
{
/* Note xmemcoll0 is a performance enhancement as
it will not unconditionally write '\0' after the
@@ -4113,6 +4738,7 @@ set_ordering (char const *s, struct keyf
@@ -4121,6 +4746,7 @@ set_ordering (char const *s, struct keyf
break;
case 'f':
key->translate = fold_toupper;
@ -3341,7 +3341,7 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
break;
case 'g':
key->general_numeric = true;
@@ -4190,7 +4816,7 @@ main (int argc, char **argv)
@@ -4198,7 +4824,7 @@ main (int argc, char **argv)
initialize_exit_failure (SORT_FAILURE);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@ -3350,7 +3350,7 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
hard_LC_TIME = hard_locale (LC_TIME);
#endif
@@ -4211,6 +4837,29 @@ main (int argc, char **argv)
@@ -4219,6 +4845,29 @@ main (int argc, char **argv)
thousands_sep = -1;
}
@ -3380,7 +3380,7 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
have_read_stdin = false;
inittables ();
@@ -4485,13 +5134,34 @@ main (int argc, char **argv)
@@ -4493,13 +5142,34 @@ main (int argc, char **argv)
case 't':
{
@ -3419,7 +3419,7 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
else
{
/* Provoke with 'sort -txx'. Complain about
@@ -4502,9 +5172,12 @@ main (int argc, char **argv)
@@ -4510,9 +5180,12 @@ main (int argc, char **argv)
quote (optarg));
}
}
@ -3434,9 +3434,9 @@ diff -urNp coreutils-8.22-orig/src/sort.c coreutils-8.22/src/sort.c
}
break;
diff -urNp coreutils-8.22-orig/src/unexpand.c coreutils-8.22/src/unexpand.c
--- coreutils-8.22-orig/src/unexpand.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/unexpand.c 2014-01-08 13:55:56.126375271 +0100
diff -urNp coreutils-8.23-orig/src/unexpand.c coreutils-8.23/src/unexpand.c
--- coreutils-8.23-orig/src/unexpand.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/unexpand.c 2014-07-22 13:45:52.721651968 +0200
@@ -38,12 +38,29 @@
#include <stdio.h>
#include <getopt.h>
@ -3692,9 +3692,9 @@ diff -urNp coreutils-8.22-orig/src/unexpand.c coreutils-8.22/src/unexpand.c
if (have_read_stdin && fclose (stdin) != 0)
error (EXIT_FAILURE, errno, "-");
diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
--- coreutils-8.22-orig/src/uniq.c 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/src/uniq.c 2014-01-08 13:55:56.127375261 +0100
diff -urNp coreutils-8.23-orig/src/uniq.c coreutils-8.23/src/uniq.c
--- coreutils-8.23-orig/src/uniq.c 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/src/uniq.c 2014-07-22 13:45:52.724651980 +0200
@@ -21,6 +21,17 @@
#include <getopt.h>
#include <sys/types.h>
@ -3745,7 +3745,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
static struct option const longopts[] =
{
{"count", no_argument, NULL, 'c'},
@@ -249,7 +276,7 @@ size_opt (char const *opt, char const *m
@@ -251,7 +278,7 @@ size_opt (char const *opt, char const *m
return a pointer to the beginning of the line's field to be compared. */
static char * _GL_ATTRIBUTE_PURE
@ -3754,7 +3754,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
{
size_t count;
char const *lp = line->buffer;
@@ -269,6 +296,83 @@ find_field (struct linebuffer const *lin
@@ -271,6 +298,83 @@ find_field (struct linebuffer const *lin
return line->buffer + i;
}
@ -3838,7 +3838,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
/* Return false if two strings OLD and NEW match, true if not.
OLD and NEW point not to the beginnings of the lines
but rather to the beginnings of the fields to compare.
@@ -277,6 +381,8 @@ find_field (struct linebuffer const *lin
@@ -279,6 +383,8 @@ find_field (struct linebuffer const *lin
static bool
different (char *old, char *new, size_t oldlen, size_t newlen)
{
@ -3847,7 +3847,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
if (check_chars < oldlen)
oldlen = check_chars;
if (check_chars < newlen)
@@ -284,14 +390,103 @@ different (char *old, char *new, size_t
@@ -286,14 +392,103 @@ different (char *old, char *new, size_t
if (ignore_case)
{
@ -3956,7 +3956,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
/* Output the line in linebuffer LINE to standard output
provided that the switches say it should be output.
@@ -356,19 +551,38 @@ check_file (const char *infile, const ch
@@ -358,19 +553,38 @@ check_file (const char *infile, const ch
char *prevfield IF_LINT ( = NULL);
size_t prevlen IF_LINT ( = 0);
bool first_group_printed = false;
@ -3995,7 +3995,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
new_group = (prevline->length == 0
|| different (thisfield, prevfield, thislen, prevlen));
@@ -386,6 +600,10 @@ check_file (const char *infile, const ch
@@ -388,6 +602,10 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
@ -4006,7 +4006,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
first_group_printed = true;
}
}
@@ -398,17 +616,26 @@ check_file (const char *infile, const ch
@@ -400,17 +618,26 @@ check_file (const char *infile, const ch
size_t prevlen;
uintmax_t match_count = 0;
bool first_delimiter = true;
@ -4033,7 +4033,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
if (readlinebuffer_delim (thisline, stdin, delimiter) == 0)
{
if (ferror (stdin))
@@ -417,6 +644,14 @@ check_file (const char *infile, const ch
@@ -419,6 +646,14 @@ check_file (const char *infile, const ch
}
thisfield = find_field (thisline);
thislen = thisline->length - 1 - (thisfield - thisline->buffer);
@ -4048,7 +4048,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
match = !different (thisfield, prevfield, thislen, prevlen);
match_count += match;
@@ -449,6 +684,9 @@ check_file (const char *infile, const ch
@@ -451,6 +686,9 @@ check_file (const char *infile, const ch
SWAP_LINES (prevline, thisline);
prevfield = thisfield;
prevlen = thislen;
@ -4058,7 +4058,7 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
if (!match)
match_count = 0;
}
@@ -495,6 +733,19 @@ main (int argc, char **argv)
@@ -497,6 +735,19 @@ main (int argc, char **argv)
atexit (close_stdout);
@ -4078,10 +4078,10 @@ diff -urNp coreutils-8.22-orig/src/uniq.c coreutils-8.22/src/uniq.c
skip_chars = 0;
skip_fields = 0;
check_chars = SIZE_MAX;
diff -urNp coreutils-8.22-orig/tests/local.mk coreutils-8.22/tests/local.mk
--- coreutils-8.22-orig/tests/local.mk 2014-01-08 13:55:24.524683837 +0100
+++ coreutils-8.22/tests/local.mk 2014-01-08 13:55:56.129375241 +0100
@@ -324,6 +324,7 @@ all_tests = \
diff -urNp coreutils-8.23-orig/tests/local.mk coreutils-8.23/tests/local.mk
--- coreutils-8.23-orig/tests/local.mk 2014-07-22 13:45:10.494422571 +0200
+++ coreutils-8.23/tests/local.mk 2014-07-22 13:45:52.726651988 +0200
@@ -331,6 +331,7 @@ all_tests = \
tests/misc/sort-discrim.sh \
tests/misc/sort-files0-from.pl \
tests/misc/sort-float.sh \
@ -4089,9 +4089,9 @@ diff -urNp coreutils-8.22-orig/tests/local.mk coreutils-8.22/tests/local.mk
tests/misc/sort-merge.pl \
tests/misc/sort-merge-fdlimit.sh \
tests/misc/sort-month.sh \
diff -urNp coreutils-8.22-orig/tests/misc/cut.pl coreutils-8.22/tests/misc/cut.pl
--- coreutils-8.22-orig/tests/misc/cut.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/cut.pl 2014-01-08 13:55:56.130375231 +0100
diff -urNp coreutils-8.23-orig/tests/misc/cut.pl coreutils-8.23/tests/misc/cut.pl
--- coreutils-8.23-orig/tests/misc/cut.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/cut.pl 2014-07-22 13:45:52.728651996 +0200
@@ -23,9 +23,11 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4106,7 +4106,7 @@ diff -urNp coreutils-8.22-orig/tests/misc/cut.pl coreutils-8.22/tests/misc/cut.p
my $prog = 'cut';
my $try = "Try '$prog --help' for more information.\n";
@@ -225,6 +227,7 @@ if ($mb_locale ne 'C')
@@ -227,6 +229,7 @@ if ($mb_locale ne 'C')
my @new_t = @$t;
my $test_name = shift @new_t;
@ -4114,9 +4114,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/cut.pl coreutils-8.22/tests/misc/cut.p
push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
}
push @Tests, @new;
diff -urNp coreutils-8.22-orig/tests/misc/expand.pl coreutils-8.22/tests/misc/expand.pl
--- coreutils-8.22-orig/tests/misc/expand.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/expand.pl 2014-01-08 13:55:56.135375181 +0100
diff -urNp coreutils-8.23-orig/tests/misc/expand.pl coreutils-8.23/tests/misc/expand.pl
--- coreutils-8.23-orig/tests/misc/expand.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/expand.pl 2014-07-22 13:45:52.729652000 +0200
@@ -23,6 +23,15 @@ use strict;
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4171,9 +4171,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/expand.pl coreutils-8.22/tests/misc/ex
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/fold.pl coreutils-8.22/tests/misc/fold.pl
--- coreutils-8.22-orig/tests/misc/fold.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/fold.pl 2014-01-08 13:55:56.136375171 +0100
diff -urNp coreutils-8.23-orig/tests/misc/fold.pl coreutils-8.23/tests/misc/fold.pl
--- coreutils-8.23-orig/tests/misc/fold.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/fold.pl 2014-07-22 13:45:52.730652004 +0200
@@ -20,9 +20,18 @@ use strict;
(my $program_name = $0) =~ s|.*/||;
@ -4243,9 +4243,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/fold.pl coreutils-8.22/tests/misc/fold
-my $prog = 'fold';
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
exit $fail;
diff -urNp coreutils-8.22-orig/tests/misc/join.pl coreutils-8.22/tests/misc/join.pl
--- coreutils-8.22-orig/tests/misc/join.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/join.pl 2014-01-08 13:55:56.137375161 +0100
diff -urNp coreutils-8.23-orig/tests/misc/join.pl coreutils-8.23/tests/misc/join.pl
--- coreutils-8.23-orig/tests/misc/join.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/join.pl 2014-07-22 13:45:52.731652008 +0200
@@ -25,6 +25,15 @@ my $limits = getlimits ();
my $prog = 'join';
@ -4312,9 +4312,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/join.pl coreutils-8.22/tests/misc/join
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/sort-mb-tests.sh coreutils-8.22/tests/misc/sort-mb-tests.sh
--- coreutils-8.22-orig/tests/misc/sort-mb-tests.sh 1970-01-01 01:00:00.000000000 +0100
+++ coreutils-8.22/tests/misc/sort-mb-tests.sh 2014-01-08 13:55:56.138375151 +0100
diff -urNp coreutils-8.23-orig/tests/misc/sort-mb-tests.sh coreutils-8.23/tests/misc/sort-mb-tests.sh
--- coreutils-8.23-orig/tests/misc/sort-mb-tests.sh 1970-01-01 01:00:00.000000000 +0100
+++ coreutils-8.23/tests/misc/sort-mb-tests.sh 2014-07-22 13:45:52.733652016 +0200
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Verify sort's multi-byte support.
@ -4361,9 +4361,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/sort-mb-tests.sh coreutils-8.22/tests/
+compare exp out || { fail=1; cat out; }
+
+Exit $fail
diff -urNp coreutils-8.22-orig/tests/misc/sort-merge.pl coreutils-8.22/tests/misc/sort-merge.pl
--- coreutils-8.22-orig/tests/misc/sort-merge.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/sort-merge.pl 2014-01-08 13:55:56.139375141 +0100
diff -urNp coreutils-8.23-orig/tests/misc/sort-merge.pl coreutils-8.23/tests/misc/sort-merge.pl
--- coreutils-8.23-orig/tests/misc/sort-merge.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/sort-merge.pl 2014-07-22 13:45:52.733652016 +0200
@@ -26,6 +26,15 @@ my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4420,9 +4420,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/sort-merge.pl coreutils-8.22/tests/mis
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/sort.pl coreutils-8.22/tests/misc/sort.pl
--- coreutils-8.22-orig/tests/misc/sort.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/sort.pl 2014-01-08 13:55:56.140375131 +0100
diff -urNp coreutils-8.23-orig/tests/misc/sort.pl coreutils-8.23/tests/misc/sort.pl
--- coreutils-8.23-orig/tests/misc/sort.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/sort.pl 2014-07-22 13:45:52.734652020 +0200
@@ -24,10 +24,15 @@ my $prog = 'sort';
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
@ -4486,9 +4486,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/sort.pl coreutils-8.22/tests/misc/sort
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/unexpand.pl coreutils-8.22/tests/misc/unexpand.pl
--- coreutils-8.22-orig/tests/misc/unexpand.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/unexpand.pl 2014-01-08 13:55:56.140375131 +0100
diff -urNp coreutils-8.23-orig/tests/misc/unexpand.pl coreutils-8.23/tests/misc/unexpand.pl
--- coreutils-8.23-orig/tests/misc/unexpand.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/unexpand.pl 2014-07-22 13:45:52.735652024 +0200
@@ -27,6 +27,14 @@ my $limits = getlimits ();
my $prog = 'unexpand';
@ -4542,9 +4542,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/unexpand.pl coreutils-8.22/tests/misc/
my $save_temps = $ENV{DEBUG};
my $verbose = $ENV{VERBOSE};
diff -urNp coreutils-8.22-orig/tests/misc/uniq.pl coreutils-8.22/tests/misc/uniq.pl
--- coreutils-8.22-orig/tests/misc/uniq.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/misc/uniq.pl 2014-01-08 13:55:56.141375121 +0100
diff -urNp coreutils-8.23-orig/tests/misc/uniq.pl coreutils-8.23/tests/misc/uniq.pl
--- coreutils-8.23-orig/tests/misc/uniq.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/misc/uniq.pl 2014-07-22 13:45:52.736652028 +0200
@@ -23,9 +23,17 @@ my $limits = getlimits ();
my $prog = 'uniq';
my $try = "Try '$prog --help' for more information.\n";
@ -4617,9 +4617,9 @@ diff -urNp coreutils-8.22-orig/tests/misc/uniq.pl coreutils-8.22/tests/misc/uniq
@Tests = add_z_variants \@Tests;
@Tests = triple_test \@Tests;
diff -urNp coreutils-8.22-orig/tests/pr/pr-tests.pl coreutils-8.22/tests/pr/pr-tests.pl
--- coreutils-8.22-orig/tests/pr/pr-tests.pl 2013-12-04 15:48:30.000000000 +0100
+++ coreutils-8.22/tests/pr/pr-tests.pl 2014-01-08 13:55:56.144375092 +0100
diff -urNp coreutils-8.23-orig/tests/pr/pr-tests.pl coreutils-8.23/tests/pr/pr-tests.pl
--- coreutils-8.23-orig/tests/pr/pr-tests.pl 2014-07-11 13:00:07.000000000 +0200
+++ coreutils-8.23/tests/pr/pr-tests.pl 2014-07-22 13:45:52.737652032 +0200
@@ -23,6 +23,15 @@ use strict;
my $prog = 'pr';

View File

@ -1,39 +0,0 @@
diff -up coreutils-8.22/gnulib-tests/test-isnanl.h.ppc coreutils-8.22/gnulib-tests/test-isnanl.h
--- coreutils-8.22/gnulib-tests/test-isnanl.h.ppc 2014-06-23 14:01:05.925541920 +0200
+++ coreutils-8.22/gnulib-tests/test-isnanl.h 2014-06-23 14:01:39.437617584 +0200
@@ -51,6 +51,15 @@ main ()
/* A bit pattern that is different from a Quiet NaN. With a bit of luck,
it's a Signalling NaN. */
{
+#if defined __powerpc__ && LDBL_MANT_DIG == 106
+ /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are
+ represented as the corresponding 64-bit IEEE values in the first double;
+ the second is ignored. Manipulate only the first double. */
+ #undef NWORDS
+ #define NWORDS \
+ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+#endif
+
memory_long_double m;
m.value = NaNl ();
# if LDBL_EXPBIT0_BIT > 0
diff -up coreutils-8.22/gnulib-tests/test-signbit.c.ppc coreutils-8.22/gnulib-tests/test-signbit.c
--- coreutils-8.22/gnulib-tests/test-signbit.c.ppc 2013-12-04 15:53:33.000000000 +0100
+++ coreutils-8.22/gnulib-tests/test-signbit.c 2014-06-23 13:59:20.378307385 +0200
@@ -151,6 +151,16 @@ test_signbitl ()
#define NWORDS \
((sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
typedef union { long double value; unsigned int word[NWORDS]; } memory_long_double;
+
+#if defined __powerpc__ && LDBL_MANT_DIG == 106
+ /* This is PowerPC "double double", a pair of two doubles. Inf and Nan are
+ represented as the corresponding 64-bit IEEE values in the first double;
+ the second is ignored. Manipulate only the first double. */
+ #undef NWORDS
+ #define NWORDS \
+ ((sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int))
+#endif
+
memory_long_double m;
m.value = zerol / zerol;
# if LDBL_EXPBIT0_BIT > 0

View File

@ -1,17 +1,3 @@
diff -urNp coreutils-8.21-orig/init.cfg coreutils-8.21/init.cfg
--- coreutils-8.21-orig/init.cfg 2013-01-31 01:46:24.000000000 +0100
+++ coreutils-8.21/init.cfg 2013-02-15 14:31:58.957469955 +0100
@@ -308,8 +308,8 @@ require_selinux_()
# Independent of whether SELinux is enabled system-wide,
# the current file system may lack SELinux support.
# Also the current build may have SELinux support disabled.
- case $(ls -Zd .) in
- '? .'|'unlabeled .')
+ case $(ls -Zd . | cut -f4 -d" ") in
+ '?'|'unlabeled')
test -z "$CONFIG_HEADER" \
&& framework_failure_ 'CONFIG_HEADER not defined'
grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
diff -urNp coreutils-8.21-orig/man/chcon.x coreutils-8.21/man/chcon.x
--- coreutils-8.21-orig/man/chcon.x 2011-08-23 15:44:01.000000000 +0200
+++ coreutils-8.21/man/chcon.x 2013-02-15 14:31:58.937482694 +0100
@ -31,45 +17,6 @@ diff -urNp coreutils-8.21-orig/man/runcon.x coreutils-8.21/man/runcon.x
[DESCRIPTION]
Run COMMAND with completely-specified CONTEXT, or with current or
transitioned security context modified by one or more of LEVEL,
diff -urNp coreutils-8.21-orig/src/copy.c coreutils-8.21/src/copy.c
--- coreutils-8.21-orig/src/copy.c 2013-02-07 10:37:05.000000000 +0100
+++ coreutils-8.21/src/copy.c 2013-02-15 14:31:58.941467872 +0100
@@ -2410,6 +2410,17 @@ copy_internal (char const *src_name, cha
else
{
omitted_permissions = 0;
+
+ /* For directories, the process global context could be reset for
+ descendents, so use it to set the context for existing dirs here.
+ This will also give earlier indication of failure to set ctx. */
+ if (x->set_security_context || x->preserve_security_context)
+ if (! set_file_security_ctx (dst_name, x->preserve_security_context,
+ false, x))
+ {
+ if (x->require_preserve_context)
+ goto un_backup;
+ }
}
/* Decide whether to copy the contents of the directory. */
@@ -2415,6 +2426,8 @@ copy_internal (char const *src_name, cha
{
/* Here, we are crossing a file system boundary and cp's -x option
is in effect: so don't copy the contents of this directory. */
+ if (x->preserve_security_context)
+ restore_default_fscreatecon_or_die ();
}
else
{
@@ -2602,7 +2613,7 @@ copy_internal (char const *src_name, cha
/* With -Z or --preserve=context, set the context for existing files.
Note this is done already for copy_reg() for reasons described therein. */
- if (!new_dst && !x->copy_as_regular
+ if (!new_dst && !x->copy_as_regular && !S_ISDIR (src_mode)
&& (x->set_security_context || x->preserve_security_context))
{
if (! set_file_security_ctx (dst_name, x->preserve_security_context,
diff -urNp coreutils-8.21-orig/src/cp.c coreutils-8.21/src/cp.c
--- coreutils-8.21-orig/src/cp.c 2013-02-07 10:37:05.000000000 +0100
+++ coreutils-8.21/src/cp.c 2013-02-15 14:31:58.945468929 +0100
@ -131,9 +78,9 @@ diff -urNp coreutils-8.21-orig/src/install.c coreutils-8.21/src/install.c
fputs (_("\
- --preserve-context preserve SELinux security context\n\
+ -P, --preserve-context preserve SELinux security context (-P deprecated)\n\
-Z, --context[=CTX] set SELinux security context of destination file to\n\
default type, or to CTX if specified\n\
"), stdout);
-Z set SELinux security context of destination\n\
file to default type\n\
--context[=CTX] like -Z, or if CTX is specified then set the\n\
@@ -782,7 +783,7 @@ main (int argc, char **argv)
we'll actually use backup_suffix_string. */
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
@ -163,367 +110,3 @@ diff -urNp coreutils-8.21-orig/src/install.c coreutils-8.21/src/install.c
x.preserve_security_context = true;
use_default_selinux_context = false;
break;
diff -urNp coreutils-8.21-orig/src/ls.c coreutils-8.21/src/ls.c
--- coreutils-8.21-orig/src/ls.c 2013-02-03 04:24:02.000000000 +0100
+++ coreutils-8.21/src/ls.c 2013-02-15 14:31:58.953469008 +0100
@@ -165,7 +165,8 @@ enum filetype
symbolic_link,
sock,
whiteout,
- arg_directory
+ arg_directory,
+ command_line
};
/* Display letters and indicators for each filetype.
@@ -281,6 +282,7 @@ static void queue_directory (char const
bool command_line_arg);
static void sort_files (void);
static void parse_ls_color (void);
+static void print_scontext_format (const struct fileinfo *f);
/* Initial size of hash table.
Most hierarchies are likely to be shallower than this. */
@@ -350,7 +352,7 @@ static struct pending *pending_dirs;
static struct timespec current_time;
-static bool print_scontext;
+static int print_scontext = 0;
static char UNKNOWN_SECURITY_CONTEXT[] = "?";
/* Whether any of the files has an ACL. This affects the width of the
@@ -390,7 +392,9 @@ enum format
one_per_line, /* -1 */
many_per_line, /* -C */
horizontal, /* -x */
- with_commas /* -m */
+ with_commas, /* -m */
+ security_format, /* -Z */
+ invalid_format
};
static enum format format;
@@ -793,6 +797,9 @@ enum
SHOW_CONTROL_CHARS_OPTION,
SI_OPTION,
SORT_OPTION,
+ CONTEXT_OPTION,
+ LCONTEXT_OPTION,
+ SCONTEXT_OPTION,
TIME_OPTION,
TIME_STYLE_OPTION
};
@@ -839,7 +846,9 @@ static struct option const long_options[
{"time-style", required_argument, NULL, TIME_STYLE_OPTION},
{"color", optional_argument, NULL, COLOR_OPTION},
{"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
- {"context", no_argument, 0, 'Z'},
+ {"context", no_argument, 0, CONTEXT_OPTION},
+ {"lcontext", no_argument, 0, LCONTEXT_OPTION},
+ {"scontext", no_argument, 0, SCONTEXT_OPTION},
{"author", no_argument, NULL, AUTHOR_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
@@ -849,12 +858,12 @@ static struct option const long_options[
static char const *const format_args[] =
{
"verbose", "long", "commas", "horizontal", "across",
- "vertical", "single-column", NULL
+ "vertical", "single-column", "context", NULL
};
static enum format const format_types[] =
{
long_format, long_format, with_commas, horizontal, horizontal,
- many_per_line, one_per_line
+ many_per_line, one_per_line, security_format
};
ARGMATCH_VERIFY (format_args, format_types);
@@ -1296,7 +1305,8 @@ main (int argc, char **argv)
/* Avoid following symbolic links when possible. */
if (is_colored (C_ORPHAN)
|| (is_colored (C_EXEC) && color_symlink_as_referent)
- || (is_colored (C_MISSING) && format == long_format))
+ || (is_colored (C_MISSING) && (format == long_format
+ || format == security_format)))
check_symlink_color = true;
/* If the standard output is a controlling terminal, watch out
@@ -1343,7 +1353,7 @@ main (int argc, char **argv)
if (dereference == DEREF_UNDEFINED)
dereference = ((immediate_dirs
|| indicator_style == classify
- || format == long_format)
+ || format == long_format || format == security_format)
? DEREF_NEVER
: DEREF_COMMAND_LINE_SYMLINK_TO_DIR);
@@ -1363,7 +1373,7 @@ main (int argc, char **argv)
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
- || print_scontext
+ || format == security_format || print_scontext
|| print_block_size;
format_needs_type = (! format_needs_stat
&& (recursive
@@ -1394,7 +1404,7 @@ main (int argc, char **argv)
}
else
do
- gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, "");
+ gobble_file (argv[i++], command_line, NOT_AN_INODE_NUMBER, true, "");
while (i < argc);
if (cwd_n_used)
@@ -1565,7 +1575,7 @@ decode_switches (int argc, char **argv)
ignore_mode = IGNORE_DEFAULT;
ignore_patterns = NULL;
hide_patterns = NULL;
- print_scontext = false;
+ print_scontext = 0;
/* FIXME: put this in a function. */
{
@@ -1941,13 +1951,27 @@ decode_switches (int argc, char **argv)
break;
case 'Z':
- print_scontext = true;
+ print_scontext = 1;
+ format = security_format;
break;
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+ case CONTEXT_OPTION: /* default security context format */
+ print_scontext = 1;
+ format = security_format;
+ break;
+ case LCONTEXT_OPTION: /* long format plus security context */
+ print_scontext = 1;
+ format = long_format;
+ break;
+ case SCONTEXT_OPTION: /* short form of new security format */
+ print_scontext = 0;
+ format = security_format;
+ break;
+
default:
usage (LS_FAILURE);
}
@@ -2883,6 +2907,7 @@ gobble_file (char const *name, enum file
memset (f, '\0', sizeof *f);
f->stat.st_ino = inode;
f->filetype = type;
+ f->scontext = NULL;
if (command_line_arg
|| format_needs_stat
@@ -2995,7 +3020,7 @@ gobble_file (char const *name, enum file
&& print_with_color && is_colored (C_CAP))
f->has_capability = has_capability_cache (absolute_name, f);
- if (format == long_format || print_scontext)
+ if (format == long_format || format == security_format || print_scontext)
{
bool have_scontext = false;
bool have_acl = false;
@@ -3016,7 +3041,7 @@ gobble_file (char const *name, enum file
err = 0;
}
- if (err == 0 && format == long_format)
+ if (err == 0 && (format == long_format || format == security_format))
{
int n = file_has_acl_cache (absolute_name, f);
err = (n < 0);
@@ -3035,7 +3060,8 @@ gobble_file (char const *name, enum file
}
if (S_ISLNK (f->stat.st_mode)
- && (format == long_format || check_symlink_color))
+ && (format == long_format || format == security_format
+ || check_symlink_color))
{
struct stat linkstats;
@@ -3054,6 +3080,7 @@ gobble_file (char const *name, enum file
command line are automatically traced if not being
listed as files. */
if (!command_line_arg || format == long_format
+ || format == security_format
|| !S_ISDIR (linkstats.st_mode))
{
/* Get the linked-to file's mode for the filetype indicator
@@ -3087,7 +3114,7 @@ gobble_file (char const *name, enum file
block_size_width = len;
}
- if (format == long_format)
+ if (format == long_format || format == security_format)
{
if (print_owner)
{
@@ -3591,6 +3618,13 @@ print_current_files (void)
print_long_format (sorted_file[i]);
DIRED_PUTCHAR ('\n');
}
+ break;
+ case security_format:
+ for (i = 0; i < cwd_n_used; i++)
+ {
+ print_scontext_format (sorted_file[i]);
+ DIRED_PUTCHAR ('\n');
+ }
break;
}
}
@@ -3753,6 +3787,67 @@ format_inode (char *buf, size_t buflen,
: (char *) "?");
}
+/* Print info about f in scontext format */
+static void
+print_scontext_format (const struct fileinfo *f)
+{
+ char modebuf[12];
+
+ /* 7 fields that may require LONGEST_HUMAN_READABLE bytes,
+ 1 10-byte mode string,
+ 9 spaces, one following each of these fields, and
+ 1 trailing NUL byte. */
+
+ char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10 + 9 + 1];
+ char *buf = init_bigbuf;
+ char *p;
+
+ p = buf;
+
+ if ( print_scontext ) { /* zero means terse listing */
+ filemodestring (&f->stat, modebuf);
+ if (! any_has_acl)
+ modebuf[10] = '\0';
+ else if (f->acl_type == ACL_T_SELINUX_ONLY)
+ modebuf[10] = '.';
+ else if (f->acl_type == ACL_T_YES)
+ modebuf[10] = '+';
+ modebuf[11] = '\0';
+
+ /* print mode */
+
+ (void) sprintf (p, "%s ", modebuf);
+ p += strlen (p);
+
+ /* print standard user and group */
+
+ DIRED_FPUTS (buf, stdout, p - buf);
+ format_user (f->stat.st_uid, owner_width, f->stat_ok);
+ format_group (f->stat.st_gid, group_width, f->stat_ok);
+ p = buf;
+ }
+
+ (void) sprintf (p, "%-32s ", f->scontext ?: "");
+ p += strlen (p);
+
+ DIRED_INDENT ();
+ DIRED_FPUTS (buf, stdout, p - buf);
+ size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf);
+
+ if (f->filetype == symbolic_link) {
+ if (f->linkname) {
+ DIRED_FPUTS_LITERAL (" -> ", stdout);
+ print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
+ if (indicator_style != none)
+ print_type_indicator (f->stat_ok, f->linkmode, f->filetype);
+ }
+ }
+ else {
+ if (indicator_style != none)
+ print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
+ }
+}
+
/* Print information about F in long format. */
static void
print_long_format (const struct fileinfo *f)
@@ -3844,9 +3939,15 @@ print_long_format (const struct fileinfo
The latter is wrong when nlink_width is zero. */
p += strlen (p);
+ if (print_scontext)
+ {
+ sprintf (p, "%-32s ", f->scontext ? f->scontext : "");
+ p += strlen (p);
+ }
+
DIRED_INDENT ();
- if (print_owner || print_group || print_author || print_scontext)
+ if (print_owner || print_group || print_author)
{
DIRED_FPUTS (buf, stdout, p - buf);
@@ -3859,9 +3960,6 @@ print_long_format (const struct fileinfo
if (print_author)
format_user (f->stat.st_author, author_width, f->stat_ok);
- if (print_scontext)
- format_user_or_group (f->scontext, 0, scontext_width);
-
p = buf;
}
@@ -4207,9 +4305,6 @@ print_file_name_and_frills (const struct
: human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
ST_NBLOCKSIZE, output_block_size));
- if (print_scontext)
- printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
-
size_t width = print_name_with_quoting (f, false, NULL, start_col);
if (indicator_style != none)
@@ -4417,9 +4512,6 @@ length_of_file_name_and_frills (const st
output_block_size))
: block_size_width);
- if (print_scontext)
- len += 1 + (format == with_commas ? strlen (f->scontext) : scontext_width);
-
quote_name (NULL, f->name, filename_quoting_options, &name_width);
len += name_width;
@@ -4856,9 +4948,16 @@ Sort entries alphabetically if none of -
-w, --width=COLS assume screen width instead of current value\n\
-x list entries by lines instead of by columns\n\
-X sort alphabetically by entry extension\n\
- -Z, --context print any SELinux security context of each file\n\
-1 list one file per line\n\
"), stdout);
+ fputs(_("\nSELinux options:\n\n\
+ --lcontext Display security context. Enable -l. Lines\n\
+ will probably be too wide for most displays.\n\
+ -Z, --context Display security context so it fits on most\n\
+ displays. Displays only mode, user, group,\n\
+ security context and file name.\n\
+ --scontext Display only security context and file name.\n\
+"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
emit_size_note ();
diff -urNp coreutils-8.21-orig/tests/misc/selinux.sh coreutils-8.21/tests/misc/selinux.sh
--- coreutils-8.21-orig/tests/misc/selinux.sh 2013-01-31 01:46:24.000000000 +0100
+++ coreutils-8.21/tests/misc/selinux.sh 2013-02-15 14:31:58.957469955 +0100
@@ -37,7 +37,7 @@ chcon $ctx f d p ||
# inspect that context with both ls -Z and stat.
for i in d f p; do
- c=$(ls -dogZ $i|cut -d' ' -f3); test x$c = x$ctx || fail=1
+ c=$(ls -dogZ $i|cut -d' ' -f4); test x$c = x$ctx || fail=1
c=$(stat --printf %C $i); test x$c = x$ctx || fail=1
done

View File

@ -1,11 +1,12 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 8.22
Release: 16%{?dist}
Version: 8.23
Release: 1%{?dist}
License: GPLv3+
Group: System Environment/Base
Url: http://www.gnu.org/software/coreutils/
Source0: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
Source2: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
Source101: coreutils-DIR_COLORS
Source102: coreutils-DIR_COLORS.lightbgcolor
Source103: coreutils-DIR_COLORS.256color
@ -13,11 +14,6 @@ Source105: coreutils-colorls.sh
Source106: coreutils-colorls.csh
# From upstream
Patch1: coreutils-8.22-cp-selinux.patch
Patch2: coreutils-8.22-datetzcrash.patch
Patch3: coreutils-8.22-dd-sparsetest-xfsspeculativeprealloc.patch
#backport of patch from gnulib fixing tests on powerPC
Patch4: coreutils-ppc-gnulib-tests.patch
# Our patches
#general patch to workaround koji build system issues
@ -126,12 +122,6 @@ the old GNU fileutils, sh-utils, and textutils packages.
%prep
%setup -q
# From upstream
%patch1 -p1 -b .nullcontext
%patch2 -p1 -b .tzcrash
%patch3 -p1 -b .xfs
%patch4 -p1 -b .ppc
# Our patches
%patch100 -p1 -b .configure
%patch101 -p1 -b .manpages
@ -377,6 +367,11 @@ fi
%{_sbindir}/chroot
%changelog
* Tue Jul 22 2014 Ondrej Vasik <ovasik@redhat.com> - 8.23-1
- new upstream release 8.23
- synchronize the old differences in ls SELinux options
with upstream
* Mon Jun 23 2014 Jakub Čajka <jcajka@redhat.com> - 8.22-16
- fix failed tests on ppc(backport from gnulib upstream)

View File

@ -1 +1,2 @@
8fb0ae2267aa6e728958adc38f8163a2 coreutils-8.22.tar.xz
abed135279f87ad6762ce57ff6d89c41 coreutils-8.23.tar.xz
f93deb9f48c2bc7236743a10bf1c2409 coreutils-8.23.tar.xz.sig