Patch for LTSP clients to properly reboot/shutdown

Bug #491940 reported by Alkis Georgopoulos on 2009-12-03
80
This bug affects 14 people
Affects Status Importance Assigned to Milestone
gnome-session (Ubuntu)
Wishlist
Unassigned
ltsp (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: gnome-session

Please consider the following 4 lines for inclusion to debian/patch/95_dbus_request_shutdown.patch.
Those lines make LTSP clients properly reboot/shutdown.

gboolean
gsm_manager_request_shutdown (GsmManager *manager,
                              GError **error)
{
        g_debug ("GsmManager: RequestShutdown called");

        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);

        if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) {
                g_set_error (error,
                             GSM_MANAGER_ERROR,
                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
                             "RequestShutdown interface is only available during the Running phase");
                return FALSE;
        }

+ if (g_getenv ("LTSP_CLIENT"))
+ g_spawn_command_line_async("xprop -root -f LDM_LOGOUT_ACTION 8s -set LDM_LOGOUT_ACTION HALT", error);

        request_shutdown (manager);

        return TRUE;
}

gboolean
gsm_manager_request_reboot (GsmManager *manager,
                            GError **error)
{
        g_debug ("GsmManager: RequestReboot called");

        g_return_val_if_fail (GSM_IS_MANAGER (manager), FALSE);

        if (manager->priv->phase != GSM_MANAGER_PHASE_RUNNING) {
                g_set_error (error,
                             GSM_MANAGER_ERROR,
                             GSM_MANAGER_ERROR_NOT_IN_RUNNING,
                             "RequestReboot interface is only available during the Running phase");
                return FALSE;
        }

+ if (g_getenv ("LTSP_CLIENT"))
+ g_spawn_command_line_async("xprop -root -f LDM_LOGOUT_ACTION 8s -set LDM_LOGOUT_ACTION REBOOT", error);

        request_reboot (manager);

        return TRUE;
}

markakis (grigoris-markakis) wrote :

I had the same problem with my LTSP Clients. Ι can confirm that this patch enables me to reboot/shutdown my LTSP clients. Nice work !!!

Alkis Georgopoulos (alkisg) wrote :

I've uploaded in LTSP-upstream the necessary code to handle this xprop from the LTSP side:

http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/revision/1223
http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ltsp-trunk/revision/1465

So if the patch above was accepted in gnome-session, LTSP clients would properly halt/reboot in Lucid.
Thanks!

Alkis Georgopoulos (alkisg) wrote :

In case anyone else wants to test this, I've uploaded updated packages for gnome-session and LTSP (karmic) to this PPA:
https://launchpad.net/~ts.sch.gr/+archive/proposed

I've also uploaded a modified iTalc package there that calls gnome.SessionManager.RequestReboot/RequestShutdown via dbus-send instead of using gdm-signal, so iTalc should also be able to properly reboot and shutdown both on standalone and on LTSP installations (LP: #367960).

Strikos (nstrikos) wrote :

Works for me also!

Alkis Georgopoulos (alkisg) wrote :

Instead of g_spawn_command_line_async(), the following could also be used:

gdk_property_change(gdk_get_default_root_window(), gdk_atom_intern("LDM_LOGOUT_ACTION", FALSE), XA_STRING, 8, GDK_PROP_MODE_REPLACE, (guchar *) "HALT", strlen("HALT"));

...but that would require #including some additional headers, and I didn't want to be intrusive. So IMHO the g_spawn call is just fine.

Alkis Georgopoulos (alkisg) wrote :

LDM_LOGOUT_ACTION has been renamed to the more generic LTSP_LOGOUT_ACTION, in commit http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ltsp-trunk/revision/1481

So please use the following 4 lines instead:

+ if (g_getenv ("LTSP_CLIENT"))
+ g_spawn_command_line_async("xprop -root -f LTSP_LOGOUT_ACTION 8s -set LTSP_LOGOUT_ACTION HALT", error);

...

+ if (g_getenv ("LTSP_CLIENT"))
+ g_spawn_command_line_async("xprop -root -f LTSP_LOGOUT_ACTION 8s -set LTSP_LOGOUT_ACTION REBOOT", error);

Hoping that it'll be included in Lucid...

Alkis Georgopoulos (alkisg) wrote :

I uploaded patched gnome-session packages for Lucid in my PPA. So if anyone wants to test those 4 lines to verify that they solve the reboot/shutdown problem for thin clients, he just needs to do:

sudo add-apt-repository ppa:ts.sch.gr/proposed &&
sudo apt-get update &&
sudo apt-get dist-upgrade

apanagio (apanagio) wrote :

I just tested the new packages and they work for reboot/shutdown fine.
nice work, thanks a lot

tags: added: patch
Alkis Georgopoulos (alkisg) wrote :

The LTSP part of this patch has been committed two months ago in http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ltsp-trunk/revision/1481. Please include the gnome-session patch as well, it's been heavily tested and it works great.

Changed in ltsp (Ubuntu):
assignee: nobody → Alkis Georgopoulos (alkisg)
status: New → Fix Released
Benjamin Drung (bdrung) wrote :

I unsubscribed ubuntu-sponsors, because there is no debdiff to sponsor. I subscribe ubuntu-reviewers for the patch.

Chris Coulson (chrisccoulson) wrote :

The patch doesn't look right anyway - the extra hooks are in a code path that's only accessible from the dbus interface, which means that the shutdown behaviour from the indicator-session applet will be different to the shutdown behaviour initiated form the session dialog. It looks quite hacky anyway, could you please explain how this is all meant to work on LTSP?

Changed in gnome-session (Ubuntu):
importance: Undecided → Wishlist
Alkis Georgopoulos (alkisg) wrote :

The LTSP user session is running on the server through ssh -X.
The shutdown will need to be executed on the client.
LTSP is using xprops as a mechanism for the server to notify the client to execute something. It is indeed a hack, but that's the "standard" way we do it in LTSP. That's also the way localapps are implemented.

So when the user initiates shutdown, either from the indicator-session applet or from the session dialog (tested and working), an xprop is set. LTSP sessions are remote (ssh) sessions, so ConsoleKit does not consider them active. So a logoff is performed instead of a shutdown/reboot.
After the logoff, the LTSP display manager reads the xprop and sees if it needs to reboot or halt the client.

One better way to resolve this would be to implement appropriate dbus hooks so that the session bus running on the server "talks" to the system bus running on the client. Unfortunately, I don't think any LTSP developer is working on implementing this, and I don't even know if it can be accomplished.

In previous Ubuntu releases there was a patch in fusa that was hiding the reboot/shutdown menus for LTSP clients. This isn't used anymore, so now those menus are there but are just performing "logoff" instead, confusing the users.

So I'm not aware of any other realistic way to have working shutdown/reboot menus in LTSP, other than the attached patch.

Kind regards,
Alkis Georgopoulos
Edubuntu/LTSP developer

Alkis Georgopoulos (alkisg) wrote :

Reopening in LTSP, as it seems we'll need to find another method in order to get working shutdown/reboot menus, and I'm not sure if we have enough time left to make it for Lucid.

Maybe the indicator-session applet could be patched instead, like fusa was in previous releases, although patching gnome-session was much better because it worked with the session dialog as well, and with applications like iTalc that directly call dbus.

It'll be the first LTS release with that problem... if any fellow teacher needs a patched gnome-session to avoid having to explain to the students why the reboot/shutdown menus in Ubuntu are not working, he may find one in the PPA for Greek schools: https://launchpad.net/~ts.sch.gr/+archive/ppa/

Changed in ltsp (Ubuntu):
assignee: Alkis Georgopoulos (alkisg) → nobody
status: Fix Released → Confirmed
Alkis Georgopoulos (alkisg) wrote :

LXDE has added upstream support for LTSP reboot/shutdown, using the same method as the patch proposed here.
http://lxde.git.sourceforge.net/git/gitweb.cgi?p=lxde/lxsession;a=commit;h=d2508534100fddbac931fa60e3b989ae54ddf147

Thanks, pcman and vagrantc.

Maybe we'd have better luck trying upstream gnome support too...

Nigel Babu (nigelbabu) wrote :

Please forward the patch upstream, thanks for the patch.

tags: added: patch-needswork
removed: patch
Chris Coulson (chrisccoulson) wrote :

The patch can't go upstream, as it touches code which is currently specific to Ubuntu anyway

Nigel Babu (nigelbabu) wrote :

Ok, so I'll wait for chris's concerns to be addressed.

Alkis Georgopoulos (alkisg) wrote :

I've uploaded a patched gnome-session package in the Greek schools ppa. Now the clients properly reboot/shutdown from gnome-panel or from iTalc.

Anyone interested may other add the ppa to his sources and update by doing
  `sudo add-apt-repository ppa:ts.sch.gr && sudo apt-get update && sudo apt-get dist-upgrade`
or he can manually download the .deb from
  https://launchpad.net/~ts.sch.gr/+archive/ppa/+sourcepub/1134508/+listing-archive-extra

I tried to press the shutdown button on a thin client to test if the session menu would also work, but that button event never reaches the server, so I didn't even see the session menu (dbus events from the thin clients system bus do not propagate to the server). So the patched package works in all reproducible cases for me.

Alkis Georgopoulos (alkisg) wrote :

Is it possible for gnome-session to return to the parent process a different exit code based on what the user selected?
E.g.
logout => return 0
reboot => return 1
shutdown => return 2

This way LTSP could look at the exit code and act appropriately...

Or is there another way for LTSP to get notified about what the user selected in the logout dialog?

Stéphane Graber (stgraber) wrote :

Closing the LTSP task as it doesn't affect the LTSP package.

I'll subscribe directly to this bug instead.

Alkis: What's the status of this patch with more recent version of Ubuntu/Unity/Gnome3 ?

Changed in ltsp (Ubuntu):
status: Confirmed → Invalid
Alkis Georgopoulos (alkisg) wrote :

Sorry, no idea. We're using only LTS releases here, and I'm kinda pressed time-wise this year, so I won't be able to test with recent versions of the involved packages until Ubuntu 12.04, if it's still a problem then.

The LTSP task mainly referred to LTSP_LOGOUT_ACTION (commit http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ltsp-trunk/revision/1481), so yeah, either invalid or committed will do, until gnome-session can provide a method to notify the caller (LDM, xinit...) about the selected action (logout, reboot, shutdown).

Another approach is to at least make indicator-session policy-kit aware, so that it doesn't display the reboot/shutdown menu items at all:
https://bugs.launchpad.net/ubuntu/+source/indicator-session/+bug/474392

From a user's perspective, that's not as good as fixing gnome-session, because then the user loses logout/reboot/shutdown functionality from the menus.

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gnome-session (Ubuntu):
status: New → Confirmed
.cobnet (mattias-campe) wrote :

This is a bug from 2009, but could it be that this is still a problem when using autologin?

I used the tutorial https://help.ubuntu.com/community/UbuntuLTSP/AutoLoginFeatures, which works. The problem is when thin client users want to shut down their system, they are brought out to the login screen for a second and then immediately logged back in automatically to the desktop. How should I be shutting down the thin clients? See also http://ubuntuforums.org/showthread.php?t=1416186

I have a LTSP client that functions as a photo frame running gphotoframe. I have the following in lts.conf for that client

#Laptop ethernet
[00:0*:**:**:**:**]
LIKE=Atoms
# Used to allow auto login of clients
LDM_AUTOLOGIN=false
LDM_LOGIN_TIMEOUT=7

# Needed for LDM_LOGIN_TIMEOUT to work properly
LDM_GUESTLOGIN=true

LDM_USERNAME=media
LDM_PASSWORD=*******
#SOUND=N
#Auto Shut down
SHUTDOWN_TIME=20:00:00

I believe the lines that will solve the problem of the endless loop are:

LDM_AUTOLOGIN=false
LDM_LOGIN_TIMEOUT=7
LDM_GUESTLOGIN=true

The LDM_LOGIN_TIMEOUT parameter makes it wait that many seconds before automatically login in. Adjust it as you like.

I forgot to add in my last comment during the countdown open the menu in the bottom left corner called Prefrences and select Shutdown.

John Hupp (john.hupp) wrote :

If this bug refers to the inelegant and tedious behavior in which LTSP clients have to click Shutdown 3 times (once on the desktop, again in a Shutdown/Restart dialog, and the dropping back to the login screen, choose Preferences: Shutdown), then I confirm that it is still a problem under Ubuntu 12.04.

Alessio Comai (alecomai) wrote :

I installed an edubuntu 12.04 LTSP environment, but when I click "shutdown" on thin clients it does a logoff instead.
I tried to add
deb http://ppa.launchpad.net/ts.sch.gr/ppa/ubuntu precise main
deb-src http://ppa.launchpad.net/ts.sch.gr/ppa/ubuntu precise main
to my repositories and dist-upgraded
It installed 4 packeges and 15 updates (including gnome-panel)
I needed to reconfigure dhcpd.conf to make pxe boot working... but nothing changes.

the only way to shut down them is the procedure described by John Hupp (or open an epoptes gui, shut down all clients with one click and then shut down the last one as usual).
Someone solved it on 12.04?

Alkis Georgopoulos (alkisg) wrote :

Since the proposed patch was not accepted by the Ubuntu devs that maintain gnome-session, nor any alternative component was suggested to try to patch that instead, we didn't upload a patched gnome-session in the ts.sch.gr PPA for 12.04, it's only there for 10.04. So no point in adding the PPA in 12.04, it doesn't help with this problem.

We've developed Epoptes instead, which can shut down the LTSP clients in any Desktop Environment.

If upstream Gnome and Gnobuntu don't deprecate gnome-fallback, we'll try to send a patch there, otherwise Gnome will be unusable with LTSP in the future anyway, at least for thin clients (3d/llvmpipe over the network is extremely slow, and Unity-2D support was dropped). So maybe LTSP in the future will propose XFCE/LXDE instead of Gnome.

Bambang Pranoto (bpranoto) wrote :

My workaround for this problem is to send "halt" command to the underlying client o/s. Below are the steps needed, do in the server:

1. Chroot to the client environment:

$sudo chroot /opt/ltsp/i386

2. Define root password:

#passwd

3. Install openssh server and exit from chroot:

#apt-get install openssh-server
#exit

4. Update the client image:

$sudo ltsp-update-image

5. Create the down script:
#!/bin/bash
my_ip=`printenv|grep SSH_CONNECTION|sed 's/\(SSH_CONNECTION=\)\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)\(.*\)/\2/'`
ssh root@$my_ip halt

6. Place a launcher on client's desktop referring to the above script.

Alessio Comai (alecomai) wrote :

Thank you bpranoto, but I finally solved with a faster solution using epoptes:
I put a launcher on desktop referring to:

 /usr/share/epoptes-client/endsession --shutdown

thanks to alkisg for suggestion

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers