bilelmoussaoui / Hardcode-Tray

Fixes Hardcoded tray icons in Linux
Other
863 stars 63 forks source link

Improved user privilege handling #654

Open BlueManCZ opened 4 years ago

BlueManCZ commented 4 years ago

This fix allows executing Hardcode-Tray by a regular user for actions, that don't require root privileges (getting version or clearing cache).

Just a reminder. Old cache owned by root should be removed before testing. sudo rm -rf ~/.config/Hardcode-Tray

Closes https://github.com/bilelmoussaoui/Hardcode-Tray/issues/397 and closes https://github.com/bilelmoussaoui/Hardcode-Tray/issues/645

bilelmoussaoui commented 4 years ago

I would go one step further and add a proper to Application that tells if the app touches files specific to the user or not. This way you can ask for root only when really necessary

BlueManCZ commented 4 years ago

And is there any easy way to do this without having to redesign the entire code? I mean, the edit I made contains only a few changed lines and result is much more user friendly. I tried to search for PolicyKit and pkexec handling in Python but didn't find very much.

bilelmoussaoui commented 4 years ago

And is there any easy way to do this without having to redesign the entire code? I mean, the edit I made contains only a few changed lines and result is much more user friendly. I tried to search for PolicyKit and pkexec handling in Python but didn't find very much.

You don't need to do any of that, you can add a property to Application with needs_root, set it to false by default, detect if the icons/files are in a directory other than /home and toggle the needs_root property accordingly. On the main app, you can then request root only if you have at least one app that needs_root