@@ -41,7 +41,7 @@ set_greeter_var()
41SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
41SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
42rm -f $SUB_SOCKET # clear socket in case we were hard shut down
42rm -f $SUB_SOCKET # clear socket in case we were hard shut down
44−rm -f "$XDG_RUNTIME_DIR/dbus-session"
44+echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" >"$XDG_RUNTIME_DIR/dbus-session"
46# If touch session script (which sets up grid units and mir variables) is available, use it
46# If touch session script (which sets up grid units and mir variables) is available, use it
47TOUCH_WRAPPER=
47TOUCH_WRAPPER=
@@ -66,11 +66,13 @@ set_greeter_var PA_DISABLED 1
66MIR_SOCKET=$SUB_SOCKET $TOUCH_WRAPPER /sbin/upstart --user --no-startup-event &
66MIR_SOCKET=$SUB_SOCKET $TOUCH_WRAPPER /sbin/upstart --user --no-startup-event &
67INIT_PID=$!
67INIT_PID=$!
68while [ ! -e "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session" ]; do sleep 0.1; done
68while [ ! -e "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session" ]; do sleep 0.1; done
69−export UPSTART_SESSION=$(/sbin/initctl list-sessions | grep "^$INIT_PID " | cut -d' ' -f2)
69+. "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session"
70+export UPSTART_SESSION
71−# Connect upstart to system.
72+# Connect upstart to system, but do first command in a loop to avoid any
72−echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}" >"$XDG_RUNTIME_DIR/dbus-session"
73+# race condition between the session file above being written and upstart being
74+# ready to handle requests.
73−/sbin/initctl notify-dbus-address "$DBUS_SESSION_BUS_ADDRESS"
75+while ! /sbin/initctl notify-dbus-address "$DBUS_SESSION_BUS_ADDRESS"; do sleep 0.1; done
74/sbin/initctl start notify-cgmanager
76/sbin/initctl start notify-cgmanager
76# Start any pre-greeter tasks if needed (like wizard)
78# Start any pre-greeter tasks if needed (like wizard)