]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
install,mkdir: fix handling of -DZ and -pZ, respectively
authorKamil Dudka <kdudka@redhat.com>
Mon, 28 Nov 2016 15:21:42 +0000 (16:21 +0100)
committerPádraig Brady <P@draigBrady.com>
Mon, 28 Nov 2016 16:17:31 +0000 (16:17 +0000)
... in the case where two or more directories nested in each other are
created and each of them defaults to a different SELinux context.

* src/install.c (make_ancestor): When calling defaultcon(), give it the
same path that is given to mkdir().  The other path is not always valid
wrt. current working directory.
* src/mkdir.c (make_ancestor): Likewise.
* NEWS: Mention the bug fix.

Reported at https://bugzilla.redhat.com/1398913

NEWS
src/install.c
src/mkdir.c

diff --git a/NEWS b/NEWS
index 6f7505f82dc5ba06cb187ee40d6de6f707d84029..e88e932145d61d15a14cba3056bac17683c6a8c5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,10 @@ GNU coreutils NEWS                                    -*- outline -*-
   factor again outputs immediately when numbers are input interactively.
   [bug introduced in coreutils-8.24]
 
+  install -DZ and mkdir -pZ now set default SELinux context correctly even if
+  two or more directories nested in each other are created and each of them
+  defaults to a different SELinux context.
+
   ls --time-style no longer mishandles '%%b' in formats.
   [bug introduced in coreutils-7.2]
 
index 414d645cc9a03897cc3f247318ef30c0840a4ba4..d79d5978926a60df9a4f72a7dc72f6b6c1937124 100644 (file)
@@ -427,7 +427,7 @@ static int
 make_ancestor (char const *dir, char const *component, void *options)
 {
   struct cp_options const *x = options;
-  if (x->set_security_context && defaultcon (dir, S_IFDIR) < 0
+  if (x->set_security_context && defaultcon (component, S_IFDIR) < 0
       && ! ignorable_ctx_err (errno))
     error (0, errno, _("failed to set default creation context for %s"),
            quoteaf (dir));
index ccd923b1c2329a47a1e9b4cfa2888fb44e8f9b65..6b51292fa883f89d3360ff5088f5b6343f6a275a 100644 (file)
@@ -123,7 +123,7 @@ make_ancestor (char const *dir, char const *component, void *options)
 {
   struct mkdir_options const *o = options;
 
-  if (o->set_security_context && defaultcon (dir, S_IFDIR) < 0
+  if (o->set_security_context && defaultcon (component, S_IFDIR) < 0
       && ! ignorable_ctx_err (errno))
     error (0, errno, _("failed to set default creation context for %s"),
            quoteaf (dir));