Subject: bug#17220: closed (Re: bug#17220: SELinux options in --help / manpage may be confusing)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 09 Apr 2014 13:19:03 +0000

Your bug report

#17220: SELinux options in --help / manpage may be confusing

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17220: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17220
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17220: SELinux options in --help / manpage may be confusing
From: Pádraig Brady <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Wed, 09 Apr 2014 14:18:27 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Will push the attached soon.

thanks,
Pádraig.
>From 30acfcab5093debf433d966c5666d2e505c389c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email-masked]>
Date: Wed, 9 Apr 2014 13:37:42 +0100
Subject: [PATCH] doc: clarify in --help that -Z doesn't take an argument

* NEWS: Fix a confusing old entry.
* cfg.mk (old_NEWS_hash): Adjust accordingly.
* src/cp.c (usage): Separate the -Z and --context descriptions.
* src/install.c: Likewise.
* src/mkdir.c: Likewise.
* src/mkfifo.c: Likewise.
* src/mknod.c: Likewise.
Fixes http://bugs.gnu.org/17220
---
 NEWS          |    2 +-
 cfg.mk        |    2 +-
 src/cp.c      |    6 ++++--
 src/install.c |    6 ++++--
 src/mkdir.c   |    9 ++++++---
 src/mkfifo.c  |    6 +++---
 src/mknod.c   |    6 +++---
 7 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/NEWS b/NEWS
index 06e78a7..0a48456 100644
--- a/NEWS
+++ b/NEWS
@@ -148,7 +148,7 @@ GNU coreutils NEWS                                    -*- outline -*-
   a NUL instead of a white space character.
 
   id and ls with -Z report the SMACK security context where available.
-  mkdir, mkfifo and mknod with -Z set the SMACK context where available.
+  mkdir, mkfifo and mknod with --context set the SMACK context where available.
 
   id can now lookup by user ID, in addition to the existing name lookup.
 
diff --git a/cfg.mk b/cfg.mk
index cc6f4b8..c2ebb5d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -45,7 +45,7 @@ export VERBOSE = yes
 # 4914152 9e
 export XZ_OPT = -8e
 
-old_NEWS_hash = 2d79d365444c9328fe28352d24f3ba1b
+old_NEWS_hash = 88cd502ce932ab23e636c63a73a48c29
 
 # Add an exemption for sc_makefile_at_at_check.
 _makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
diff --git a/src/cp.c b/src/cp.c
index ee7d088..a254116 100644
--- a/src/cp.c
+++ b/src/cp.c
@@ -230,8 +230,10 @@ Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.\n\
   -x, --one-file-system        stay on this file system\n\
 "), stdout);
       fputs (_("\
-  -Z, --context[=CTX]          set SELinux security context of destination\n\
-                                 file to default type, or to CTX if specified\n\
+  -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\
+                                 SELinux or SMACK security context to CTX\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
diff --git a/src/install.c b/src/install.c
index 0554047..c9bfdae 100644
--- a/src/install.c
+++ b/src/install.c
@@ -647,8 +647,10 @@ In the 4th form, create all components of the given DIRECTORY(ies).\n\
 "), stdout);
       fputs (_("\
       --preserve-context  preserve SELinux security context\n\
-  -Z, --context[=CTX]     set SELinux security context of destination file to\n\
-                            default type, or to CTX if specified\n\
+  -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\
+                            SELinux or SMACK security context to CTX\n\
 "), stdout);
 
       fputs (HELP_OPTION_DESCRIPTION, stdout);
diff --git a/src/mkdir.c b/src/mkdir.c
index a6f6c24..04367eb 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -66,9 +66,12 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
   -m, --mode=MODE   set file mode (as in chmod), not a=rwx - umask\n\
   -p, --parents     no error if existing, make parent directories as needed\n\
   -v, --verbose     print a message for each created directory\n\
-  -Z, --context[=CTX]  set the SELinux security context of each created\n\
-                         directory to default type or set the SELinux or\n\
-                         SMACK security context to CTX if specified\n\
+"), stdout);
+      fputs (_("\
+  -Z                   set SELinux security context of each created directory\n\
+                         to the default type\n\
+      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux\n\
+                         or SMACK security context to CTX\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
diff --git a/src/mkfifo.c b/src/mkfifo.c
index cf97059..5a52d6a 100644
--- a/src/mkfifo.c
+++ b/src/mkfifo.c
@@ -61,9 +61,9 @@ Create named pipes (FIFOs) with the given NAMEs.\n\
   -m, --mode=MODE    set file permission bits to MODE, not a=rw - umask\n\
 "), stdout);
       fputs (_("\
-  -Z, --context[=CTX]  set the SELinux security context of each NAME to\n\
-                         default type, or set the SELinux or SMACK\n\
-                         security context to CTX if specified\n\
+  -Z                   set the SELinux security context to default type\n\
+      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux\n\
+                         or SMACK security context to CTX\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
diff --git a/src/mknod.c b/src/mknod.c
index dfb9ef4..6e67094 100644
--- a/src/mknod.c
+++ b/src/mknod.c
@@ -63,9 +63,9 @@ Create the special file NAME of the given TYPE.\n\
   -m, --mode=MODE    set file permission bits to MODE, not a=rw - umask\n\
 "), stdout);
       fputs (_("\
-  -Z, --context[=CTX]  set the SELinux security context of NAME to\n\
-                         default type, or set the SELinux or SMACK\n\
-                         security context to CTX if specified\n\
+  -Z                   set the SELinux security context to default type\n\
+      --context[=CTX]  like -Z, or if CTX is specified then set the SELinux\n\
+                         or SMACK security context to CTX\n\
 "), stdout);
       fputs (HELP_OPTION_DESCRIPTION, stdout);
       fputs (VERSION_OPTION_DESCRIPTION, stdout);
-- 
1.7.7.6

Subject: SELinux options in --help / manpage may be confusing
From: Ondrej Vasik <[email-masked]>
To: CoreutilsBugs <[email-masked]>
Date: Tue, 08 Apr 2014 15:47:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,
recently I got one bug report, asking about mknod not running correctly
with old syntax
mknod -m 666 -Z system_u:object_r:random_device_t:s0 /dev/random2 c 1 9
This is not a bug, as since 8.22, short version of -Z doesn't accept
optional arguments.

However, --help and manpage is a bit misleading. I think we should split
the lines for -Z and --context , as both are doing a bit different
thing.
-Z restores the default SELinux context
--context=[CTX] restores the default SELinux context if no CTX is
specified, otherwise sets the SELinux/SMACK context to CTX.

Now, with having them both on one lines, it gives user the feeling that
-Z accepts argument, which may lead to scripts errors. This is not only
about mknod, but about all utilities with -Z option (and recent change
in behaviour)

Thanks in advance for consideration!

Greetings,
         Ondrej