diff options
Diffstat (limited to 'updater/updater.cpp')
-rw-r--r-- | updater/updater.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/updater/updater.cpp b/updater/updater.cpp index f3e282044..e4b8e4641 100644 --- a/updater/updater.cpp +++ b/updater/updater.cpp @@ -19,6 +19,7 @@ #include <stdio.h> #include <unistd.h> #include <stdlib.h> +#include <fcntl.h> #include <string.h> #include <string> @@ -46,6 +47,9 @@ // (Note it's "updateR-script", not the older "update-script".) static constexpr const char* SCRIPT_NAME = "META-INF/com/google/android/updater-script"; +#define SELINUX_CONTEXTS_ZIP "file_contexts" +#define SELINUX_CONTEXTS_TMP "/tmp/file_contexts" + extern bool have_eio_error; struct selabel_handle *sehandle; @@ -167,6 +171,20 @@ int main(int argc, char** argv) { } ota_io_init(za, state.is_retry); + if (access(SELINUX_CONTEXTS_TMP, R_OK) == 0) { + struct selinux_opt seopts[] = { + { SELABEL_OPT_PATH, SELINUX_CONTEXTS_TMP } + }; + + sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1); + } else { + struct selinux_opt seopts[] = { + { SELABEL_OPT_PATH, "/file_contexts" } + }; + + sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1); + } + std::string result; bool status = Evaluate(&state, root, &result); |