diff options
author | gcondra@google.com <gcondra@google.com> | 2013-05-16 15:06:58 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-05-16 15:06:58 -0700 |
commit | 4c09a62411a10438665df827791a82ec8652012b (patch) | |
tree | ee0e4cc87aff62fabcdcc9e6e53754bb0917bda1 | |
parent | 2810abf218c6b89731b9741c78e3926c6980744b (diff) | |
parent | 4d53ee61f68921dd08d4428b7af1ba30a806f412 (diff) | |
download | libselinux-4c09a62411a10438665df827791a82ec8652012b.tar.gz |
am 4d53ee61: am 0f3a5e88: Call lsetfilecon directly in fixcon.
* commit '4d53ee61f68921dd08d4428b7af1ba30a806f412':
Call lsetfilecon directly in fixcon.
-rw-r--r-- | src/android.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/android.c b/src/android.c index 8299f1e..c337650 100644 --- a/src/android.c +++ b/src/android.c @@ -705,7 +705,8 @@ bail: static int file_requires_fixup(const char *pathname, struct selabel_handle *sehandle_old, - struct selabel_handle *sehandle_new) + struct selabel_handle *sehandle_new, + char **context) { int ret; struct stat sb; @@ -754,10 +755,10 @@ err: out: if (current_context) freecon(current_context); - if (new_context) - freecon(new_context); if (old_context) freecon(old_context); + if (new_context) + *context = new_context; return ret; } @@ -766,14 +767,19 @@ static int fixcon_file(const char *pathname, struct selabel_handle *sehandle_new) { int requires_fixup; + char *new_context = NULL; + + requires_fixup = file_requires_fixup(pathname, sehandle_old, sehandle_new, &new_context); + + if (requires_fixup > 0) + lsetfilecon(pathname, new_context); + + if (new_context) + freecon(new_context); - requires_fixup = file_requires_fixup(pathname, sehandle_old, sehandle_new); if (requires_fixup < 0) return -1; - if (requires_fixup) - selinux_android_restorecon(pathname); - return 0; } |