]> rtime.felk.cvut.cz Git - sojka/lightdm.git/commitdiff
Don't assume display server is an X server when running scripts - fixes crashes runni...
authorRobert Ancell <robert.ancell@canonical.com>
Mon, 1 Sep 2014 05:01:15 +0000 (17:01 +1200)
committerRobert Ancell <robert.ancell@canonical.com>
Mon, 1 Sep 2014 05:01:15 +0000 (17:01 +1200)
src/seat-unity.c
src/seat-xlocal.c
tests/Makefile.am
tests/scripts/mir-script-hooks.conf [new file with mode: 0644]
tests/scripts/unity-mir-script-hooks.conf [new file with mode: 0644]
tests/scripts/unity-script-hooks.conf [new file with mode: 0644]
tests/test-mir-script-hooks [new file with mode: 0755]
tests/test-unity-mir-script-hooks [new file with mode: 0755]
tests/test-unity-script-hooks [new file with mode: 0755]

index 98a0fa33653ac0e89efdda32b7eae80951763cf5..df538b09b368e23a27b0f53982e21e4ec42cedae 100644 (file)
@@ -383,10 +383,13 @@ seat_unity_run_script (Seat *seat, DisplayServer *display_server, Process *scrip
     const gchar *path;
     XServerLocal *x_server;
 
-    x_server = X_SERVER_LOCAL (display_server);
-    path = x_server_local_get_authority_file_path (x_server);
-    process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
-    process_set_env (script, "XAUTHORITY", path);
+    if (IS_X_SERVER_LOCAL (display_server))
+    {
+        x_server = X_SERVER_LOCAL (display_server);
+        path = x_server_local_get_authority_file_path (x_server);
+        process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
+        process_set_env (script, "XAUTHORITY", path);
+    }
 
     SEAT_CLASS (seat_unity_parent_class)->run_script (seat, display_server, script);
 }
index e0bd08e7d97620a0d135eba40b275d4c55c88b1b..9fa9f683c62a33efc8d888b59b94ef9ea5439235 100644 (file)
@@ -343,10 +343,13 @@ seat_xlocal_run_script (Seat *seat, DisplayServer *display_server, Process *scri
     const gchar *path;
     XServerLocal *x_server;
 
-    x_server = X_SERVER_LOCAL (display_server);
-    path = x_server_local_get_authority_file_path (x_server);
-    process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
-    process_set_env (script, "XAUTHORITY", path);
+    if (IS_X_SERVER_LOCAL (display_server))
+    {
+        x_server = X_SERVER_LOCAL (display_server);
+        path = x_server_local_get_authority_file_path (x_server);
+        process_set_env (script, "DISPLAY", x_server_get_address (X_SERVER (x_server)));
+        process_set_env (script, "XAUTHORITY", path);
+    }
 
     SEAT_CLASS (seat_xlocal_parent_class)->run_script (seat, display_server, script);
 }
index 1685d28365ce75bcfeac8297daa14ef2b0dce6ae..81d1491d74cd40849803e8762adf9df76260bd3b 100644 (file)
@@ -189,6 +189,7 @@ TESTS = \
        test-mir-session-crash \
        test-mir-session-compositor-crash \
        test-mir-container-session \
+       test-mir-script-hooks \
        test-unity-compositor-command \
        test-unity-compositor-not-found \
        test-unity-compositor-fail-start \
@@ -201,13 +202,15 @@ TESTS = \
        test-unity-login \
        test-unity-switch \
        test-unity-plymouth \
+       test-unity-script-hooks \
        test-unity-mir-autologin \
        test-unity-mir-greeter-x-session \
        test-unity-mir-greeter-mir-session \
        test-unity-mir-lock-seat \
        test-unity-mir-session-x-greeter \
        test-unity-mir-switch \
-       test-unity-mir-switch-to-user-resettable
+       test-unity-mir-switch-to-user-resettable \
+       test-unity-mir-script-hooks
 
 #      test-session-exit-error
 #      test-greeter-no-exit
@@ -442,6 +445,7 @@ EXTRA_DIST = \
        scripts/mir-autologin.conf \
        scripts/mir-container-session.conf \
        scripts/mir-greeter.conf \
+       scripts/mir-script-hooks.conf \
        scripts/mir-session.conf \
        scripts/mir-session-compositor-crash.conf \
        scripts/mir-session-crash.conf \
@@ -514,10 +518,12 @@ EXTRA_DIST = \
        scripts/unity-mir-greeter-mir-session.conf \
        scripts/unity-mir-lock-seat.conf \
        scripts/unity-mir-greeter-x-session.conf \
+       scripts/unity-mir-script-hooks.conf \
        scripts/unity-mir-session-x-greeter.conf \
        scripts/unity-mir-switch.conf \
        scripts/unity-mir-switch-to-user-resettable.conf \
        scripts/unity-plymouth.conf \
+       scripts/unity-script-hooks.conf \
        scripts/unity-switch.conf \
        scripts/upstart-autologin.conf \
        scripts/upstart-login.conf \
diff --git a/tests/scripts/mir-script-hooks.conf b/tests/scripts/mir-script-hooks.conf
new file mode 100644 (file)
index 0000000..1663939
--- /dev/null
@@ -0,0 +1,71 @@
+#
+# Check LightDM runs the script hooks correctly for autologin and the greeter
+#
+
+[SeatDefaults]
+display-setup-script=test-script-hook DISPLAY-SETUP
+display-stopped-script=test-script-hook DISPLAY-STOPPED
+greeter-setup-script=test-script-hook GREETER-SETUP
+session-setup-script=test-script-hook SESSION-SETUP
+session-cleanup-script=test-script-hook SESSION-CLEANUP
+autologin-user=have-password1
+user-session=mir
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/lightdm-mir-0 VT=7 ENABLE-HARDWARE-CURSOR=TRUE XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK SESSION-SETUP USER=have-password1
+
+# Session starts
+#?SESSION-MIR-session-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=mir XDG_SESSION_DESKTOP=mir USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+
+# Session shown
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=session-0
+
+# Logout session
+#?*SESSION-MIR-session-0 LOGOUT
+
+# Script hooks runs
+#?SCRIPT-HOOK SESSION-CLEANUP USER=have-password1
+
+# System compositor stops
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-STOPPED
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/lightdm-mir-0 VT=7 ENABLE-HARDWARE-CURSOR=TRUE XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK GREETER-SETUP USER=.*
+
+# Greeter starts
+#?GREETER-MIR-greeter-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
+#?GREETER-MIR-greeter-0 CONNECT-TO-DAEMON
+# FIXME: Not occurring?
+##?GREETER-MIR-greeter-0 CONNECTED-TO-DAEMON
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=greeter-0
+
+# Cleanup
+#?*STOP-DAEMON
+#?GREETER-MIR-greeter-0 TERMINATE SIGNAL=15
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-STOPPED
+
+# Finish cleanup
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/unity-mir-script-hooks.conf b/tests/scripts/unity-mir-script-hooks.conf
new file mode 100644 (file)
index 0000000..dbf6e68
--- /dev/null
@@ -0,0 +1,61 @@
+#
+# Check LightDM runs the script hooks correctly for autologin and the greeter
+#
+
+[SeatDefaults]
+type=unity
+display-setup-script=test-script-hook DISPLAY-SETUP
+display-stopped-script=test-script-hook DISPLAY-STOPPED
+greeter-setup-script=test-script-hook GREETER-SETUP
+session-setup-script=test-script-hook SESSION-SETUP
+session-cleanup-script=test-script-hook SESSION-CLEANUP
+autologin-user=have-password1
+user-session=mir
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK SESSION-SETUP USER=have-password1
+
+# Session starts
+#?SESSION-MIR-session-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=mir XDG_SESSION_DESKTOP=mir USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=session-0
+
+# Logout session
+#?*SESSION-MIR-session-0 LOGOUT
+
+# Script hooks runs
+#?SCRIPT-HOOK SESSION-CLEANUP USER=have-password1
+# FIXME: order wrong here?
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK DISPLAY-STOPPED
+#?SCRIPT-HOOK GREETER-SETUP USER=.*
+
+# Greeter starts
+#?GREETER-MIR-greeter-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
+#?GREETER-MIR-greeter-0 CONNECT-TO-DAEMON
+#?GREETER-MIR-greeter-0 CONNECTED-TO-DAEMON
+
+# System compositor switches to greeter
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=greeter-0
+
+# Cleanup
+#?*STOP-DAEMON
+#?GREETER-MIR-greeter-0 TERMINATE SIGNAL=15
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-STOPPED
+
+# Finish cleanup
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/scripts/unity-script-hooks.conf b/tests/scripts/unity-script-hooks.conf
new file mode 100644 (file)
index 0000000..4db13cf
--- /dev/null
@@ -0,0 +1,87 @@
+#
+# Check LightDM runs the script hooks correctly for autologin and the greeter
+#
+
+[SeatDefaults]
+type=unity
+display-setup-script=test-script-hook DISPLAY-SETUP
+display-stopped-script=test-script-hook DISPLAY-STOPPED
+greeter-setup-script=test-script-hook GREETER-SETUP
+session-setup-script=test-script-hook SESSION-SETUP
+session-cleanup-script=test-script-hook SESSION-CLEANUP
+autologin-user=have-password1
+user-session=default
+
+#?*START-DAEMON
+#?RUNNER DAEMON-START
+
+# System compositor starts
+#?UNITY-SYSTEM-COMPOSITOR START FILE=/run/mir_socket VT=7 XDG_VTNR=7
+#?*UNITY-SYSTEM-COMPOSITOR READY
+
+# X server starts
+#?XSERVER-0 START SEAT=seat0 MIR-ID=x-0
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK SESSION-SETUP USER=have-password1
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_GREETER_DATA_DIR=.*/have-password1 XDG_SESSION_TYPE=x11 XDG_SESSION_DESKTOP=default USER=have-password1
+#?LOGIN1 ACTIVATE-SESSION SESSION=c0
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-0
+
+# Logout session
+#?*SESSION-X-0 LOGOUT
+
+# Script hook runs
+#?SCRIPT-HOOK SESSION-CLEANUP USER=have-password1
+
+# X server stops
+#?XSERVER-0 TERMINATE SIGNAL=15
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-STOPPED
+
+# X server starts
+#?XSERVER-1 START SEAT=seat0 MIR-ID=x-1
+
+# Daemon connects when X server is ready
+#?*XSERVER-1 INDICATE-READY
+#?XSERVER-1 INDICATE-READY
+#?XSERVER-1 ACCEPT-CONNECT
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-SETUP
+#?SCRIPT-HOOK GREETER-SETUP USER=.*
+
+# Greeter starts
+#?GREETER-X-1 START XDG_SEAT=seat0 XDG_VTNR=7 XDG_SESSION_CLASS=greeter
+#?LOGIN1 ACTIVATE-SESSION SESSION=c1
+#?XSERVER-1 ACCEPT-CONNECT
+#?GREETER-X-1 CONNECT-XSERVER
+#?GREETER-X-1 CONNECT-TO-DAEMON
+#?GREETER-X-1 CONNECTED-TO-DAEMON
+
+# System compositor switches to session
+#?UNITY-SYSTEM-COMPOSITOR SET-ACTIVE-SESSION ID=x-1
+
+# Cleanup
+#?*STOP-DAEMON
+#?GREETER-X-1 TERMINATE SIGNAL=15
+#?XSERVER-1 TERMINATE SIGNAL=15
+
+# Script hooks run
+#?SCRIPT-HOOK DISPLAY-STOPPED
+
+# Finish cleanup
+#?UNITY-SYSTEM-COMPOSITOR TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
diff --git a/tests/test-mir-script-hooks b/tests/test-mir-script-hooks
new file mode 100755 (executable)
index 0000000..1cc1944
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner mir-script-hooks test-mir-greeter
diff --git a/tests/test-unity-mir-script-hooks b/tests/test-unity-mir-script-hooks
new file mode 100755 (executable)
index 0000000..be7f182
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner unity-mir-script-hooks test-mir-greeter
diff --git a/tests/test-unity-script-hooks b/tests/test-unity-script-hooks
new file mode 100755 (executable)
index 0000000..5c59de2
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+./src/dbus-env ./src/test-runner unity-script-hooks test-gobject-greeter