fix: support ExecSearchPath to prevent systemd from not finding binaries

In NixOS, maintainer used a patch to modify the DEFAULT_PATH macro of systemd.
However, systemd can only find its own binaries under that path.
At this point, if you take the relative path of the binary as a parameter to StartTransientUnit,
systemd will use DEFAULT_PATH to look for the binary, which will cause systemd to not find it.

There may be other Linux distributions that change this path,
so add ExecSearchPath to prevent systemd from not finding the binary.

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2024-02-01 17:30:59 +08:00
committed by Comix
parent bcb9d0c3e5
commit aca0531e85
10 changed files with 118 additions and 47 deletions

View File

@ -19,8 +19,10 @@ QStringList generateCommand(const QVariantMap &props) noexcept
options.emplace_back(std::make_unique<setEnvLaunchOption>(value));
} else if (key == hookLaunchOption::key()) {
options.emplace_back(std::make_unique<hookLaunchOption>(value));
} else if (key == setPathLaunchOption::key()) {
options.emplace_back(std::make_unique<setPathLaunchOption>(value));
} else if (key == setWorkingPathLaunchOption::key()) {
options.emplace_back(std::make_unique<setWorkingPathLaunchOption>(value));
} else if (key == builtInSearchExecOption::key()) {
options.emplace_back(std::make_unique<builtInSearchExecOption>(value));
} else {
qWarning() << "unsupported options" << key;
}
@ -109,7 +111,7 @@ QStringList setEnvLaunchOption::generateCommandLine() const noexcept
return QStringList{QString{"--Environment=%1"}.arg(str)};
}
QStringList setPathLaunchOption::generateCommandLine() const noexcept
QStringList setWorkingPathLaunchOption::generateCommandLine() const noexcept
{
auto str = m_val.toString();
if (str.isEmpty()) {
@ -118,3 +120,14 @@ QStringList setPathLaunchOption::generateCommandLine() const noexcept
return QStringList{QString{"--WorkingDirectory=%1"}.arg(str)};
}
QStringList builtInSearchExecOption::generateCommandLine() const noexcept
{
auto list = m_val.toStringList();
if (list.isEmpty()) {
return {};
}
auto content = list.join(';');
return QStringList{QString{"--ExecSearchPath=%1"}.arg(content)};
}