From c23308f78ef7dc258388f3c67cfb34cbbcb66a73 Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Fri, 30 Oct 2026 18:04:04 +0100 Subject: [PATCH] Fix(update): chaine de SU --- src/update-manager.cpp | 14 +++++++++++--- version | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/update-manager.cpp b/src/update-manager.cpp index 0310653..a0b957e 100644 --- a/src/update-manager.cpp +++ b/src/update-manager.cpp @@ -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 { diff --git a/version b/version index 9075be4..9c6d629 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.5 +1.6.1