A PkexecUtil class is provided to be reused by other tools like smartctl or nvme-cli in the future.
This implements a way to ship a pkexec policy file and to ask the user to install it when missing, once pkexec exec method is selected.
This provides a policy file for ipmi-sensors for now.
For now the /usr/sbin/ prefix for super user binaries is hardcoded, I'm not sure we can generate a policy file on the fly, so maybe there is no good way to not hardcode this.
If setting up pkexec fails (because either pkexec is not found, the super user binary (here /usr/sbin/ipmi-sensors) is not found, or the user did did not gave the right password, the settings is reset to direct to avoid endless password requests).
One known bug is that when the setting is reset on failure, the preferences window do not update, but closing the preference window and reopening it shows the setting is properly reset.
I'm not fluent in javascript so there may be better ways to do it.
I believe it's better to merge this than to wait for something better, because right now the current code in master annoys the user with endless password requests, those password requests taking priority and preventing to reset the option.
A
PkexecUtil
class is provided to be reused by other tools likesmartctl
ornvme-cli
in the future.This implements a way to ship a pkexec policy file and to ask the user to install it when missing, once
pkexec
exec method is selected.This provides a policy file for
ipmi-sensors
for now.For now the
/usr/sbin/
prefix for super user binaries is hardcoded, I'm not sure we can generate a policy file on the fly, so maybe there is no good way to not hardcode this.If setting up pkexec fails (because either pkexec is not found, the super user binary (here
/usr/sbin/ipmi-sensors
) is not found, or the user did did not gave the right password, the settings is reset todirect
to avoid endless password requests).One known bug is that when the setting is reset on failure, the preferences window do not update, but closing the preference window and reopening it shows the setting is properly reset.
I'm not fluent in javascript so there may be better ways to do it.
I believe it's better to merge this than to wait for something better, because right now the current code in master annoys the user with endless password requests, those password requests taking priority and preventing to reset the option.
Fixes #272: