[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
- [PATCH 1/6] cp: -Z: restorecon(): fix detection and indication of errors,
Pádraig Brady <=
- [PATCH 2/6] cp: -Z: simplify return code handling in selinux routines, Pádraig Brady, 2012/12/04
- [PATCH 3/6] cp: -Z: check for more errors in selinux routines, Pádraig Brady, 2012/12/04
- [PATCH 6/6] cp: -Z: fix handling of open errors in restorecon(), Pádraig Brady, 2012/12/04
- [PATCH 5/6] cp: -Z: rename PRESERVE bool param to LOCAL, Pádraig Brady, 2012/12/04
- [PATCH 4/6] cp: -Z: tweak comments for selinux routines, Pádraig Brady, 2012/12/04