Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Enabling shutdown in XFCE menu

622 views
Skip to first unread message

Keve Nagy

unread,
Jan 29, 2016, 7:28:38 PM1/29/16
to
Good Evening Everyone,
I wonder if somebody can tell me what this depends on.
I would like to allow a mortal FreeBSD user to shut down the computer
from an X desktop. XFCE is being used, which has shutdown and reboot
options in its main menu. When I startx as root, these items are
clickable in the menu. When the mortal user account does startx, the
same shutdown and reboot options in the XFCE manu are grayed out.

Now, the mortal user account is a member of the wheel and operator
groups, so it can perform a proper "shutdown -p now" in any command line
and the computer does power down nicely.
Also, as suggested by the xfce-session package, I have created a new
file named 40-desktopuser.rules in /usr/local/etc/polkit-1/rules.d/ with
the below contents:

polkit.addRule(function (action, subject) {
if (action.id == "org.freedesktop.consolekit.system.restart" ||
action.id == "org.freedesktop.consolekit.system.stop"
&& subject.isInGroup("desktopuser")) {
return polkit.Result.YES;
}
});

polkit.addRule(function (action, subject) {
if (action.id == "org.freedesktop.consolekit.system.suspend"
&& subject.isInGroup("desktopuser")) {
return polkit.Result.YES;
}
});

The mortal user has been added to the desktopuser group.
The user is still unable to shut down the PC from the XFCE menu, as the
item is still disabled. Unfortunatelly, I couldn't find how to confirm
if my rules from the .rules file are actually loaded and have effect.
The sample rules file that comes with the package mentiones to read
polkit(8), but man 8 polkit and man 8 PolKit finds no available manual
pages.

I also checked the Handbook to see if any recent updates provide
instructions on such settings, but found nothing related.

How do I enable the shutdown/reboot items in the XFCE menu? What does
the mortal user need in order to XFCE enable those menu items?
Ultimately, I plan to enable xdm or gdm, so that the computer starts
with a GUI automatically. Would that make the shutdown option available
for X users?

Regards,
Keve Nagy * Debrecen * Hungary
--
to contact me directly:
keve(at)safe-mail(dot)net

Winston

unread,
Jan 30, 2016, 12:34:17 AM1/30/16
to
I don't know the answer to your main question, but for this:

Keve Nagy <inv...@see.my.sig> posted:
> The sample rules file that comes with the package mentiones to read
> polkit(8), but man 8 polkit and man 8 PolKit finds no available manual
> pages.

Googling "FreeBSD, man 8 polkit" found:

http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man8/polkit.8.html

Related man pages may include:

polkit-action(1) - List and modify registered PolicyKit actions
polkit-auth(1) - Manage authorizations
polkit-config-file-validate(1) - Validate a PolicyKit configuration file
polkit-policy-file-validate(1) - Validate a PolicyKit policy file

HTH,
-WBE

Keve Nagy

unread,
Jan 30, 2016, 3:20:10 AM1/30/16
to
Winston wrote:
> I don't know the answer to your main question, but for this:
>
>> The sample rules file that comes with the package mentiones to read
>> polkit(8), but man 8 polkit and man 8 PolKit finds no available manual
>> pages.
>
> Googling "FreeBSD, man 8 polkit" found:
>
> http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man8/polkit.8.html

Good catch.
Thanks for the link, Winston!

Regards,
Keve

Keve Nagy

unread,
Jan 30, 2016, 6:17:56 PM1/30/16
to
After investing two more days into researching this, and doing all sorts
of jiggery-pokery in configuration and rules files, I can finally
conclude that YOU DON'T NEED ANY OF THOSE.

The way XFCE gets setup when installed as a pkg, already sets everything
up for mortal users to be able to shutdown or reboot the computer.
Everything is done through PolicyKit/ConsoleKit, hence my earlier
attempt in writing blocks of rubbish like the one above.
Unfortunately, it did not matter what kind of magic I applied to my
config, because they were never used when startx initiated XFCE. In
order for my XFCE session to utilise ConsoleKit/PolicyKit, it needs to
be started THROUGH a ConsoleKit Session.

The solution:
Make sure that your XFCE session is started by
ck-lauch-session xfce4-session
instead of just
xfce4-session
The ck-launch-session in front of xfce4-session will start your XFCE
session INSIDE a ConsoleKit session, which will then make use of the
already (factory) configured rules, including access to shutdown and reboot.

On a side note, the xinitrc that ships with XFCE does have some code in
it to handle this out-of-the-box. However, it checks for an environment
variable $XFCE4_SESSION_WITH_CK and calls xfce4-session alone if this
veriable is not set, or calls it via ck-launch-session if the variable
is set. I don't know where this variable was supposed to be initialized,
but as it was never set, my xinitrc always started xcfe4-session alone.
So one more time, if you need ConsoleKit functionality, make sure your X
session is started via ck-launch-session!

Torfinn Ingolfsen

unread,
Jan 31, 2016, 5:21:14 AM1/31/16
to
On 01/31/2016 00:17, Keve Nagy wrote:
> Keve Nagy wrote:
>
>
> The solution:
> Make sure that your XFCE session is started by
> ck-lauch-session xfce4-session
> instead of just
> xfce4-session
> The ck-launch-session in front of xfce4-session will start your XFCE
> session INSIDE a ConsoleKit session, which will then make use of the
> already (factory) configured rules, including access to shutdown and
> reboot.
>

Very useful. Thanks for posting the solution follow-up.

--
Torfinn Ingolfsen,
Norway

Thomas Mueller

unread,
Feb 3, 2016, 9:16:03 AM2/3/16
to
On Sun, 31 Jan 2016 00:17:51 +0100, Keve Nagy wrote:
> The solution:
> Make sure that your XFCE session is started by
> ck-lauch-session xfce4-session
> instead of just
> xfce4-session
> The ck-launch-session in front of xfce4-session will start your XFCE
> session INSIDE a ConsoleKit session, which will then make use of the
> already (factory) configured rules, including access to shutdown and reboot.
>
> On a side note, the xinitrc that ships with XFCE does have some code in
> it to handle this out-of-the-box. However, it checks for an environment
> variable $XFCE4_SESSION_WITH_CK and calls xfce4-session alone if this
> veriable is not set, or calls it via ck-launch-session if the variable
> is set. I don't know where this variable was supposed to be initialized,
> but as it was never set, my xinitrc always started xcfe4-session alone.

startxfce sets $XFCE4_SESSION_WITH_CK when given --with-ck-launch on
the command line.

--
Thomas Mueller

Torfinn Ingolfsen

unread,
Feb 3, 2016, 1:49:30 PM2/3/16
to
On 02/03/2016 15:16, Thomas Mueller wrote:
>
> startxfce sets $XFCE4_SESSION_WITH_CK when given --with-ck-launch on
> the command line.

Useful info.
Thanks!
--
Torfinn Ingolfsen,
Norway

Keve Nagy

unread,
Feb 6, 2016, 10:59:09 AM2/6/16
to
Excellent.
Thank you!

Regards,
Keve
0 new messages