[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [BUG] Issues with chcon
From:       Sagiv Dvash <sagivdev () gmail ! com>
Date:       2018-08-25 11:20:32
Message-ID: CA+VEgV2BinwcpTTmfbb4Eq3OdCksvMcqW3mTxyFK8TZ_QCWZ7Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi List,

There are some issues with chcon (selinux tool) that I encountered:

- recurse is not acting as expected (looks like broken old code)
  example: running $ chcon -R -t <target> <dir> will not recurse, but
running $ chcon -t <target> <dir> will..
- when not using verbose output, return value for when file context is
retained is 1, which is not expected.

Both are fixed with the attached patch. Is this the correct format?

-- Sagiv

PS I wasn't sure if the github project only acts as a mirror or whether I
can actually submit patches to there too. was it possible to submit it
there instead? any preference?

[Attachment #5 (text/html)]

<div dir="ltr">Hi List,<div><br></div><div>There are some issues with chcon (selinux \
tool) that I encountered:</div><div><br></div><div><div>- recurse is not acting as \
expected (looks like broken old code)</div><div>   example: running $ chcon -R -t \
&lt;target&gt; &lt;dir&gt; will not recurse, but running $ chcon -t &lt;target&gt; \
&lt;dir&gt; will..</div><div>- when not using verbose output, return value for when \
file context is retained is 1, which is not \
expected.</div></div><div><br></div><div>Both are fixed with the attached patch. Is \
this the correct format?</div><div><br></div><div>-- \
Sagiv</div><div><br></div><div>PS I wasn&#39;t sure if the github project only acts \
as a mirror or whether I can actually submit patches to there too. was it possible to \
submit it there instead? any preference?</div></div>


["0001-Fix-chcon-issues-with-recurse-and-retval-for-retaine.patch" (application/octet-stream)]

From 166c7b50d42e959641b60fd780b6aa63f1e4a357 Mon Sep 17 00:00:00 2001
From: sagivd <sagivdev@gmail.com>
Date: Sat, 25 Aug 2018 13:49:24 +0300
Subject: [PATCH] Fix chcon issues with recurse and retval for retained files

- recurse is not acting as expected (looks like broken old code)
- when not using verbose output, return value for retained files is 1,
  which is not expected.
---
 selinux/chcon.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/selinux/chcon.c b/selinux/chcon.c
index 3ddb2dd..92eb767 100644
--- a/selinux/chcon.c
+++ b/selinux/chcon.c
@@ -131,8 +131,10 @@ static int FAST_FUNC change_filedir_context(
 			bb_error_msg("can't change context of %s to %s",
 					fname, context_string);
 		}
-	} else if (option_mask32 & OPT_VERBOSE) {
-		printf("context of %s retained as %s\n", fname, context_string);
+	} else {
+		if (option_mask32 & OPT_VERBOSE) {
+			printf("context of %s retained as %s\n", fname, context_string);
+		}
 		rc = TRUE;
 	}
 skip:
@@ -202,7 +204,7 @@ int chcon_main(int argc UNUSED_PARAM, char **argv)
 		fname[fname_len] = '\0';
 
 		if (recursive_action(fname,
-					1<<option_mask32 & OPT_RECURSIVE,
+					((option_mask32 & OPT_RECURSIVE) ? ACTION_RECURSIVE : 0),
 					change_filedir_context,
 					change_filedir_context,
 					NULL, 0) != TRUE)
-- 
2.9.3.windows.2



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic