2013-02-15 16:50:47 +00:00
|
|
|
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.
|
2013-12-14 17:41:07 +00:00
|
|
|
# Also the current build may have SELinux support disabled.
|
2013-02-15 16:50:47 +00:00
|
|
|
- case $(ls -Zd .) in
|
|
|
|
- '? .'|'unlabeled .')
|
|
|
|
+ case $(ls -Zd . | cut -f4 -d" ") in
|
|
|
|
+ '?'|'unlabeled')
|
2013-12-14 17:41:07 +00:00
|
|
|
test -z "$CONFIG_HEADER" \
|
|
|
|
&& framework_failure_ 'CONFIG_HEADER not defined'
|
|
|
|
grep '^#define HAVE_SELINUX_SELINUX_H 1' "$CONFIG_HEADER" > /dev/null \
|
2013-02-15 16:50:47 +00:00
|
|
|
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
|
2008-10-22 11:07:44 +00:00
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
[NAME]
|
2008-01-25 17:48:11 +00:00
|
|
|
-chcon \- change file security context
|
|
|
|
+chcon \- change file SELinux security context
|
2008-10-22 11:07:44 +00:00
|
|
|
[DESCRIPTION]
|
2008-01-25 17:48:11 +00:00
|
|
|
.\" Add any additional description here
|
2013-02-15 16:50:47 +00:00
|
|
|
diff -urNp coreutils-8.21-orig/man/runcon.x coreutils-8.21/man/runcon.x
|
|
|
|
--- coreutils-8.21-orig/man/runcon.x 2011-08-23 15:44:01.000000000 +0200
|
|
|
|
+++ coreutils-8.21/man/runcon.x 2013-02-15 14:31:58.938486496 +0100
|
2008-10-22 11:07:44 +00:00
|
|
|
@@ -1,5 +1,5 @@
|
|
|
|
[NAME]
|
|
|
|
-runcon \- run command with specified security context
|
|
|
|
+runcon \- run command with specified SELinux security context
|
|
|
|
[DESCRIPTION]
|
|
|
|
Run COMMAND with completely-specified CONTEXT, or with current or
|
|
|
|
transitioned security context modified by one or more of LEVEL,
|
2013-02-15 16:50:47 +00:00
|
|
|
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
|
2014-01-03 07:38:06 +00:00
|
|
|
@@ -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
|
2009-09-12 09:28:49 +00:00
|
|
|
{
|
|
|
|
/* 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. */
|
2008-01-25 17:48:11 +00:00
|
|
|
+ if (x->preserve_security_context)
|
2009-09-12 09:28:49 +00:00
|
|
|
+ restore_default_fscreatecon_or_die ();
|
|
|
|
}
|
2008-01-25 17:48:11 +00:00
|
|
|
else
|
2009-09-12 09:28:49 +00:00
|
|
|
{
|
2014-01-03 07:38:06 +00:00
|
|
|
@@ -2602,7 +2613,7 @@ copy_internal (char const *src_name, cha
|
2014-01-02 10:39:46 +00:00
|
|
|
|
|
|
|
/* With -Z or --preserve=context, set the context for existing files.
|
|
|
|
Note this is done already for copy_reg() for reasons described therein. */
|
2014-01-03 07:38:06 +00:00
|
|
|
- if (!new_dst && !x->copy_as_regular
|
|
|
|
+ if (!new_dst && !x->copy_as_regular && !S_ISDIR (src_mode)
|
2014-01-02 10:39:46 +00:00
|
|
|
&& (x->set_security_context || x->preserve_security_context))
|
|
|
|
{
|
2014-01-03 07:38:06 +00:00
|
|
|
if (! set_file_security_ctx (dst_name, x->preserve_security_context,
|
2013-02-15 16:50:47 +00:00
|
|
|
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
|
|
|
|
@@ -201,6 +202,9 @@ Copy SOURCE to DEST, or multiple SOURCE(
|
2009-11-18 14:48:00 +00:00
|
|
|
all\n\
|
|
|
|
"), stdout);
|
|
|
|
fputs (_("\
|
2014-01-02 10:39:46 +00:00
|
|
|
+ -c deprecated, same as --preserve=context\n\
|
2009-11-18 14:48:00 +00:00
|
|
|
+"), stdout);
|
|
|
|
+ fputs (_("\
|
|
|
|
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\
|
|
|
|
--parents use full source file name under DIRECTORY\n\
|
|
|
|
"), stdout);
|
2011-01-04 16:59:58 +00:00
|
|
|
@@ -933,7 +939,7 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
we'll actually use backup_suffix_string. */
|
|
|
|
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
|
|
|
|
2013-12-14 17:41:07 +00:00
|
|
|
- while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
|
|
|
|
+ while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ",
|
2009-11-18 14:48:00 +00:00
|
|
|
long_opts, NULL))
|
|
|
|
!= -1)
|
|
|
|
{
|
2013-12-16 08:42:12 +00:00
|
|
|
@@ -981,6 +987,17 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
copy_contents = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case 'c':
|
2013-12-18 16:13:25 +00:00
|
|
|
+ fprintf (stderr, "%s: warning: option '-c' is deprecated, please use '--preserve=context' instead\n", argv[0]);
|
2009-11-18 14:48:00 +00:00
|
|
|
+ if ( x.set_security_context ) {
|
|
|
|
+ (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+ else if (selinux_enabled) {
|
|
|
|
+ x.preserve_security_context = true;
|
|
|
|
+ x.require_preserve_context = true;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
case 'd':
|
|
|
|
x.preserve_links = true;
|
|
|
|
x.dereference = DEREF_NEVER;
|
2013-02-15 16:50:47 +00:00
|
|
|
diff -urNp coreutils-8.21-orig/src/id.c coreutils-8.21/src/id.c
|
|
|
|
--- coreutils-8.21-orig/src/id.c 2013-01-31 01:46:24.000000000 +0100
|
|
|
|
+++ coreutils-8.21/src/id.c 2013-02-15 14:31:58.946469154 +0100
|
|
|
|
@@ -106,7 +106,7 @@ int
|
2009-11-18 14:48:00 +00:00
|
|
|
main (int argc, char **argv)
|
2008-01-25 17:48:11 +00:00
|
|
|
{
|
2009-11-18 14:48:00 +00:00
|
|
|
int optc;
|
|
|
|
- int selinux_enabled = (is_selinux_enabled () > 0);
|
|
|
|
+ bool selinux_enabled = (is_selinux_enabled () > 0);
|
2013-12-14 17:41:07 +00:00
|
|
|
bool smack_enabled = is_smack_enabled ();
|
|
|
|
bool opt_zero = false;
|
|
|
|
char *pw_name = NULL;
|
2013-02-15 16:50:47 +00:00
|
|
|
diff -urNp coreutils-8.21-orig/src/install.c coreutils-8.21/src/install.c
|
|
|
|
--- coreutils-8.21-orig/src/install.c 2013-02-07 10:37:05.000000000 +0100
|
|
|
|
+++ coreutils-8.21/src/install.c 2013-02-15 14:31:58.948469440 +0100
|
|
|
|
@@ -639,7 +640,7 @@ In the 4th form, create all components o
|
2011-04-14 10:30:24 +00:00
|
|
|
-v, --verbose print the name of each directory as it is created\n\
|
|
|
|
"), stdout);
|
|
|
|
fputs (_("\
|
|
|
|
- --preserve-context preserve SELinux security context\n\
|
2014-01-02 10:39:46 +00:00
|
|
|
+ -P, --preserve-context preserve SELinux security context (-P deprecated)\n\
|
2013-12-14 17:41:07 +00:00
|
|
|
-Z, --context[=CTX] set SELinux security context of destination file to\n\
|
|
|
|
default type, or to CTX if specified\n\
|
2011-04-14 10:30:24 +00:00
|
|
|
"), stdout);
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -782,7 +783,7 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
we'll actually use backup_suffix_string. */
|
|
|
|
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
|
|
|
|
2013-12-14 17:41:07 +00:00
|
|
|
- while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
|
|
|
|
+ while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pPt:TvS:Z", long_options,
|
2009-11-18 14:48:00 +00:00
|
|
|
NULL)) != -1)
|
|
|
|
{
|
|
|
|
switch (optc)
|
2013-12-16 08:42:12 +00:00
|
|
|
@@ -853,6 +854,8 @@ main (int argc, char **argv)
|
2011-04-14 10:30:24 +00:00
|
|
|
no_target_directory = true;
|
|
|
|
break;
|
|
|
|
|
2009-11-18 14:48:00 +00:00
|
|
|
+ case 'P':
|
2013-12-18 16:13:25 +00:00
|
|
|
+ fprintf (stderr, "%s: warning: option '-P' is deprecated, please use '--preserve-context' instead\n", argv[0]);
|
2009-11-18 14:48:00 +00:00
|
|
|
case PRESERVE_CONTEXT_OPTION:
|
2013-12-14 17:41:07 +00:00
|
|
|
if (! selinux_enabled)
|
2009-11-18 14:48:00 +00:00
|
|
|
{
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -860,6 +862,10 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
"this kernel is not SELinux-enabled"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
+ if ( x.set_security_context ) {
|
|
|
|
+ (void) fprintf(stderr, "%s: cannot force target context and preserve it\n", argv[0]);
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
x.preserve_security_context = true;
|
|
|
|
use_default_selinux_context = false;
|
|
|
|
break;
|
2013-02-15 16:50:47 +00:00
|
|
|
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
|
2009-11-18 14:48:00 +00:00
|
|
|
symbolic_link,
|
|
|
|
sock,
|
|
|
|
whiteout,
|
|
|
|
- arg_directory
|
|
|
|
+ arg_directory,
|
|
|
|
+ command_line
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Display letters and indicators for each filetype.
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -281,6 +282,7 @@ static void queue_directory (char const
|
2012-01-07 19:47:10 +00:00
|
|
|
bool command_line_arg);
|
2009-11-18 14:48:00 +00:00
|
|
|
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. */
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -350,7 +352,7 @@ static struct pending *pending_dirs;
|
2009-11-18 14:48:00 +00:00
|
|
|
|
|
|
|
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
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -390,7 +392,9 @@ enum format
|
2009-11-18 14:48:00 +00:00
|
|
|
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;
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -793,6 +797,9 @@ enum
|
2009-11-18 14:48:00 +00:00
|
|
|
SHOW_CONTROL_CHARS_OPTION,
|
|
|
|
SI_OPTION,
|
|
|
|
SORT_OPTION,
|
|
|
|
+ CONTEXT_OPTION,
|
|
|
|
+ LCONTEXT_OPTION,
|
|
|
|
+ SCONTEXT_OPTION,
|
|
|
|
TIME_OPTION,
|
|
|
|
TIME_STYLE_OPTION
|
|
|
|
};
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -839,7 +846,9 @@ static struct option const long_options[
|
2009-11-18 14:48:00 +00:00
|
|
|
{"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},
|
2008-01-25 17:48:11 +00:00
|
|
|
{GETOPT_HELP_OPTION_DECL},
|
|
|
|
{GETOPT_VERSION_OPTION_DECL},
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -849,12 +858,12 @@ static struct option const long_options[
|
2009-11-18 14:48:00 +00:00
|
|
|
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);
|
|
|
|
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -1296,7 +1305,8 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
/* 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
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -1343,7 +1353,7 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
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);
|
|
|
|
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -1363,7 +1373,7 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
|
|
|
|
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
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -1394,7 +1404,7 @@ main (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
}
|
|
|
|
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)
|
2011-09-09 11:16:47 +00:00
|
|
|
@@ -1565,7 +1575,7 @@ decode_switches (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
ignore_mode = IGNORE_DEFAULT;
|
|
|
|
ignore_patterns = NULL;
|
|
|
|
hide_patterns = NULL;
|
|
|
|
- print_scontext = false;
|
|
|
|
+ print_scontext = 0;
|
|
|
|
|
|
|
|
/* FIXME: put this in a function. */
|
|
|
|
{
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -1941,13 +1951,27 @@ decode_switches (int argc, char **argv)
|
2009-11-18 14:48:00 +00:00
|
|
|
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;
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
default:
|
|
|
|
usage (LS_FAILURE);
|
|
|
|
}
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -2883,6 +2907,7 @@ gobble_file (char const *name, enum file
|
2009-11-18 14:48:00 +00:00
|
|
|
memset (f, '\0', sizeof *f);
|
|
|
|
f->stat.st_ino = inode;
|
|
|
|
f->filetype = type;
|
|
|
|
+ f->scontext = NULL;
|
|
|
|
|
|
|
|
if (command_line_arg
|
|
|
|
|| format_needs_stat
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -2995,7 +3020,7 @@ gobble_file (char const *name, enum file
|
2009-11-27 13:24:09 +00:00
|
|
|
&& print_with_color && is_colored (C_CAP))
|
2012-03-26 16:23:32 +00:00
|
|
|
f->has_capability = has_capability_cache (absolute_name, f);
|
2009-11-18 14:48:00 +00:00
|
|
|
|
|
|
|
- if (format == long_format || print_scontext)
|
|
|
|
+ if (format == long_format || format == security_format || print_scontext)
|
|
|
|
{
|
2013-12-14 17:41:07 +00:00
|
|
|
bool have_scontext = false;
|
2009-11-18 14:48:00 +00:00
|
|
|
bool have_acl = false;
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3016,7 +3041,7 @@ gobble_file (char const *name, enum file
|
2009-11-18 14:48:00 +00:00
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (err == 0 && format == long_format)
|
|
|
|
+ if (err == 0 && (format == long_format || format == security_format))
|
|
|
|
{
|
2012-03-26 16:23:32 +00:00
|
|
|
int n = file_has_acl_cache (absolute_name, f);
|
2009-11-18 14:48:00 +00:00
|
|
|
err = (n < 0);
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3035,7 +3060,8 @@ gobble_file (char const *name, enum file
|
2009-11-18 14:48:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2012-05-11 07:58:08 +00:00
|
|
|
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3054,6 +3080,7 @@ gobble_file (char const *name, enum file
|
2009-11-18 14:48:00 +00:00
|
|
|
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
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3087,7 +3114,7 @@ gobble_file (char const *name, enum file
|
2009-11-18 14:48:00 +00:00
|
|
|
block_size_width = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (format == long_format)
|
|
|
|
+ if (format == long_format || format == security_format)
|
|
|
|
{
|
|
|
|
if (print_owner)
|
|
|
|
{
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3591,6 +3618,13 @@ print_current_files (void)
|
2009-11-18 14:48:00 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3753,6 +3787,67 @@ format_inode (char *buf, size_t buflen,
|
2009-11-18 14:48:00 +00:00
|
|
|
: (char *) "?");
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* Print info about f in scontext format */
|
2009-10-07 08:11:44 +00:00
|
|
|
+static void
|
2009-11-18 14:48:00 +00:00
|
|
|
+print_scontext_format (const struct fileinfo *f)
|
2009-10-07 08:11:44 +00:00
|
|
|
+{
|
2009-11-18 14:48:00 +00:00
|
|
|
+ char modebuf[12];
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ /* 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. */
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ char init_bigbuf[7 * LONGEST_HUMAN_READABLE + 10 + 9 + 1];
|
|
|
|
+ char *buf = init_bigbuf;
|
|
|
|
+ char *p;
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ p = buf;
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ 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';
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ /* print mode */
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ (void) sprintf (p, "%s ", modebuf);
|
|
|
|
+ p += strlen (p);
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ /* print standard user and group */
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ (void) sprintf (p, "%-32s ", f->scontext ?: "");
|
|
|
|
+ p += strlen (p);
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ DIRED_INDENT ();
|
|
|
|
+ DIRED_FPUTS (buf, stdout, p - buf);
|
2009-11-27 13:24:09 +00:00
|
|
|
+ size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf);
|
2009-10-07 08:11:44 +00:00
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
+ if (f->filetype == symbolic_link) {
|
|
|
|
+ if (f->linkname) {
|
|
|
|
+ DIRED_FPUTS_LITERAL (" -> ", stdout);
|
2009-11-27 13:24:09 +00:00
|
|
|
+ print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
|
2009-11-18 14:48:00 +00:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2009-10-07 08:11:44 +00:00
|
|
|
+}
|
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
/* Print information about F in long format. */
|
|
|
|
static void
|
|
|
|
print_long_format (const struct fileinfo *f)
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3844,9 +3939,15 @@ print_long_format (const struct fileinfo
|
2009-11-18 14:48:00 +00:00
|
|
|
The latter is wrong when nlink_width is zero. */
|
|
|
|
p += strlen (p);
|
|
|
|
|
|
|
|
+ if (print_scontext)
|
2009-10-07 08:11:44 +00:00
|
|
|
+ {
|
2009-11-18 14:48:00 +00:00
|
|
|
+ sprintf (p, "%-32s ", f->scontext ? f->scontext : "");
|
|
|
|
+ p += strlen (p);
|
2009-10-07 08:11:44 +00:00
|
|
|
+ }
|
|
|
|
+
|
2009-11-18 14:48:00 +00:00
|
|
|
DIRED_INDENT ();
|
|
|
|
|
|
|
|
- if (print_owner || print_group || print_author || print_scontext)
|
|
|
|
+ if (print_owner || print_group || print_author)
|
|
|
|
{
|
|
|
|
DIRED_FPUTS (buf, stdout, p - buf);
|
|
|
|
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -3859,9 +3960,6 @@ print_long_format (const struct fileinfo
|
2009-11-18 14:48:00 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -4207,9 +4305,6 @@ print_file_name_and_frills (const struct
|
2009-11-18 14:48:00 +00:00
|
|
|
: 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);
|
|
|
|
-
|
2009-11-27 13:24:09 +00:00
|
|
|
size_t width = print_name_with_quoting (f, false, NULL, start_col);
|
|
|
|
|
|
|
|
if (indicator_style != none)
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -4417,9 +4512,6 @@ length_of_file_name_and_frills (const st
|
2009-11-18 14:48:00 +00:00
|
|
|
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;
|
|
|
|
|
2013-02-15 16:50:47 +00:00
|
|
|
@@ -4856,9 +4948,16 @@ Sort entries alphabetically if none of -
|
2009-11-18 14:48:00 +00:00
|
|
|
-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 ();
|
2013-02-15 16:50:47 +00:00
|
|
|
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
|
2011-01-04 16:59:58 +00:00
|
|
|
@@ -37,7 +37,7 @@ chcon $ctx f d p ||
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
# inspect that context with both ls -Z and stat.
|
|
|
|
for i in d f p; do
|
2012-05-11 07:58:08 +00:00
|
|
|
- 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
|
2008-01-25 17:48:11 +00:00
|
|
|
done
|
2009-01-28 17:29:41 +00:00
|
|
|
|