coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] chcon: use specified_context directly


From: Namhyung Kim
Subject: [PATCH 2/2] chcon: use specified_context directly
Date: Tue, 1 Jul 2014 00:12:42 +0900

Since it's verified by security_check_context() it can be used in
change_file_context() without converting to context_t everytime.

* src/chcon.c (change_file_context): Use specified_context directly.
---
 src/chcon.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/chcon.c b/src/chcon.c
index cd5fba3..fee9ffb 100644
--- a/src/chcon.c
+++ b/src/chcon.c
@@ -170,17 +170,14 @@ change_file_context (int fd, char const *file)
 
       if (compute_context_from_mask (file_context, &context))
         return 1;
+
+      context_string = context_str (context);
     }
   else
     {
-      /* FIXME: this should be done exactly once, in main.  */
-      context = context_new (specified_context);
-      if (!context)
-        abort ();
+      context_string = specified_context;
     }
 
-  context_string = context_str (context);
-
   if (file_context == NULL || ! STREQ (context_string, file_context))
     {
       int fail = (affect_symlink_referent
@@ -195,8 +192,11 @@ change_file_context (int fd, char const *file)
         }
     }
 
-  context_free (context);
-  freecon (file_context);
+  if (specified_context == NULL)
+    {
+      context_free (context);
+      freecon (file_context);
+    }
 
   return errors;
 }
-- 
2.0.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]