GNU bug report logs - #25052
[PATCH] install,mkdir: fix handling of -DZ and -pZ, respectively

Previous Next

Package: coreutils;

Reported by: Kamil Dudka <kdudka <at> redhat.com>

Date: Mon, 28 Nov 2016 15:23:02 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25052 in the body.
You can then email your comments to 25052 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#25052; Package coreutils. (Mon, 28 Nov 2016 15:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Kamil Dudka <kdudka <at> redhat.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 28 Nov 2016 15:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kamil Dudka <kdudka <at> redhat.com>
To: bug-coreutils <at> gnu.org
Subject: [PATCH] install,mkdir: fix handling of -DZ and -pZ, respectively
Date: Mon, 28 Nov 2016 16:21:42 +0100
... in case 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          | 4 ++++
 src/install.c | 2 +-
 src/mkdir.c   | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 6f7505f..e88e932 100644
--- 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]
 
diff --git a/src/install.c b/src/install.c
index 414d645..d79d597 100644
--- a/src/install.c
+++ b/src/install.c
@@ -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));
diff --git a/src/mkdir.c b/src/mkdir.c
index ccd923b..6b51292 100644
--- a/src/mkdir.c
+++ b/src/mkdir.c
@@ -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));
-- 
2.7.4





Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Mon, 28 Nov 2016 16:12:01 GMT) Full text and rfc822 format available.

Notification sent to Kamil Dudka <kdudka <at> redhat.com>:
bug acknowledged by developer. (Mon, 28 Nov 2016 16:12:01 GMT) Full text and rfc822 format available.

Message #10 received at 25052-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Kamil Dudka <kdudka <at> redhat.com>, 25052-done <at> debbugs.gnu.org
Subject: Re: bug#25052: [PATCH] install, mkdir: fix handling of -DZ and -pZ,
 respectively
Date: Mon, 28 Nov 2016 16:11:34 +0000
On 28/11/16 15:21, Kamil Dudka wrote:
> ... in case 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          | 4 ++++
>  src/install.c | 2 +-
>  src/mkdir.c   | 2 +-
>  3 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index 6f7505f..e88e932 100644
> --- 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]
>  
> diff --git a/src/install.c b/src/install.c
> index 414d645..d79d597 100644
> --- a/src/install.c
> +++ b/src/install.c
> @@ -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));
> diff --git a/src/mkdir.c b/src/mkdir.c
> index ccd923b..6b51292 100644
> --- a/src/mkdir.c
> +++ b/src/mkdir.c
> @@ -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));
> 

Looks good.
Good timing re release 8.26 which we're about to cut.

thanks!
Pádraig




Information forwarded to bug-coreutils <at> gnu.org:
bug#25052; Package coreutils. (Mon, 28 Nov 2016 16:40:01 GMT) Full text and rfc822 format available.

Message #13 received at 25052-done <at> debbugs.gnu.org (full text, mbox):

From: Kamil Dudka <kdudka <at> redhat.com>
To: Pádraig Brady <P <at> draigbrady.com>
Cc: 25052-done <at> debbugs.gnu.org
Subject: Re: bug#25052: [PATCH] install, mkdir: fix handling of -DZ and -pZ,
 respectively
Date: Mon, 28 Nov 2016 17:39:38 +0100
On Monday, November 28, 2016 16:11:34 Pádraig Brady wrote:
> On 28/11/16 15:21, Kamil Dudka wrote:
> > ... in case 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          | 4 ++++
> >  src/install.c | 2 +-
> >  src/mkdir.c   | 2 +-
> >  3 files changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/NEWS b/NEWS
> > index 6f7505f..e88e932 100644
> > --- 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]
> > 
> > diff --git a/src/install.c b/src/install.c
> > index 414d645..d79d597 100644
> > --- a/src/install.c
> > +++ b/src/install.c
> > @@ -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));
> > 
> > diff --git a/src/mkdir.c b/src/mkdir.c
> > index ccd923b..6b51292 100644
> > --- a/src/mkdir.c
> > +++ b/src/mkdir.c
> > @@ -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));
> 
> Looks good.
> Good timing re release 8.26 which we're about to cut.

Thanks for merging it upstream!  Looking forward for the new release...

Kamil

> thanks!
> Pádraig




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 27 Dec 2016 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 231 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.