Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open Help menu links in gsmartcontrol-root #7

Open
JohnVeness opened this issue Jul 2, 2021 · 6 comments
Open

Cannot open Help menu links in gsmartcontrol-root #7

JohnVeness opened this issue Jul 2, 2021 · 6 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@JohnVeness
Copy link

Hi, many thanks for this app. I am using 1.1.3 on Ubuntu Mate 21.04.

I notice that all links in the Help menu (Help, Support, About/Website and the mailto: links in About/Credits) do not work when using gsmartcontrol-root (they work in non-root gsmartcontrol).

Running gsmartcontrol-root -v I see:

<info>  [app] GscMainWindow::on_action_activated(): Action activated: "action_online_documentation"
Running Firefox as root in a regular user's session is not supported.  ($XAUTHORITY is /home/john/.Xauthority which is owned by john.)
<info>  [app] GscMainWindow::on_action_activated(): Action activated: "action_support"
Running Firefox as root in a regular user's session is not supported.  ($XAUTHORITY is /home/john/.Xauthority which is owned by john.)
<info>  [app] GscMainWindow::on_action_activated(): Action activated: "action_about"
Running Firefox as root in a regular user's session is not supported.  ($XAUTHORITY is /home/john/.Xauthority which is owned by john.)
Running Thunderbird as root in a regular user's session is not supported.  ($XAUTHORITY is /home/john/.Xauthority which is owned by john.)
@ashaduri ashaduri self-assigned this Jul 5, 2021
@ashaduri
Copy link
Owner

Hello,
Thanks for the bug report!

GSmartControl uses gtk_show_uri_on_window() to open URLs, so it does not have any say in which browser is used to open the URL.
Since GSmartControl itself is launched with root privileges, and Firefox doesn't support running in this mode, I guess the only workaround would be to check whether the launch was successful. If it was not, a dialog with the URL (for the user to copy) would be shown.
I will have to check whether an unsuccessful launch can be detected at all. If not, I'm not sure what else I could do (any help is appreciated!)

@ashaduri ashaduri added the bug Something isn't working label Jul 13, 2021
@JohnVeness
Copy link
Author

I can see why it's not a good idea to run a browser as root! I know very little about this, but maybe you can (fork a process and?) drop root at runtime before calling gtk_show_uri etc.?

@ashaduri
Copy link
Owner

Yes, a helper process with less privileges is one possibility, but the hard part is to make launching it portable (at least across Linux distributions, because the root escalation is also distribution-dependent).

@hamishmb
Copy link

It would be good for security in general to launch the GUI as a normal user, then use pkexec to run smartctl when required, with a rule in /usr/share/polkit-1/actions to display an authentication dialog to the user with a nice message about what the privileges are needed for.

This would help on the more modern systems that don't allow X11 windows to run as root, and possibly avoids issues with Wayland in the future as well: https://wiki.archlinux.org/title/Running_GUI_applications_as_root#Wayland

@ashaduri
Copy link
Owner

ashaduri commented Sep 13, 2022

It would be good for security in general to launch the GUI as a normal user, then use pkexec to run smartctl when required, with a rule in /usr/share/polkit-1/actions to display an authentication dialog to the user with a nice message about what the privileges are needed for.

While it's a good idea in principle, last time I checked polkit did not allow you to specify the "keep" timeout after gaining the rights. There is only mention of a "brief" period in the specification, which is suggested to be 5 minutes. Asking for a password every 5 minutes while the program is running would be bad.
Also, gsmartcontrol itself needs elevated access to files sometimes, so it's not only for "smartctl" or "twcli" or similar backend commands.

The proper solution would be to have a single privileged subprocess (elevated via pkexec or some other way), let it do everything related to the system, and communicate back and forth with the GUI. Implementing this (especially in a cross-platform way) will take considerable amount of resources though.

@hamishmb
Copy link

That's a fair point. I wonder how that could be done in a cross-platform way.

On Linux I guess DBUS could be used, or maybe a socket, but I'm not sure how this might work on other platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants