From 2e9ea60ae081633d476cb3b783f077affad57415 Mon Sep 17 00:00:00 2001 From: Boris Pozdena Date: Wed, 1 Jul 2026 11:29:25 +0200 Subject: [PATCH] Refactor logout method to use subprocess for improved error handling and compatibility in AppImage --- src/profile_settings_window.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/profile_settings_window.py b/src/profile_settings_window.py index cca0f2d..11c496c 100644 --- a/src/profile_settings_window.py +++ b/src/profile_settings_window.py @@ -18,6 +18,7 @@ from ui.ui_profile_settings_page import Ui_profile_settings import re import os import copy +import subprocess from configparser import ConfigParser # Import setup_wizard after importing wizard, keeping it at the bottom to avoid circular imports @@ -657,9 +658,6 @@ class ProfileSettingsPage(QWidget, Ui_profile_settings): return value.lower() in "true" def logout(self): - os.system(f"{client_bin_path} --confdir='{self.config_dir}' --logout") - logging.info(f"Profile {self.profile} has been logged out.") - main_window.main_window_instance.profile_status_pages[self.profile].stop_monitor() if self.profile in workers: workers[self.profile].stop_worker() @@ -668,6 +666,17 @@ class ProfileSettingsPage(QWidget, Ui_profile_settings): else: logging.info(f"OneDrive for profile {self.profile} is not running.") + # Run --logout only after the monitor process has fully stopped, otherwise the + # running onedrive process can still hold a lock on the auth/session files and + # --logout silently fails to clear the saved credentials. + # Use subprocess instead of os.system: inside the AppImage, os.system's /bin/sh + # picks up the bundled LD_LIBRARY_PATH and crashes with a readline symbol lookup + # error before ever running the command. + result = subprocess.run([client_bin_path, f"--confdir={self.config_dir}", "--logout"], capture_output=True, text=True) + logging.info(f"Profile {self.profile} has been logged out.") + if result.returncode != 0: + logging.error(f"[{self.profile}] onedrive --logout failed (exit {result.returncode}): {result.stdout}{result.stderr}") + main_window.main_window_instance.profile_status_pages[self.profile].label_onedrive_status.setText("You have been logged out") def get_sync_dir_name(self):