From b35fff01b0188c42570a95f5929129a2205b1f91 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 14 Aug 2023 08:45:09 +0400 Subject: [PATCH] Restore initial working directory on restart So executable path computation still works for the new instance on systems deducing it by argv0 --- Telegram/SourceFiles/platform/linux/launcher_linux.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp index a19cb109d..59b059fda 100644 --- a/Telegram/SourceFiles/platform/linux/launcher_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/launcher_linux.cpp @@ -53,7 +53,12 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { : (cExeDir() + u"Updater"_q)).toStdString(); std::vector argumentsList; - argumentsList.push_back(writeProtectedUpdate ? "pkexec" : binaryPath); + if (writeProtectedUpdate) { + argumentsList.push_back("pkexec"); + argumentsList.push_back("--keep-cwd"); + } else { + argumentsList.push_back(binaryPath); + } argumentsList.push_back((justRelaunch && !arguments().isEmpty()) ? arguments().first().toStdString() : binaryPath); @@ -104,6 +109,7 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { // pkexec needs an alive parent if (writeProtectedUpdate) { if (!GLib::spawn_sync( + initialWorkingDir().toStdString(), argumentsList, std::nullopt, GLib::SpawnFlags::SEARCH_PATH_, @@ -119,6 +125,7 @@ bool Launcher::launchUpdater(UpdaterLaunch action) { } return GLib::spawn_async( + initialWorkingDir().toStdString(), argumentsList, std::nullopt, GLib::SpawnFlags::FILE_AND_ARGV_ZERO_,