Hardcode-Tray icon indicating copy to clipboard operation
Hardcode-Tray copied to clipboard

Improved user privilege handling

Open BlueManCZ opened this issue 4 years ago • 3 comments

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

BlueManCZ avatar Aug 05 '20 14:08 BlueManCZ

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

bilelmoussaoui avatar Aug 07 '20 08:08 bilelmoussaoui

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.

BlueManCZ avatar Aug 07 '20 10:08 BlueManCZ

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

bilelmoussaoui avatar Aug 24 '20 16:08 bilelmoussaoui