coreutils
[Top][All Lists]
Advanced

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

[PATCH 1/6] cp: -Z: restorecon(): fix detection and indication of errors


From: Pádraig Brady
Subject: [PATCH 1/6] cp: -Z: restorecon(): fix detection and indication of errors
Date: Tue, 4 Dec 2012 16:32:20 +0000

* src/selinux.c (restorecon_private): Check for correct error code
from [lf]getfilecon().  Note gnulib ensures these functions
always return -1 on error.  Also indicate return with an error if
context_new() fails.
---
 src/selinux.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/selinux.c b/src/selinux.c
index e708b55..afb3959 100644
--- a/src/selinux.c
+++ b/src/selinux.c
@@ -193,15 +193,17 @@ restorecon_private (char const *path, bool preserve)
   if (fd)
     {
       rc = fgetfilecon (fd, &tcon);
-      if (!rc)
+      if (rc < 0)
         goto quit;
     }
   else
     {
       rc = lgetfilecon (path, &tcon);
-      if (!rc)
+      if (rc < 0)
         goto quit;
     }
+
+  rc = -1;
   tcontext = context_new (tcon);
   if (!tcontext)
     goto quit;
-- 
1.7.6.4




reply via email to

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