diff options
author | dcashman <dcashman@google.com> | 2015-09-19 19:52:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-19 19:52:40 +0000 |
commit | def6f14fc604a41e2c75fddb0f54baccc7567b7b (patch) | |
tree | 9bef3f305fcd1c2a083098e5c4b4cd7a2beb62e7 | |
parent | 74900f76ef6969aae5e87304395c99c780156b18 (diff) | |
parent | 02797a0e21cea245998ee7cb0976972f67aee8ce (diff) | |
download | libselinux-def6f14fc604a41e2c75fddb0f54baccc7567b7b.tar.gz |
am 02797a0e: Revert "Enable restorecon to properly label symlinks."
* commit '02797a0e21cea245998ee7cb0976972f67aee8ce':
Revert "Enable restorecon to properly label symlinks."
-rw-r--r-- | src/android.c | 44 |
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) |