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