Merge pull request #53418 from ClickHouse/sudo-preserve-env

Attempt to address reset ENV in init.d script
This commit is contained in:
Alexey Milovidov 2023-08-14 21:29:55 +03:00 committed by GitHub
commit 5d0a05ef19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -997,7 +997,9 @@ namespace
{
/// sudo respects limits in /etc/security/limits.conf e.g. open files,
/// that's why we are using it instead of the 'clickhouse su' tool.
command = fmt::format("sudo -u '{}' {}", user, command);
/// by default, sudo resets all the ENV variables, but we should preserve
/// the values /etc/default/clickhouse in /etc/init.d/clickhouse file
command = fmt::format("sudo --preserve-env -u '{}' {}", user, command);
}
fmt::print("Will run {}\n", command);