install,mkdir: fix handling of -DZ and -pZ, respectively

... 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
This commit is contained in:
Kamil Dudka authored and Pádraig Brady committed 2016-11-28 16:17:31 +00:00
1 parent a39641cbb8
commit d8104265f2
3 files changed
+6 -2

No files matched your search

+4
View File
@@ -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]
+1 -1
View 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));
+1 -1
View 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));