summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordcashman <dcashman@google.com>2015-09-18 16:01:17 -0700
committerdcashman <dcashman@google.com>2015-09-18 16:35:08 -0700
commite036e11fb1268622cbc8a6ca474a5c17a6d320f8 (patch)
tree9bef3f305fcd1c2a083098e5c4b4cd7a2beb62e7
parent01dad8c12e9c8908c60bc87c9d81be3764c63c55 (diff)
downloadlibselinux-e036e11fb1268622cbc8a6ca474a5c17a6d320f8.tar.gz
Revert "Enable restorecon to properly label symlinks."
This change resulted in //data being used for restorecon, rather than /data, causing the check to fail when deciding whether or not init should label app data files. This reverts commit 249094fcb1b4d3a37be10e394023bcba75fff2b1. (cherry-pick of commit: 02797a0e21cea245998ee7cb0976972f67aee8ce) Bug: 24190361 Change-Id: I1a0f64404da3c54a03890df60b8b5d9102d1efa3
-rw-r--r--src/android.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/android.c b/src/android.c
index 8949a5d..8f66a5a 100644
--- a/src/android.c
+++ b/src/android.c
@@ -31,7 +31,6 @@
#include <limits.h>
#include <sys/vfs.h>
#include <linux/magic.h>
-#include <libgen.h>
/*
* XXX Where should this configuration file be located?
@@ -1232,7 +1231,7 @@ static int selinux_android_restorecon_common(const char* pathname_orig,
struct statfs sfsb;
FTS *fts;
FTSENT *ftsent;
- char *pathname = NULL, *pathdnamer = NULL, *pathdname, *pathbname;
+ char *pathname;
char * paths[2] = { NULL , NULL };
int ftsflags = FTS_NOCHDIR | FTS_XDEV | FTS_PHYSICAL;
int error, sverrno;
@@ -1247,25 +1246,16 @@ static int selinux_android_restorecon_common(const char* pathname_orig,
if (!fc_sehandle)
return 0;
- /*
- * Convert passed-in pathname to canonical pathname by resolving realpath of
- * containing dir, then appending last component name.
- */
- pathbname = basename(pathname_orig);
- if (!strcmp(pathbname, "/") || !strcmp(pathbname, ".") || !strcmp(pathbname, "..")) {
- pathname = realpath(pathname_orig, NULL);
- if (!pathname)
- goto realpatherr;
- } else {
- pathdname = dirname(pathname_orig);
- pathdnamer = realpath(pathdname, NULL);
- if (!pathdnamer)
- goto realpatherr;
- error = asprintf(&pathname, "%s/%s", pathdnamer, pathbname);
- if (error < 0)
- goto oom;
+ // convert passed-in pathname to canonical pathname
+ pathname = realpath(pathname_orig, NULL);
+ if (!pathname) {
+ sverrno = errno;
+ selinux_log(SELINUX_ERROR, "SELinux: Could not get canonical path %s restorecon: %s.\n",
+ pathname_orig, strerror(errno));
+ errno = sverrno;
+ error = -1;
+ goto cleanup;
}
-
paths[0] = pathname;
issys = (!strcmp(pathname, SYS_PATH)
|| !strncmp(pathname, SYS_PREFIX, sizeof(SYS_PREFIX)-1)) ? true : false;
@@ -1374,22 +1364,8 @@ out:
(void) fts_close(fts);
errno = sverrno;
cleanup:
- free(pathdnamer);
free(pathname);
return error;
-oom:
- sverrno = errno;
- selinux_log(SELINUX_ERROR, "%s: Out of memory\n", __FUNCTION__);
- errno = sverrno;
- error = -1;
- goto cleanup;
-realpatherr:
- sverrno = errno;
- selinux_log(SELINUX_ERROR, "SELinux: Could not get canonical path for %s restorecon: %s.\n",
- pathname_orig, strerror(errno));
- errno = sverrno;
- error = -1;
- goto cleanup;
}
int selinux_android_restorecon(const char *file, unsigned int flags)