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 yes as the value for the --set-defaults-any 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 auth_admin_keep_always, 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:
org.freedesktop.hal.power-management.shutdown no <-- (action, result)
org.freedesktop.hal.power-management.reboot no <-- (action, result)
org.freedesktop.hal.power-management.reboot no <-- (action, result)
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: yes and auth_admin_keep_always. Use the former if you want to allow anyone to perform the action. Use the latter if only administrators are allowed. auth_admin_keep_always will require you to authenticate yourself as a member of the wheel group (check /usr/local/etc/PolicyKit/PolicyKit.conf for define_admin_auth). 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 yes as the value for the --set-defaults-any 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 auth_admin_keep_always, 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 proc /proc procfs rw 0 0 to your /etc/fstab
2) # mount /proc
[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
You'll need to mount procfs by doing the following:polkit-auth: This operation requires the system message bus and ConsoleKit to be running
1) Add proc /proc procfs rw 0 0 to your /etc/fstab
2) # mount /proc
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 $ polkit-auth --show-obtainable. After successful authentication, the action will appear when you invoke $ polkit-auth and disappear from $ polkit-auth --show-obtainable.
Revoke authentication:
$ polkit-auth --revoke ACTION
ACTION is one of the actions listed from invoking $ polkit-auth. After this command, the action will appear back in the list given by the --show-obtainable 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!