-
-
Notifications
You must be signed in to change notification settings - Fork 426
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
PolicyKit warnings; unable to manage services, restart system, or update packages #349
Comments
Just a heads up that when installed through KIAUH using multiple instaces, Be sure to restart your host if that is your case, that will still apply the changes made by the script. |
Implements scripts gymnastics to automate policykit rule installation. Moonraker now also has a post merge githook to handle unforeseen changes that would otherwise require the user to be familiar with ssh and linux. See: Arksine/moonraker#349 for more information.
Implements scripts gymnastics to automate policykit rule installation. Moonraker now also has a post merge githook to handle unforeseen changes that would otherwise require the user to be familiar with ssh and linux. See: Arksine/moonraker#349 for more information.
If you are running multiple instances then That said, officially I don't encourage the use of multiple instances, as Moonraker isn't designed to be "instance aware". |
After having issues with users running install scripts with sudo, even though nobody told them to do so, i tried the same with this update in moonraker, i did
|
Makes sense, IIRC the install script has this. I'll add it shortly. Thanks for the feedback. |
Although i know that Arksine does not encurage the use of multi instances in the style of KIAUH creates them, i just wanted to give a quick update that i just pushed a fix to KIAUH adressing that issue (dw-0/kiauh@a14e321) |
tested and working! thanks! <3 |
Oof this is a tough one @Arksine. If users update Moonraker they're locked out of their webinterface, so i can't fix it through RatOS scripting. It'll only work seamlessly if they update the RatOS module first. Would be nice with a transition period of a month (whatever the default package refresh interval is) or something where the policykit warnings are present, but policykit is still unused. Is that possible? EDIT: My goal here is to avoid having to teach users SSH and linux commands. |
That safeguard will break my automated policykit rule installation. I had to patch the $USER variable temporarily and run the script as root to avoid sudo prompts. There are a lot of sudo prefixed commands in that script that i would prefer not to whitelist for passwordless usage. Basically it would make it impossible to fix this without the user having to interact with the commandline. I know that's not a goal of yours, but things like these are why klipper is scary and unapproachable to people. |
Btw (and sorry for all the ranting here 😂), i will definitely transition to use policykit for RatOS scripts as well, it's definitely the right choice going forward, but it would be preferable if we could avoid breaking installations (for regular 3DP users) on the way there. EDIT: 13591d0 R.I.P my inbox 😂 |
@miklschmidt I'm not sure why this change would lock users out of the WebUI, it should simply result in warnings and an error if the user attempts to invoke an endpoint that requires those permissions. Users can configure the CLI fallbacks to restore access to these endpoints. The warnings won't show up in this scenario, however it may be possible to add a way to do this.
If necessary I can add a command line parameter that disables the sudo check. Presumably all of the commands in the script would need to run without sudo access for this to work, as it would assume the that script is run by root. |
@Arksine True, you just can't restart services or access the update manager (which kills my automation). This was compounded with the recent pip/piwheel issue, sorry about that. I'll make a script that tries to patch moonraker.conf and enables the cli fallback, that way i can give people some time to get everything updated before switching back to policykit. It's just too late for me to do anything if people update moonraker first, because then they can't update RatOS.
That would be nice, currently i'm copying and patching up the setup script to skip the check each time the RatOS or moonraker post-merge hook is run. Only if the rules aren't already present though.
Yeah, however it does work even with sudo if run as root, so don't go through the trouble for me :) Thanks for bearing with me, it's been a tough weekend with all the pings and panic 😂 |
@miklschmidt All is good, been one of those days 😄 I have released a workaround for the pip issue, #352 (comment). It will require ssh, not ideal but it can get folks back up and running. We can track pypa/pip#10847, when that is merged and released I believe that it users will be able to update Moonraker without issue. I also added a |
@Arksine Awesome, i used that to fix one users broken installation 30 minutes ago, it does the trick. I made an announcement to the users earlier today to hold off on updating until further notice, that stopped the bulk of the carnage :D Fixed the script to use the I will follow along on the pip issue :) |
@ssjbardock If the polkit rules aren't working there is something about either the OS or the Moonraker installation that deviates from the standard. If you haven't been able to resolve this I would suggest creating a new issue. Make sure you attach moonraker.log and give details about your OS. Detail the process you used to install moonraker and any deviations from the instructions outlined in the documentation. |
@Arksine @StuSerious It seems that you might benefit from |
Moonraker requires permission to perform administrative tasks such as restarting another service, updating packages, and rebooting the system. That said, it is completely possible to disable this functionality in the configuration, in which case you will get no warnings. Your solution won't grant Moonraker permission to do these things, and I suspect it would break the aforementioned functionality. |
How exactly does this work? |
Moonraker connects to systemd over dbus issues commands. For updating packages it connects to packagekit over dbus. PolKit is used to grant Moonraker privileged access. If Moonraker is configured to use dbus for sysadmin the polkit rules must be applied, otherwise Moonraker will generate warnings. For this to work the user must be consistent and it must be defined in the rules (at least on Debian, other distros with newer versions of polkit may not be subject to this limitation). The legacy implementation uses sudo commands and requires that the OS grant the Moonraker user (typically "Pi") "no password" sudo access. |
Hi @Arksine, I did some research and it is possible to control services started with
This should resolve the issue of service control. The only question is where to keep this I still do not understand why you need to implement package update here though. My position is that this is redundant and should be removed. We have package managers exactly for that. It would also make the process of distribution and code maintenance much easier. |
This announcement is an effort to get ahead of a coming change that will certainly result in issues. PR #346 has been merged, and with it are some changes to Moonraker's default behavior.
It is desirable to move away from having Mooraker spawn "sudo" commands to collect system data, manage systemd services, reboot/shutdown the machine, and update packages. We can do this through the Linux D-Bus interface, however to do so we must add PolicyKit rules that grant Moonraker specific privileges. Currently Moonraker's
update_manager
isn't equipped to make these changes, and it would be unwise to automatically make such a change.As such, after updating users will need to
ssh
into their machine (or open a terminal on Desktops) and run the following new script:Once the rules are installed Moonraker will restart and all necessary permissions should be available. Users of Debian and its derivatives (Raspberry Pi OS, Ubuntu, etc) should note that they ship with an older version of PolKit, which can only grant permissions on a per user or per group basis. This means that any DBus application run by the user will have the same privileges Moonraker has. For example, you can run
systemctl restart klipper
without sudo. Newer versions of PolKit (those included in Arch, etc) allow for more fine grained rules, only the Moonraker process will be granted such privileges.If managing services and/or updating packages is not important to you, it is possible to disable this functionality rather than add the PolKit rules:
Its also possible to use the CLI Fallbacks. Take note however that it is likely that these will be deprecated and removed in the future:
One final note on package updates: To use the packagekit backend it is necessary to install packagekit. For most this would have been done on the last update. However, if the update manager fails to update packages its a good idea to ssh into the pi and run the install script with no options. This will update all dependencies and install new ones:
The text was updated successfully, but these errors were encountered: