mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-04 01:05:58 +03:00
SystemServer: Revert back to inheriting environments again
This reverts the SystemServer exec() logic to how it was before
81bd91c
, but now with some extra TRY()s. This allows the HOME var
to always be propagated from LoginServer which prevents needing
to unveil() /etc/passwd everywhere.
This commit is contained in:
parent
d81a72ed78
commit
83f41d1491
Notes:
sideshowbarker
2024-07-17 00:45:28 +09:00
Author: https://github.com/MacDue Commit: https://github.com/SerenityOS/serenity/commit/83f41d1491 Pull-request: https://github.com/SerenityOS/serenity/pull/17309 Reviewed-by: https://github.com/timschumi Reviewed-by: https://github.com/trflynn89
@ -193,12 +193,9 @@ ErrorOr<void> Service::spawn(int socket_fd)
|
||||
}
|
||||
}
|
||||
|
||||
auto environment = TRY(StringBuilder::create());
|
||||
TRY(environment.try_append(m_environment));
|
||||
|
||||
if (!m_sockets.is_empty()) {
|
||||
// The new descriptor is !CLOEXEC here.
|
||||
TRY(environment.try_appendff(" SOCKET_TAKEOVER={}", TRY(socket_takeover_builder.to_string())));
|
||||
TRY(Core::System::setenv("SOCKET_TAKEOVER"sv, socket_takeover_builder.string_view(), true));
|
||||
}
|
||||
|
||||
if (m_account.has_value() && m_account.value().uid() != getuid()) {
|
||||
@ -207,13 +204,20 @@ ErrorOr<void> Service::spawn(int socket_fd)
|
||||
dbgln("Failed to drop privileges (GID={}, UID={})\n", account.gid(), account.uid());
|
||||
exit(1);
|
||||
}
|
||||
TRY(environment.try_appendff(" HOME={}", account.home_directory()));
|
||||
TRY(Core::System::setenv("HOME"sv, account.home_directory(), true));
|
||||
}
|
||||
|
||||
auto arguments = TRY(StringBuilder::create());
|
||||
TRY(arguments.try_appendff("{} {}", m_executable_path, m_extra_arguments));
|
||||
TRY(m_environment.view().for_each_split_view(' ', SplitBehavior::Nothing, [&](auto env) {
|
||||
return Core::System::putenv(env);
|
||||
}));
|
||||
|
||||
TRY(Core::System::exec(m_executable_path, arguments.string_view().split_view(' '), Core::System::SearchInPath::No, environment.string_view().split_view(' ')));
|
||||
Vector<StringView, 10> arguments;
|
||||
TRY(arguments.try_append(m_executable_path));
|
||||
TRY(m_extra_arguments.view().for_each_split_view(' ', SplitBehavior::Nothing, [&](auto arg) {
|
||||
return arguments.try_append(arg);
|
||||
}));
|
||||
|
||||
TRY(Core::System::exec(m_executable_path, arguments, Core::System::SearchInPath::No));
|
||||
} else if (!m_multi_instance) {
|
||||
// We are the parent.
|
||||
m_pid = pid;
|
||||
|
Loading…
Reference in New Issue
Block a user