Fix(update): chaine de SU

This commit is contained in:
BlackAngelTV committed 2026-10-30 18:04:04 +01:00
1 parent 3a77cb8f42
commit c23308f78e
2 files changed
+12 -4

No files matched your search

+11 -3
View File
@@ -579,18 +579,26 @@ QString UpdateManager::stagedInstallScript() {
// Install command: the action runs in a child `sh` (so it may be a compound
// command and expands the exported paths), through sudo when a password was
// provided or the target directory is not writable.
//
// The paths are handed to the child through `env` because sudo resets the
// environment (env_reset, the default): the exports from the prologue would be
// dropped and the install script would run `mkdir -p ""` on a system-wide
// install (/usr/bin and the like). They are expanded by the unprivileged shell
// that still has them, since the action itself is single-quoted.
QString UpdateManager::installCommand(const QString& quotedPassword,
const QString& action) const {
const QString quotedAction = quoteShell(action);
const QString passThrough = QStringLiteral(
"env BIN_DIR=\"$BIN_DIR\" STAGE=\"$STAGE\" APP_VERSION=\"$APP_VERSION\"");
if (!quotedPassword.isEmpty()) {
// NOTE: single %s — QString::arg() only substitutes %1..%99.
return QStringLiteral("printf '%s\\n' %1 | sudo -S sh -c %2 2>&1\n")
.arg(quotedPassword, quotedAction);
return QStringLiteral("printf '%s\\n' %1 | sudo -S %2 sh -c %3 2>&1\n")
.arg(quotedPassword, passThrough, quotedAction);
}
if (QFileInfo(binDir()).isWritable()) {
return QStringLiteral("sh -c %1 2>&1\n").arg(quotedAction);
}
return QStringLiteral("sudo sh -c %1 2>&1\n").arg(quotedAction);
return QStringLiteral("sudo %1 sh -c %2 2>&1\n").arg(passThrough, quotedAction);
}
QString UpdateManager::quotedBinDir() const {
+1 -1
View File
@@ -1 +1 @@
1.5.5
1.6.1