diff options
author | Scott Lobdell <slobdell@google.com> | 2021-03-11 19:09:01 +0000 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2021-03-11 19:09:01 +0000 |
commit | 3c37969c09d9a55be484ffddb1920dcb1412d96e (patch) | |
tree | 5e745d1720c37bf82fd0e3051f39847d2cdc4e75 /init/builtins.cpp | |
parent | b720863fd10b6e6f245f3057785cd7426833700b (diff) | |
parent | 80f5c42becf297b2ff2c6f9be0490c17048e169c (diff) |
Merge SP1A.210311.001
Change-Id: I01c4c598ed6764fc1936b2baaab660e585a3984c
Diffstat (limited to 'init/builtins.cpp')
-rw-r--r-- | init/builtins.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/init/builtins.cpp b/init/builtins.cpp index 50f254c89..058f84aa5 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -292,6 +292,38 @@ static Result<void> do_export(const BuiltinArguments& args) { return {}; } +static Result<void> do_load_exports(const BuiltinArguments& args) { + auto file_contents = ReadFile(args[1]); + if (!file_contents.ok()) { + return Error() << "Could not read input file '" << args[1] + << "': " << file_contents.error(); + } + + auto lines = Split(*file_contents, "\n"); + for (const auto& line : lines) { + if (line.empty()) { + continue; + } + + auto env = Split(line, " "); + + if (env.size() != 3) { + return ErrnoError() << "Expected a line as `export <name> <value>`, found: `" << line + << "`"; + } + + if (env[0] != "export") { + return ErrnoError() << "Unknown action: '" << env[0] << "', expected 'export'"; + } + + if (setenv(env[1].c_str(), env[2].c_str(), 1) == -1) { + return ErrnoError() << "Failed to export '" << line << "' from " << args[1]; + } + } + + return {}; +} + static Result<void> do_hostname(const BuiltinArguments& args) { if (auto result = WriteFile("/proc/sys/kernel/hostname", args[1]); !result.ok()) { return Error() << "Unable to write to /proc/sys/kernel/hostname: " << result.error(); @@ -1268,6 +1300,14 @@ static Result<void> GenerateLinkerConfiguration() { return ErrnoError() << "failed to execute linkerconfig"; } + auto current_mount_ns = GetCurrentMountNamespace(); + if (!current_mount_ns.ok()) { + return current_mount_ns.error(); + } + if (*current_mount_ns == NS_DEFAULT) { + SetDefaultMountNamespaceReady(); + } + LOG(INFO) << "linkerconfig generated " << linkerconfig_target << " with mounted APEX modules info"; @@ -1426,6 +1466,7 @@ const BuiltinFunctionMap& GetBuiltinFunctionMap() { {"interface_restart", {1, 1, {false, do_interface_restart}}}, {"interface_start", {1, 1, {false, do_interface_start}}}, {"interface_stop", {1, 1, {false, do_interface_stop}}}, + {"load_exports", {1, 1, {false, do_load_exports}}}, {"load_persist_props", {0, 0, {false, do_load_persist_props}}}, {"load_system_props", {0, 0, {false, do_load_system_props}}}, {"loglevel", {1, 1, {false, do_loglevel}}}, |