Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Use runuser and xdg-open in root-mode to open URLs in browser
  • Loading branch information
buhtz committed Oct 5, 2025
commit 590c0e079e699b8ebbd959d6d276b1bfc544d058
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version 1.5.6 (2025-10-05)
* Fixed: Always use 0 as window ID value when inhibiting suspend via D-Bus power manager (#2084, #2268, #2192)
* Fixed: Crash in "Manage profiles" dialog when using "qt6ct" (#2128)
* Fixed: Open online changelog if local CHANGES file is missing (#2266)
* Fixed: Use runuser and xdg-open in root-mode to open URLs in browser

Version 1.5.5 (2025-06-05)
* Fixed: Unlocking SSH keys with passphrases on new created profiles (#2164) (@davidfjoh)
Expand Down
2 changes: 1 addition & 1 deletion qt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@ def btnReportBugClicked(self):
self.openUrl('https://github.com/bit-team/backintime/issues/new')

def openUrl(self, url):
return QDesktopServices.openUrl(QUrl(url))
qttools.open_url(url)

def openManPage(self, man_page):
if not tools.checkCommand('man'):
Expand Down
34 changes: 33 additions & 1 deletion qt/qttools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

"""
import os
import subprocess
import sys
import re
import textwrap
Expand Down Expand Up @@ -278,7 +279,38 @@ def open_user_manual() -> None:
If available the local manual is used otherwise the online version is
opened.
"""
QDesktopServices.openUrl(QUrl(user_manual_uri()))
open_url(user_manual_uri())


def open_url(self, url):
sudo_user = os.getenv('SUDO_USER', None)

if not sudo_user: # regular user mode
return QDesktopServices.openUrl(QUrl(url))

# BIT in root mode
try:
subprocess.run(
[
'runuser',
'-u',
sudo_user,
'--',
'xdg-open',
url
],
check=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL
)
except (subprocess.CalledProcessError, FileNotFoundError) as exc:
logger.error(f'Problem while opening "{url}" in as user '
f'"{sudo_user}" while in root-mode. '
f'Error was: {exc}')
except Exception as exc:
logger.critical(f'Unknown problem while opening "{url}" in as user '
f'"{sudo_user}" while in root-mode. '
f'Error was: {exc}')


class FileDialogShowHidden(QFileDialog):
Expand Down