Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d27792975e
|
||
|
|
c23308f78e
|
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user