Fix return value of selinux_android_restorecon.
Change I4a380caab7f8481c33eb64fcdb16b6cabe918ebd unified
the init and libselinux restorecon code but introduced a bug
by changing the return value of selinux_android_restorecon
on errors from -1 (as in libselinux) to -errno (as in the init
built-in command). Change it back as there are various callers
assuming the libselinux behavior and init does not actually rely
on the -errno behavior in the utils code and handles it correctly
in the built-in command functions themselves.
Change-Id: I6ed5b644820eb07c061d8a2a116511aeb7401df4
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
diff --git a/src/android.c b/src/android.c
index 554828e..5810e63 100644
--- a/src/android.c
+++ b/src/android.c
@@ -713,11 +713,11 @@
int i;
if (selabel_lookup(sehandle, &secontext, pathname, sb->st_mode) < 0)
- return -errno;
+ return -1;
if (lgetfilecon(pathname, &oldsecontext) < 0) {
freecon(secontext);
- return -errno;
+ return -1;
}
if (strcmp(oldsecontext, secontext) != 0) {
@@ -727,7 +727,7 @@
pathname, secontext, strerror(errno));
freecon(oldsecontext);
freecon(secontext);
- return -errno;
+ return -1;
}
}
freecon(oldsecontext);
@@ -754,7 +754,7 @@
return 0;
if (lstat(pathname, &sb) < 0)
- return -errno;
+ return -1;
return restorecon_sb(pathname, &sb, false);
}