2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/configure.ac coreutils-7.1/configure.ac
|
|
|
|
--- coreutils-7.1-orig/configure.ac 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
+++ coreutils-7.1/configure.ac 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -84,6 +84,13 @@ AC_ARG_ENABLE(pam, dnl
|
2008-01-25 17:48:11 +00:00
|
|
|
LIB_PAM="-ldl -lpam -lpam_misc"
|
|
|
|
AC_SUBST(LIB_PAM)])
|
|
|
|
|
|
|
|
+dnl Give the chance to enable SELINUX
|
|
|
|
+AC_ARG_ENABLE(selinux, dnl
|
|
|
|
+[ --enable-selinux Enable use of the SELINUX libraries],
|
|
|
|
+[AC_DEFINE(WITH_SELINUX, 1, [Define if you want to use SELINUX])
|
|
|
|
+LIB_SELINUX="-lselinux"
|
|
|
|
+AC_SUBST(LIB_SELINUX)])
|
|
|
|
+
|
|
|
|
AC_FUNC_FORK
|
|
|
|
|
|
|
|
optional_bin_progs=
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/man/chcon.x coreutils-7.1/man/chcon.x
|
|
|
|
--- coreutils-7.1-orig/man/chcon.x 2008-09-18 09:06:57.000000000 +0200
|
|
|
|
+++ coreutils-7.1/man/chcon.x 2009-02-24 13:47:15.000000000 +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
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/man/runcon.x coreutils-7.1/man/runcon.x
|
|
|
|
--- coreutils-7.1-orig/man/runcon.x 2008-09-18 09:06:57.000000000 +0200
|
|
|
|
+++ coreutils-7.1/man/runcon.x 2009-02-24 13:47:15.000000000 +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,
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/copy.c coreutils-7.1/src/copy.c
|
|
|
|
--- coreutils-7.1-orig/src/copy.c 2009-02-18 15:32:52.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/copy.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -1830,6 +1830,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
|
|
|
{
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/copy.h coreutils-7.1/src/copy.h
|
|
|
|
--- coreutils-7.1-orig/src/copy.h 2009-02-18 15:32:52.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/copy.h 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -140,6 +140,9 @@ struct cp_options
|
2008-01-25 17:48:11 +00:00
|
|
|
bool preserve_mode;
|
|
|
|
bool preserve_timestamps;
|
|
|
|
|
|
|
|
+ /* If true, attempt to set specified security context */
|
|
|
|
+ bool set_security_context;
|
|
|
|
+
|
|
|
|
/* Enabled for mv, and for cp by the --preserve=links option.
|
|
|
|
If true, attempt to preserve in the destination files any
|
|
|
|
logical hard links between the source files. If used with cp's
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/cp.c coreutils-7.1/src/cp.c
|
|
|
|
--- coreutils-7.1-orig/src/cp.c 2009-02-18 15:32:52.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/cp.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -133,6 +133,7 @@ static struct option const long_opts[] =
|
2008-01-25 17:48:11 +00:00
|
|
|
{"target-directory", required_argument, NULL, 't'},
|
|
|
|
{"update", no_argument, NULL, 'u'},
|
|
|
|
{"verbose", no_argument, NULL, 'v'},
|
|
|
|
+ {"context", required_argument, NULL, 'Z'},
|
|
|
|
{GETOPT_HELP_OPTION_DECL},
|
|
|
|
{GETOPT_VERSION_OPTION_DECL},
|
|
|
|
{NULL, 0, NULL, 0}
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -191,6 +192,9 @@ Mandatory arguments to long options are
|
2009-01-28 17:29:41 +00:00
|
|
|
all\n\
|
2008-01-25 17:48:11 +00:00
|
|
|
"), stdout);
|
|
|
|
fputs (_("\
|
|
|
|
+ -c same as --preserve=context\n\
|
|
|
|
+"), stdout);
|
|
|
|
+ fputs (_("\
|
|
|
|
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\
|
|
|
|
--parents use full source file name under DIRECTORY\n\
|
|
|
|
"), stdout);
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -216,6 +220,7 @@ Mandatory arguments to long options are
|
2008-01-25 17:48:11 +00:00
|
|
|
destination file is missing\n\
|
|
|
|
-v, --verbose explain what is being done\n\
|
|
|
|
-x, --one-file-system stay on this file system\n\
|
|
|
|
+ -Z, --context=CONTEXT set security context of copy to CONTEXT\n\
|
|
|
|
"), stdout);
|
|
|
|
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
|
|
|
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -765,6 +770,7 @@ cp_option_init (struct cp_options *x)
|
2008-01-25 17:48:11 +00:00
|
|
|
x->preserve_timestamps = false;
|
|
|
|
x->preserve_security_context = false;
|
|
|
|
x->require_preserve_context = false;
|
|
|
|
+ x->set_security_context = false;
|
2009-01-28 17:29:41 +00:00
|
|
|
x->preserve_xattr = false;
|
2009-02-24 16:34:43 +00:00
|
|
|
x->reduce_diagnostics = false;
|
2009-01-28 17:29:41 +00:00
|
|
|
x->require_preserve_xattr = false;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -911,7 +917,7 @@ main (int argc, char **argv)
|
2008-01-25 17:48:11 +00:00
|
|
|
we'll actually use backup_suffix_string. */
|
|
|
|
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2009-01-28 17:29:41 +00:00
|
|
|
- while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:T",
|
|
|
|
+ while ((c = getopt_long (argc, argv, "abcdfHilLnprst:uvxPRS:TZ:",
|
2009-09-12 09:28:49 +00:00
|
|
|
long_opts, NULL))
|
|
|
|
!= -1)
|
2008-01-25 17:48:11 +00:00
|
|
|
{
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -945,6 +951,16 @@ main (int argc, char **argv)
|
2009-09-12 09:28:49 +00:00
|
|
|
copy_contents = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
+ case 'c':
|
|
|
|
+ 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;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -1054,6 +1070,27 @@ main (int argc, char **argv)
|
2009-09-12 09:28:49 +00:00
|
|
|
x.one_file_system = true;
|
|
|
|
break;
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2004-12-27 13:37:11 +00:00
|
|
|
+
|
2009-09-12 09:28:49 +00:00
|
|
|
+ case 'Z':
|
|
|
|
+ /* politely decline if we're not on a selinux-enabled kernel. */
|
|
|
|
+ if( !selinux_enabled ) {
|
|
|
|
+ fprintf( stderr, "Warning: ignoring --context (-Z). "
|
|
|
|
+ "It requires a SELinux enabled kernel.\n" );
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ if ( x.preserve_security_context ) {
|
|
|
|
+ (void) fprintf(stderr, "%s: cannot force target context to '%s' and preserve it\n", argv[0], optarg);
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+ x.set_security_context = true;
|
|
|
|
+ /* if there's a security_context given set new path
|
|
|
|
+ components to that context, too */
|
|
|
|
+ if ( setfscreatecon(optarg) < 0 ) {
|
|
|
|
+ (void) fprintf(stderr, _("cannot set default security context %s\n"), optarg);
|
|
|
|
+ exit( 1 );
|
|
|
|
+ }
|
|
|
|
+ break;
|
2004-12-27 13:37:11 +00:00
|
|
|
+
|
2009-09-12 09:28:49 +00:00
|
|
|
case 'S':
|
|
|
|
make_backups = true;
|
|
|
|
backup_suffix_string = optarg;
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/chcon.c coreutils-7.1/src/chcon.c
|
|
|
|
--- coreutils-7.1-orig/src/chcon.c 2008-10-12 16:12:56.000000000 +0200
|
|
|
|
+++ coreutils-7.1/src/chcon.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -346,7 +346,7 @@ Usage: %s [OPTION]... CONTEXT FILE...\n\
|
|
|
|
"),
|
2009-09-12 09:28:49 +00:00
|
|
|
program_name, program_name, program_name);
|
2009-02-24 16:34:43 +00:00
|
|
|
fputs (_("\
|
|
|
|
-Change the security context of each FILE to CONTEXT.\n\
|
|
|
|
+Change the SELinux security context of each FILE to CONTEXT.\n\
|
|
|
|
With --reference, change the security context of each FILE to that of RFILE.\n\
|
|
|
|
\n\
|
|
|
|
-h, --no-dereference affect symbolic links instead of any referenced file\n\
|
|
|
|
diff -urNp coreutils-7.1-orig/src/id.c coreutils-7.1/src/id.c
|
|
|
|
--- coreutils-7.1-orig/src/id.c 2009-02-16 15:57:44.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/id.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -107,7 +107,7 @@ int
|
2008-01-25 17:48:11 +00:00
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int optc;
|
|
|
|
- int selinux_enabled = (is_selinux_enabled () > 0);
|
|
|
|
+ bool selinux_enabled = (is_selinux_enabled () > 0);
|
|
|
|
|
|
|
|
/* If true, output the list of all group IDs. -G */
|
|
|
|
bool just_group_list = false;
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/install.c coreutils-7.1/src/install.c
|
|
|
|
--- coreutils-7.1-orig/src/install.c 2009-02-18 15:32:52.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/install.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -292,6 +292,7 @@ cp_option_init (struct cp_options *x)
|
|
|
|
x->reduce_diagnostics=false;
|
2008-01-25 17:48:11 +00:00
|
|
|
x->require_preserve = false;
|
|
|
|
x->require_preserve_context = false;
|
|
|
|
+ x->set_security_context = false;
|
2009-02-24 11:53:38 +00:00
|
|
|
x->require_preserve_xattr = false;
|
2008-01-25 17:48:11 +00:00
|
|
|
x->recursive = false;
|
|
|
|
x->sparse_mode = SPARSE_AUTO;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -469,7 +470,7 @@ main (int argc, char **argv)
|
2008-02-18 14:37:04 +00:00
|
|
|
we'll actually use backup_suffix_string. */
|
|
|
|
backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
|
|
|
|
|
2009-02-24 11:53:38 +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-09-12 09:28:49 +00:00
|
|
|
NULL)) != -1)
|
2008-02-18 14:37:04 +00:00
|
|
|
{
|
|
|
|
switch (optc)
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -539,6 +540,7 @@ main (int argc, char **argv)
|
2009-09-12 09:28:49 +00:00
|
|
|
error (0, 0, _("WARNING: --preserve_context is deprecated; "
|
|
|
|
"use --preserve-context instead"));
|
|
|
|
/* fall through */
|
|
|
|
+ case 'P':
|
|
|
|
case PRESERVE_CONTEXT_OPTION:
|
|
|
|
if ( ! selinux_enabled)
|
|
|
|
{
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -546,6 +548,10 @@ main (int argc, char **argv)
|
2009-09-12 09:28:49 +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;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -557,6 +563,7 @@ main (int argc, char **argv)
|
2009-09-12 09:28:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
scontext = optarg;
|
|
|
|
+ x.set_security_context = true;
|
|
|
|
use_default_selinux_context = false;
|
|
|
|
break;
|
|
|
|
case_GETOPT_HELP_CHAR;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -990,8 +997,8 @@ Mandatory arguments to long options are
|
2008-01-25 17:48:11 +00:00
|
|
|
-v, --verbose print the name of each directory as it is created\n\
|
|
|
|
"), stdout);
|
|
|
|
fputs (_("\
|
|
|
|
- --preserve-context preserve SELinux security context\n\
|
|
|
|
- -Z, --context=CONTEXT set SELinux security context of files and directories\n\
|
|
|
|
+ -P, --preserve-context (SELinux) preserve security context\n\
|
|
|
|
+ -Z, --context=CONTEXT (SELinux) set security context of files and directories\n\
|
|
|
|
"), stdout);
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/ls.c coreutils-7.1/src/ls.c
|
|
|
|
--- coreutils-7.1-orig/src/ls.c 2009-02-20 19:34:02.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/ls.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -136,7 +136,8 @@ enum filetype
|
2007-01-09 19:29:30 +00:00
|
|
|
symbolic_link,
|
|
|
|
sock,
|
|
|
|
whiteout,
|
|
|
|
- arg_directory
|
|
|
|
+ arg_directory,
|
|
|
|
+ command_line
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Display letters and indicators for each filetype.
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -253,6 +254,7 @@ static void queue_directory (char const
|
2007-01-09 19:29:30 +00:00
|
|
|
static void sort_files (void);
|
|
|
|
static void parse_ls_color (void);
|
|
|
|
void usage (int status);
|
|
|
|
+static void print_scontext_format (const struct fileinfo *f);
|
|
|
|
|
2008-11-11 16:03:49 +00:00
|
|
|
/* Initial size of hash table.
|
|
|
|
Most hierarchies are likely to be shallower than this. */
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -322,7 +324,7 @@ static struct pending *pending_dirs;
|
2008-07-16 14:22:18 +00:00
|
|
|
|
|
|
|
static struct timespec current_time;
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
-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
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -362,7 +364,9 @@ enum format
|
2007-01-09 19:29:30 +00:00
|
|
|
one_per_line, /* -1 */
|
|
|
|
many_per_line, /* -C */
|
|
|
|
horizontal, /* -x */
|
|
|
|
- with_commas /* -m */
|
2008-01-25 17:48:11 +00:00
|
|
|
+ with_commas, /* -m */
|
|
|
|
+ security_format, /* -Z */
|
2007-01-09 19:29:30 +00:00
|
|
|
+ invalid_format
|
|
|
|
};
|
|
|
|
|
|
|
|
static enum format format;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -754,6 +758,9 @@ enum
|
2007-01-09 19:29:30 +00:00
|
|
|
SHOW_CONTROL_CHARS_OPTION,
|
|
|
|
SI_OPTION,
|
|
|
|
SORT_OPTION,
|
|
|
|
+ CONTEXT_OPTION,
|
|
|
|
+ LCONTEXT_OPTION,
|
|
|
|
+ SCONTEXT_OPTION,
|
|
|
|
TIME_OPTION,
|
|
|
|
TIME_STYLE_OPTION
|
|
|
|
};
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -799,7 +806,9 @@ static struct option const long_options[
|
2007-01-09 19:29:30 +00:00
|
|
|
{"time-style", required_argument, NULL, TIME_STYLE_OPTION},
|
|
|
|
{"color", optional_argument, NULL, COLOR_OPTION},
|
|
|
|
{"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
|
2008-01-25 17:48:11 +00:00
|
|
|
- {"context", no_argument, 0, 'Z'},
|
2007-01-09 19:29:30 +00:00
|
|
|
+ {"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},
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -809,12 +818,12 @@ static struct option const long_options[
|
2007-01-09 19:29:30 +00:00
|
|
|
static char const *const format_args[] =
|
|
|
|
{
|
|
|
|
"verbose", "long", "commas", "horizontal", "across",
|
|
|
|
- "vertical", "single-column", NULL
|
2008-01-25 17:48:11 +00:00
|
|
|
+ "vertical", "single-column", "context", NULL
|
2007-01-09 19:29:30 +00:00
|
|
|
};
|
|
|
|
static enum format const format_types[] =
|
|
|
|
{
|
|
|
|
long_format, long_format, with_commas, horizontal, horizontal,
|
2008-01-25 17:48:11 +00:00
|
|
|
- many_per_line, one_per_line
|
|
|
|
+ many_per_line, one_per_line, security_format
|
2007-01-09 19:29:30 +00:00
|
|
|
};
|
|
|
|
ARGMATCH_VERIFY (format_args, format_types);
|
|
|
|
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -1194,7 +1203,8 @@ main (int argc, char **argv)
|
|
|
|
/* Avoid following symbolic links when possible. */
|
|
|
|
if (is_colored (C_ORPHAN)
|
2009-09-12 09:28:49 +00:00
|
|
|
|| (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;
|
2009-02-26 13:44:18 +00:00
|
|
|
|
|
|
|
/* If the standard output is a controlling terminal, watch out
|
|
|
|
@@ -1241,7 +1251,7 @@ main (int argc, char **argv)
|
|
|
|
if (dereference == DEREF_UNDEFINED)
|
|
|
|
dereference = ((immediate_dirs
|
2009-09-12 09:28:49 +00:00
|
|
|
|| indicator_style == classify
|
|
|
|
- || format == long_format)
|
|
|
|
+ || format == long_format || format == security_format)
|
|
|
|
? DEREF_NEVER
|
|
|
|
: DEREF_COMMAND_LINE_SYMLINK_TO_DIR);
|
2009-02-26 13:44:18 +00:00
|
|
|
|
|
|
|
@@ -1261,7 +1271,7 @@ main (int argc, char **argv)
|
2007-01-09 19:29:30 +00:00
|
|
|
|
|
|
|
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|
|
|
|
|| format == long_format
|
2008-01-25 17:48:11 +00:00
|
|
|
- || print_scontext
|
2007-01-09 19:29:30 +00:00
|
|
|
+ || format == security_format || print_scontext
|
|
|
|
|| print_block_size;
|
|
|
|
format_needs_type = (! format_needs_stat
|
2009-09-12 09:28:49 +00:00
|
|
|
&& (recursive
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -1292,7 +1302,7 @@ main (int argc, char **argv)
|
2007-01-09 19:29:30 +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);
|
|
|
|
|
2007-03-01 17:36:24 +00:00
|
|
|
if (cwd_n_used)
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -1455,7 +1465,7 @@ decode_switches (int argc, char **argv)
|
2007-01-09 19:29:30 +00:00
|
|
|
ignore_mode = IGNORE_DEFAULT;
|
|
|
|
ignore_patterns = NULL;
|
|
|
|
hide_patterns = NULL;
|
2008-01-25 17:48:11 +00:00
|
|
|
- print_scontext = false;
|
|
|
|
+ print_scontext = 0;
|
2007-01-09 19:29:30 +00:00
|
|
|
|
|
|
|
/* FIXME: put this in a function. */
|
|
|
|
{
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -1837,13 +1847,27 @@ decode_switches (int argc, char **argv)
|
2009-09-12 09:28:49 +00:00
|
|
|
break;
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2009-09-12 09:28:49 +00:00
|
|
|
case 'Z':
|
|
|
|
- print_scontext = true;
|
|
|
|
+ print_scontext = 1;
|
2008-01-25 17:48:11 +00:00
|
|
|
+ format = security_format;
|
2009-09-12 09:28:49 +00:00
|
|
|
break;
|
2008-01-25 17:48:11 +00:00
|
|
|
|
2009-09-12 09:28:49 +00:00
|
|
|
case_GETOPT_HELP_CHAR;
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2009-09-12 09:28:49 +00:00
|
|
|
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
+ case CONTEXT_OPTION: /* default security context format */
|
2009-09-12 09:28:49 +00:00
|
|
|
+ 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;
|
2006-03-24 13:48:34 +00:00
|
|
|
+
|
2009-09-12 09:28:49 +00:00
|
|
|
default:
|
|
|
|
usage (LS_FAILURE);
|
|
|
|
}
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2557,8 +2581,10 @@ clear_files (void)
|
2007-03-01 17:36:24 +00:00
|
|
|
struct fileinfo *f = sorted_file[i];
|
|
|
|
free (f->name);
|
|
|
|
free (f->linkname);
|
2008-01-25 17:48:11 +00:00
|
|
|
- if (f->scontext != UNKNOWN_SECURITY_CONTEXT)
|
2009-09-12 09:28:49 +00:00
|
|
|
- freecon (f->scontext);
|
2008-01-25 17:48:11 +00:00
|
|
|
+ if (f->scontext != UNKNOWN_SECURITY_CONTEXT) {
|
2009-09-12 09:28:49 +00:00
|
|
|
+ freecon (f->scontext);
|
2008-01-25 17:48:11 +00:00
|
|
|
+ f->scontext = NULL;
|
|
|
|
+ }
|
2007-01-09 19:29:30 +00:00
|
|
|
}
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
cwd_n_used = 0;
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2600,6 +2626,7 @@ gobble_file (char const *name, enum file
|
2007-01-09 19:29:30 +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
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2699,7 +2726,7 @@ gobble_file (char const *name, enum file
|
2008-01-25 17:48:11 +00:00
|
|
|
|
2007-01-10 14:13:03 +00:00
|
|
|
f->stat_ok = true;
|
2007-01-09 19:29:30 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
- if (format == long_format || print_scontext)
|
2008-06-04 17:56:55 +00:00
|
|
|
+ if (format == long_format || format == security_format || print_scontext)
|
2009-09-12 09:28:49 +00:00
|
|
|
{
|
|
|
|
bool have_selinux = false;
|
|
|
|
bool have_acl = false;
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2732,7 +2760,7 @@ gobble_file (char const *name, enum file
|
2009-09-12 09:28:49 +00:00
|
|
|
err = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (err == 0 && format == long_format)
|
|
|
|
+ if (err == 0 && (format == long_format || format == security_format))
|
|
|
|
{
|
|
|
|
int n = file_has_acl (absolute_name, &f->stat);
|
|
|
|
err = (n < 0);
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2751,7 +2779,8 @@ gobble_file (char const *name, enum file
|
2009-09-12 09:28:49 +00:00
|
|
|
}
|
2009-02-26 13:44:18 +00:00
|
|
|
|
|
|
|
if (S_ISLNK (f->stat.st_mode)
|
2009-09-12 09:28:49 +00:00
|
|
|
- && (format == long_format || check_symlink_color))
|
|
|
|
+ && (format == long_format || format == security_format
|
|
|
|
+ || check_symlink_color))
|
|
|
|
{
|
|
|
|
char *linkname;
|
|
|
|
struct stat linkstats;
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2771,6 +2800,7 @@ gobble_file (char const *name, enum file
|
2009-09-12 09:28:49 +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
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -2810,7 +2840,7 @@ gobble_file (char const *name, enum file
|
2009-09-12 09:28:49 +00:00
|
|
|
block_size_width = len;
|
|
|
|
}
|
2009-02-26 13:44:18 +00:00
|
|
|
|
|
|
|
- if (format == long_format)
|
|
|
|
+ if (format == long_format || format == security_format)
|
2009-09-12 09:28:49 +00:00
|
|
|
{
|
|
|
|
if (print_owner)
|
|
|
|
{
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -3312,6 +3341,13 @@ print_current_files (void)
|
2009-09-12 09:28:49 +00:00
|
|
|
print_long_format (sorted_file[i]);
|
|
|
|
DIRED_PUTCHAR ('\n');
|
|
|
|
}
|
2008-01-25 17:48:11 +00:00
|
|
|
+ break;
|
2007-01-09 19:29:30 +00:00
|
|
|
+ case security_format:
|
2007-03-01 17:36:24 +00:00
|
|
|
+ for (i = 0; i < cwd_n_used; i++)
|
2007-01-09 19:29:30 +00:00
|
|
|
+ {
|
2007-03-01 17:36:24 +00:00
|
|
|
+ print_scontext_format (sorted_file[i]);
|
2007-01-09 19:29:30 +00:00
|
|
|
+ DIRED_PUTCHAR ('\n');
|
|
|
|
+ }
|
2008-01-25 17:48:11 +00:00
|
|
|
break;
|
2007-01-09 19:29:30 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -3434,6 +3470,69 @@ format_group_width (gid_t g)
|
2009-02-24 16:34:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+/* 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->name, FILE_OR_LINK_MODE(f), f->linkok,
|
2009-09-12 09:28:49 +00:00
|
|
|
+ f->stat_ok, f->filetype, &dired_obstack, f->stat.st_nlink, p - buf);
|
2009-02-24 16:34:43 +00:00
|
|
|
+
|
|
|
|
+ if (f->filetype == symbolic_link) {
|
|
|
|
+ if (f->linkname) {
|
2009-09-12 09:28:49 +00:00
|
|
|
+ DIRED_FPUTS_LITERAL (" -> ", stdout);
|
|
|
|
+ print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
|
|
|
|
+ f->stat_ok, f->filetype, NULL, f->stat.st_nlink, (p-buf) + w + 4 );
|
|
|
|
+ if (indicator_style != none)
|
|
|
|
+ print_type_indicator (f->stat_ok, f->linkmode, f->filetype);
|
2009-02-24 16:34:43 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -3528,9 +3627,15 @@ print_long_format (const struct fileinfo
|
2007-01-09 19:29:30 +00:00
|
|
|
The latter is wrong when nlink_width is zero. */
|
|
|
|
p += strlen (p);
|
|
|
|
|
|
|
|
+ if (print_scontext)
|
2006-03-24 13:48:34 +00:00
|
|
|
+ {
|
2007-01-09 19:29:30 +00:00
|
|
|
+ sprintf (p, "%-32s ", f->scontext ? f->scontext : "");
|
|
|
|
+ p += strlen (p);
|
2006-03-24 13:48:34 +00:00
|
|
|
+ }
|
|
|
|
+
|
2007-01-09 19:29:30 +00:00
|
|
|
DIRED_INDENT ();
|
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
- if (print_owner | print_group | print_author | print_scontext)
|
|
|
|
+ if (print_owner | print_group | print_author)
|
|
|
|
{
|
|
|
|
DIRED_FPUTS (buf, stdout, p - buf);
|
|
|
|
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -3543,9 +3648,6 @@ print_long_format (const struct fileinfo
|
2008-01-25 17:48:11 +00:00
|
|
|
if (print_author)
|
2009-09-12 09:28:49 +00:00
|
|
|
format_user (f->stat.st_author, author_width, f->stat_ok);
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
- if (print_scontext)
|
2009-09-12 09:28:49 +00:00
|
|
|
- format_user_or_group (f->scontext, 0, scontext_width);
|
2008-01-25 17:48:11 +00:00
|
|
|
-
|
|
|
|
p = buf;
|
|
|
|
}
|
|
|
|
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -3888,9 +3990,6 @@ print_file_name_and_frills (const struct
|
2009-09-12 09:28:49 +00:00
|
|
|
human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
|
|
|
|
ST_NBLOCKSIZE, output_block_size));
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
- if (print_scontext)
|
|
|
|
- printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
|
|
|
|
-
|
2009-02-24 11:53:38 +00:00
|
|
|
size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f),
|
2009-09-12 09:28:49 +00:00
|
|
|
f->linkok, f->stat_ok, f->filetype,
|
|
|
|
NULL, f->stat.st_nlink, start_col);
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -4105,9 +4204,6 @@ length_of_file_name_and_frills (const st
|
2009-09-12 09:28:49 +00:00
|
|
|
output_block_size))
|
|
|
|
: block_size_width);
|
2008-01-25 17:48:11 +00:00
|
|
|
|
|
|
|
- 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;
|
|
|
|
|
2009-02-26 13:44:18 +00:00
|
|
|
@@ -4538,9 +4634,16 @@ Mandatory arguments to long options are
|
2008-01-25 17:48:11 +00:00
|
|
|
-w, --width=COLS assume screen width instead of current value\n\
|
|
|
|
-x list entries by lines instead of by columns\n\
|
2007-01-09 19:29:30 +00:00
|
|
|
-X sort alphabetically by entry extension\n\
|
2008-01-25 17:48:11 +00:00
|
|
|
- -Z, --context print any SELinux security context of each file\n\
|
2007-01-09 19:29:30 +00:00
|
|
|
-1 list one file per line\n\
|
|
|
|
"), stdout);
|
2008-10-22 11:07:44 +00:00
|
|
|
+ fputs(_("\nSELinux options:\n\n\
|
2008-01-25 17:48:11 +00:00
|
|
|
+ --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);
|
2007-01-09 19:29:30 +00:00
|
|
|
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
|
|
|
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
2009-09-12 09:28:49 +00:00
|
|
|
emit_size_note ();
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/mkdir.c coreutils-7.1/src/mkdir.c
|
|
|
|
--- coreutils-7.1-orig/src/mkdir.c 2008-10-19 21:47:57.000000000 +0200
|
|
|
|
+++ coreutils-7.1/src/mkdir.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -38,6 +38,7 @@
|
2008-01-25 17:48:11 +00:00
|
|
|
static struct option const longopts[] =
|
|
|
|
{
|
|
|
|
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
2006-03-24 13:48:34 +00:00
|
|
|
+ {"context", required_argument, NULL, 'Z'},
|
2008-01-25 17:48:11 +00:00
|
|
|
{"mode", required_argument, NULL, 'm'},
|
|
|
|
{"parents", no_argument, NULL, 'p'},
|
|
|
|
{"verbose", no_argument, NULL, 'v'},
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/mknod.c coreutils-7.1/src/mknod.c
|
|
|
|
--- coreutils-7.1-orig/src/mknod.c 2008-09-22 16:01:21.000000000 +0200
|
|
|
|
+++ coreutils-7.1/src/mknod.c 2009-02-24 13:47:15.000000000 +0100
|
2009-01-28 17:29:41 +00:00
|
|
|
@@ -35,7 +35,7 @@
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
static struct option const longopts[] =
|
|
|
|
{
|
|
|
|
- {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
|
|
|
+ {GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
|
|
|
{"mode", required_argument, NULL, 'm'},
|
|
|
|
{GETOPT_HELP_OPTION_DECL},
|
|
|
|
{GETOPT_VERSION_OPTION_DECL},
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/mv.c coreutils-7.1/src/mv.c
|
|
|
|
--- coreutils-7.1-orig/src/mv.c 2009-02-18 15:32:52.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/mv.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -122,6 +122,7 @@ cp_option_init (struct cp_options *x)
|
2008-01-25 17:48:11 +00:00
|
|
|
x->preserve_mode = true;
|
|
|
|
x->preserve_timestamps = true;
|
|
|
|
x->preserve_security_context = selinux_enabled;
|
|
|
|
+ x->set_security_context = false;
|
2009-02-24 11:53:38 +00:00
|
|
|
x->reduce_diagnostics = false;
|
2008-01-25 17:48:11 +00:00
|
|
|
x->require_preserve = false; /* FIXME: maybe make this an option */
|
|
|
|
x->require_preserve_context = false;
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/runcon.c coreutils-7.1/src/runcon.c
|
|
|
|
--- coreutils-7.1-orig/src/runcon.c 2008-09-18 09:06:57.000000000 +0200
|
|
|
|
+++ coreutils-7.1/src/runcon.c 2009-02-24 13:47:15.000000000 +0100
|
2009-01-28 17:29:41 +00:00
|
|
|
@@ -86,7 +86,7 @@ Usage: %s CONTEXT COMMAND [args]\n\
|
2008-10-22 11:07:44 +00:00
|
|
|
or: %s [ -c ] [-u USER] [-r ROLE] [-t TYPE] [-l RANGE] COMMAND [args]\n\
|
|
|
|
"), program_name, program_name);
|
|
|
|
fputs (_("\
|
|
|
|
-Run a program in a different security context.\n\
|
|
|
|
+Run a program in a different SELinux security context.\n\
|
|
|
|
With neither CONTEXT nor COMMAND, print the current security context.\n\
|
|
|
|
\n\
|
|
|
|
CONTEXT Complete security context\n\
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/src/stat.c coreutils-7.1/src/stat.c
|
|
|
|
--- coreutils-7.1-orig/src/stat.c 2009-01-27 22:11:25.000000000 +0100
|
|
|
|
+++ coreutils-7.1/src/stat.c 2009-02-24 13:47:15.000000000 +0100
|
|
|
|
@@ -825,7 +825,7 @@ print_it (char const *format, char const
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
/* Stat the file system and print what we find. */
|
|
|
|
static bool
|
|
|
|
-do_statfs (char const *filename, bool terse, char const *format)
|
|
|
|
+do_statfs (char const *filename, bool terse, bool secure, char const *format)
|
|
|
|
{
|
|
|
|
STRUCT_STATVFS statfsbuf;
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -837,15 +837,31 @@ do_statfs (char const *filename, bool te
|
2008-01-25 17:48:11 +00:00
|
|
|
}
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
if (format == NULL)
|
|
|
|
+ {
|
|
|
|
+ if (terse)
|
2006-03-24 13:48:34 +00:00
|
|
|
{
|
2008-01-25 17:48:11 +00:00
|
|
|
- format = (terse
|
2009-09-12 09:28:49 +00:00
|
|
|
- ? "%n %i %l %t %s %S %b %f %a %c %d\n"
|
|
|
|
- : " File: \"%n\"\n"
|
|
|
|
- " ID: %-8i Namelen: %-7l Type: %T\n"
|
|
|
|
- "Block size: %-10s Fundamental block size: %S\n"
|
|
|
|
- "Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
|
|
|
- "Inodes: Total: %-10c Free: %d\n");
|
2008-01-25 17:48:11 +00:00
|
|
|
+ if (secure)
|
|
|
|
+ format = "%n %i %l %t %s %S %b %f %a %c %d %C\n";
|
2009-09-12 09:28:49 +00:00
|
|
|
+ else
|
|
|
|
+ format = "%n %i %l %t %s %S %b %f %a %c %d\n";
|
2008-01-25 17:48:11 +00:00
|
|
|
}
|
|
|
|
+ else
|
2009-09-12 09:28:49 +00:00
|
|
|
+ {
|
|
|
|
+ if (secure)
|
|
|
|
+ format = " File: \"%n\"\n"
|
|
|
|
+ " ID: %-8i Namelen: %-7l Type: %T\n"
|
|
|
|
+ "Block size: %-10s Fundamental block size: %S\n"
|
|
|
|
+ "Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
|
|
|
+ "Inodes: Total: %-10c Free: %d\n"
|
|
|
|
+ " S_Context: %C\n";
|
|
|
|
+ else
|
|
|
|
+ format = " File: \"%n\"\n"
|
|
|
|
+ " ID: %-8i Namelen: %-7l Type: %T\n"
|
|
|
|
+ "Block size: %-10s Fundamental block size: %S\n"
|
|
|
|
+ "Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
|
|
|
+ "Inodes: Total: %-10c Free: %d\n";
|
2008-01-25 17:48:11 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2006-10-04 11:18:28 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
print_it (format, filename, print_statfs, &statfsbuf);
|
|
|
|
return true;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -853,7 +869,7 @@ do_statfs (char const *filename, bool te
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2008-01-25 17:48:11 +00:00
|
|
|
/* stat the file and print what we find */
|
|
|
|
static bool
|
|
|
|
-do_stat (char const *filename, bool terse, char const *format)
|
2008-03-06 12:21:32 +00:00
|
|
|
+do_stat (char const *filename, bool terse, bool secure, char const *format)
|
2008-01-25 17:48:11 +00:00
|
|
|
{
|
|
|
|
struct stat statbuf;
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -866,9 +882,12 @@ do_stat (char const *filename, bool ters
|
2008-01-25 17:48:11 +00:00
|
|
|
if (format == NULL)
|
|
|
|
{
|
|
|
|
if (terse)
|
2009-09-12 09:28:49 +00:00
|
|
|
- {
|
|
|
|
- format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n";
|
|
|
|
- }
|
2008-01-25 17:48:11 +00:00
|
|
|
+ {
|
|
|
|
+ if (secure)
|
2009-09-12 09:28:49 +00:00
|
|
|
+ format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n";
|
|
|
|
+ else
|
|
|
|
+ format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n";
|
2008-01-25 17:48:11 +00:00
|
|
|
+ }
|
|
|
|
else
|
2009-09-12 09:28:49 +00:00
|
|
|
{
|
|
|
|
/* Temporary hack to match original output until conditional
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -885,12 +904,22 @@ do_stat (char const *filename, bool ters
|
2009-09-12 09:28:49 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
- format =
|
|
|
|
- " File: %N\n"
|
|
|
|
- " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
- "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
|
|
|
- "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
- "Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
2008-01-25 17:48:11 +00:00
|
|
|
+ if (secure)
|
|
|
|
+ format =
|
2009-09-12 09:28:49 +00:00
|
|
|
+ " File: %N\n"
|
|
|
|
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
+ "Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
|
|
|
+ " Device type: %t,%T\n"
|
|
|
|
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
+ " S_Context: %C\n"
|
|
|
|
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
2008-01-25 17:48:11 +00:00
|
|
|
+ else
|
2009-09-12 09:28:49 +00:00
|
|
|
+ format =
|
|
|
|
+ " File: %N\n"
|
|
|
|
+ " Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
|
|
|
+ "Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
|
|
|
+ "Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
|
|
|
+ "Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
|
|
|
}
|
|
|
|
}
|
2008-01-25 17:48:11 +00:00
|
|
|
}
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -911,6 +940,7 @@ usage (int status)
|
2008-01-25 17:48:11 +00:00
|
|
|
Display file or file system status.\n\
|
|
|
|
\n\
|
|
|
|
-L, --dereference follow links\n\
|
|
|
|
+ -Z, --context print the SELinux security context \n\
|
|
|
|
-f, --file-system display file system status instead of file status\n\
|
|
|
|
"), stdout);
|
|
|
|
fputs (_("\
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -995,6 +1025,7 @@ main (int argc, char *argv[])
|
2008-01-25 17:48:11 +00:00
|
|
|
int i;
|
|
|
|
bool fs = false;
|
|
|
|
bool terse = false;
|
|
|
|
+ bool secure = false;
|
|
|
|
char *format = NULL;
|
|
|
|
bool ok = true;
|
2006-03-24 13:48:34 +00:00
|
|
|
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -1034,13 +1065,13 @@ main (int argc, char *argv[])
|
2009-09-12 09:28:49 +00:00
|
|
|
terse = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
- case 'Z': /* FIXME: remove in 2010 */
|
|
|
|
- /* Ignore, for compatibility with distributions
|
|
|
|
- that implemented this before upstream.
|
|
|
|
- But warn of impending removal. */
|
|
|
|
- error (0, 0,
|
|
|
|
- _("the --context (-Z) option is obsolete and will be removed\n"
|
|
|
|
- "in a future release"));
|
|
|
|
+ case 'Z':
|
2008-01-25 17:48:11 +00:00
|
|
|
+ if((is_selinux_enabled()>0))
|
2009-09-12 09:28:49 +00:00
|
|
|
+ secure = 1;
|
|
|
|
+ else {
|
|
|
|
+ error (0, 0, _("Kernel is not SELinux enabled"));
|
|
|
|
+ usage (EXIT_FAILURE);
|
|
|
|
+ }
|
|
|
|
break;
|
|
|
|
|
|
|
|
case_GETOPT_HELP_CHAR;
|
2009-02-24 16:34:43 +00:00
|
|
|
@@ -1060,8 +1091,8 @@ main (int argc, char *argv[])
|
2004-12-27 13:37:11 +00:00
|
|
|
|
2006-03-24 13:48:34 +00:00
|
|
|
for (i = optind; i < argc; i++)
|
|
|
|
ok &= (fs
|
2009-09-12 09:28:49 +00:00
|
|
|
- ? do_statfs (argv[i], terse, format)
|
|
|
|
- : do_stat (argv[i], terse, format));
|
|
|
|
+ ? do_statfs (argv[i], terse, secure, format)
|
|
|
|
+ : do_stat (argv[i], terse, secure, format));
|
2006-03-24 13:48:34 +00:00
|
|
|
|
|
|
|
exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
|
|
}
|
2009-02-24 16:34:43 +00:00
|
|
|
diff -urNp coreutils-7.1-orig/tests/misc/selinux coreutils-7.1/tests/misc/selinux
|
|
|
|
--- coreutils-7.1-orig/tests/misc/selinux 2008-10-25 14:20:26.000000000 +0200
|
|
|
|
+++ coreutils-7.1/tests/misc/selinux 2009-02-24 13:47:15.000000000 +0100
|
2009-02-24 11:53:38 +00:00
|
|
|
@@ -30,7 +30,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
|
|
|
|
- c=`ls -dogZ $i|cut -d' ' -f3`; test x$c = x$ctx || fail=1
|
2008-01-31 15:55:47 +00:00
|
|
|
+ c=`ls -dogZ $i|cut -d' ' -f5`; test x$c = x$ctx || fail=1
|
2008-01-25 17:48:11 +00:00
|
|
|
c=`stat --printf %C $i`; test x$c = x$ctx || fail=1
|
|
|
|
done
|
2009-01-28 17:29:41 +00:00
|
|
|
|