How to Shutdown and Reboot in XFCE4
For the Practical Man
Description and Reason:
You just installed XFCE4 for FreeBSD but can't shutdown or reboot. Errors would show up that look like this:
You're getting these errors because PolicyKit is reporting to the system that you don't have the authorization to do the requested action.
Quick Fix:
Allow all users to shutdown and reboot:
Fix:
This will involve two commandline tools used for PolicyKit administration: polkit-action(1) and polkit-auth(1). Lets familiarize ourselves with these tools just enough so that we can figure out how to solve our problem. By the way, I always have HAL and DBUS enabled in my /etc/rc.conf. I don't know if it's required but lets just say that it is, because my keyboard and mouse dies if I disable them. Okay, lets continue.
polkit-action(1):
This is used to control the policies of each action; actions such as shutdown and reboot.
List actions supported by PolicyKit:
Get details of an action:
Change the policy of an action:
Reset an action to its default policy:
List actions that aren't using their default policy:
That's all you need to know about polkit-action(1). If you used [font="Courier New"]yes[/font] as the value for the [font="Courier New"]--set-defaults-any[/font] option, you're done! The changes should be immediate. You don't need to reboot, you don't even need to logout->login. However, if you've chosen [font="Courier New"]auth_admin_keep_always[/font], continue reading.
polkit-auth(1):
This is used to authenticate yourself to PolicyKit. You don't need to use sudo or become root, so you should log in as the user trying to authenticate.
List actions you're allowed to perform:
List actions that require authentication:
Authenticate for an action:
Revoke authentication:
That's it! This started out as a guide for shutdown and reboot, but it's really about basic PolicyKit administration. At this point, the commands under "quick fix" should be clear. You should also have an idea on how to enable other PolicyKit controlled actions such as auto-mounting. Try it!
For the Practical Man
Description and Reason:
You just installed XFCE4 for FreeBSD but can't shutdown or reboot. Errors would show up that look like this:
[font="Courier New"]org.freedesktop.hal.power-management.shutdown no <-- (action, result)
org.freedesktop.hal.power-management.reboot no <-- (action, result)[/font]
org.freedesktop.hal.power-management.reboot no <-- (action, result)[/font]
You're getting these errors because PolicyKit is reporting to the system that you don't have the authorization to do the requested action.
Quick Fix:
Allow all users to shutdown and reboot:
# polkit-action --set-defaults-any org.freedesktop.hal.power-management.shutdown yes
# polkit-action --set-defaults-any org.freedesktop.hal.power-management.reboot yes
Fix:
This will involve two commandline tools used for PolicyKit administration: polkit-action(1) and polkit-auth(1). Lets familiarize ourselves with these tools just enough so that we can figure out how to solve our problem. By the way, I always have HAL and DBUS enabled in my /etc/rc.conf. I don't know if it's required but lets just say that it is, because my keyboard and mouse dies if I disable them. Okay, lets continue.
polkit-action(1):
This is used to control the policies of each action; actions such as shutdown and reboot.
List actions supported by PolicyKit:
$ polkit-action
Get details of an action:
$ polkit-action --action ACTION
ACTION is one of the actions listed from invoking the command with no arguments.
Change the policy of an action:
# polkit-action --set-defaults-any ACTION VALUE
ACTION is one of the actions listed from invoking the command with no arguments.
VALUE can be one of several values, but we'll only concern ourselves with two of them: [font="Courier New"]yes[/font] and [font="Courier New"]auth_admin_keep_always[/font]. Use the former if you want to allow anyone to perform the action. Use the latter if only administrators are allowed. [font="Courier New"]auth_admin_keep_always[/font] will require you to authenticate yourself as a member of the wheel group (check /usr/local/etc/PolicyKit/PolicyKit.conf for [font="Courier New"]define_admin_auth[/font]). The "keep always" part means you'll only have to authenticate once. We'll get to authentication in a bit.
Reset an action to its default policy:
# polkit-action --reset-defaults ACTION
ACTION is one of the actions listed from invoking the command with no arguments.
List actions that aren't using their default policy:
$ polkit-action --show-overrides
That's all you need to know about polkit-action(1). If you used [font="Courier New"]yes[/font] as the value for the [font="Courier New"]--set-defaults-any[/font] option, you're done! The changes should be immediate. You don't need to reboot, you don't even need to logout->login. However, if you've chosen [font="Courier New"]auth_admin_keep_always[/font], continue reading.
polkit-auth(1):
This is used to authenticate yourself to PolicyKit. You don't need to use sudo or become root, so you should log in as the user trying to authenticate.
List actions you're allowed to perform:
$ polkit-auth
If you get an error like this:
1) Add [font="Courier New"]proc /proc procfs rw 0 0[/font] to your /etc/fstab
2) [font="Courier New"]# mount /proc[/font]
[font="Courier New"][WARN XXXX] Cannot lookup information for pid XXXX: No such file or directory
polkit-auth: This operation requires the system message bus and ConsoleKit to be running[/font]
You'll need to mount procfs by doing the following:polkit-auth: This operation requires the system message bus and ConsoleKit to be running[/font]
1) Add [font="Courier New"]proc /proc procfs rw 0 0[/font] to your /etc/fstab
2) [font="Courier New"]# mount /proc[/font]
List actions that require authentication:
$ polkit-auth --show-obtainable
Authenticate for an action:
$ polkit-auth --obtain ACTION
ACTION is one of the actions listed from [font="Courier New"]$ polkit-auth --show-obtainable[/font]. After successful authentication, the action will appear when you invoke [font="Courier New"]$ polkit-auth[/font] and disappear from [font="Courier New"]$ polkit-auth --show-obtainable[/font].
Revoke authentication:
$ polkit-auth --revoke ACTION
ACTION is one of the actions listed from invoking [font="Courier New"]$ polkit-auth[/font]. After this command, the action will appear back in the list given by the [font="Courier New"]--show-obtainable[/font] option.
That's it! This started out as a guide for shutdown and reboot, but it's really about basic PolicyKit administration. At this point, the commands under "quick fix" should be clear. You should also have an idea on how to enable other PolicyKit controlled actions such as auto-mounting. Try it!