summaryrefslogtreecommitdiff
path: root/init/subcontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'init/subcontext.cpp')
-rw-r--r--init/subcontext.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/init/subcontext.cpp b/init/subcontext.cpp
index e55265b0a..bebcc7733 100644
--- a/init/subcontext.cpp
+++ b/init/subcontext.cpp
@@ -209,8 +209,12 @@ void Subcontext::Fork() {
PLOG(FATAL) << "Could not dup child_fd";
}
- if (setexeccon(context_.c_str()) < 0) {
- PLOG(FATAL) << "Could not set execcon for '" << context_ << "'";
+ // We don't switch contexts if we're running the unit tests. We don't use std::optional,
+ // since we still need a real context string to pass to the builtin functions.
+ if (context_ != kTestContext) {
+ if (setexeccon(context_.c_str()) < 0) {
+ PLOG(FATAL) << "Could not set execcon for '" << context_ << "'";
+ }
}
auto init_path = GetExecutablePath();