}
}
+static Session *
+find_user_session (Seat *seat, const gchar *username, Session *ignore_session)
+{
+ GList *link;
+
+ if (!username)
+ return NULL;
+
+ for (link = seat->priv->sessions; link; link = link->next)
+ {
+ Session *session = link->data;
+
+ if (session == ignore_session)
+ continue;
+
+ if (!session_get_is_stopping (session) && strcmp (session_get_username (session), username) == 0)
+ return session;
+ }
+
+ return NULL;
+}
+
static void
session_authentication_complete_cb (Session *session, Seat *seat)
{
if (session_get_is_authenticated (session))
{
- l_debug (seat, "Session authenticated, running command");
- run_session (seat, session);
+ Session *s;
+
+ s = find_user_session (seat, session_get_username (session), session);
+ if (s)
+ {
+ l_debug (seat, "Session authenticated, switching to existing user session");
+ seat_set_active_session (seat, s);
+ session_stop (session);
+ }
+ else
+ {
+ l_debug (seat, "Session authenticated, running command");
+ run_session (seat, session);
+ }
}
else if (!IS_GREETER (session))
{
else
l_debug (seat, "Can't find session '%s'", seat_get_string_property (seat, "user-session"));
-
g_object_unref (user);
return session;
*argv = new_argv;
}
-static Session *
-find_user_session (Seat *seat, const gchar *username)
-{
- GList *link;
-
- if (!username)
- return NULL;
-
- for (link = seat->priv->sessions; link; link = link->next)
- {
- Session *session = link->data;
-
- if (!session_get_is_stopping (session) && strcmp (session_get_username (session), username) == 0)
- return session;
- }
-
- return NULL;
-}
-
static gboolean
greeter_start_session_cb (Greeter *greeter, SessionType type, const gchar *session_name, Seat *seat)
{
/* Return to existing session if it is open */
username = session_get_username (session);
- existing_session = find_user_session (seat, username);
+ existing_session = find_user_session (seat, username, NULL);
if (existing_session && session != existing_session)
{
l_debug (seat, "Returning to existing user session %s", username);
l_debug (seat, "Switching to user %s", username);
- session = find_user_session (seat, username);
- if (session)
- {
- l_debug (seat, "Switching to existing user session %s", username);
- seat_set_active_session (seat, session);
- return TRUE;
- }
-
session = create_user_session (seat, username);
if (!session)
return FALSE;
test-switch-to-user \
test-switch-to-users \
test-switch-to-user-existing-session \
+ test-switch-to-user-switch-back \
test-switch-to-user-no-password \
test-switch-to-user-logout \
test-vnc-login \
scripts/switch-to-user-existing-session.conf \
scripts/switch-to-user-logout.conf \
scripts/switch-to-user-no-password.conf \
+ scripts/switch-to-user-switch-back.conf \
scripts/system-xauthority.conf \
scripts/unity-autologin.conf \
scripts/unity-compositor-command.conf \
#
[SeatDefaults]
-autologin-user=have-password1
+autologin-user=no-password1
user-session=default
#?RUNNER DAEMON-START
#?XSERVER-0 ACCEPT-CONNECT
# Session starts
-#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 USER=have-password1
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 USER=no-password1
#?XSERVER-0 ACCEPT-CONNECT
#?SESSION-X-0 CONNECT-XSERVER
#?VT ACTIVATE VT=8
# Login
-#?*GREETER-X-1 AUTHENTICATE USERNAME=have-password2
-#?GREETER-X-1 SHOW-PROMPT TEXT="Password:"
-#?*GREETER-X-1 RESPOND TEXT="password"
-#?GREETER-X-1 AUTHENTICATION-COMPLETE USERNAME=have-password2 AUTHENTICATED=TRUE
+#?*GREETER-X-1 AUTHENTICATE USERNAME=no-password2
+#?GREETER-X-1 AUTHENTICATION-COMPLETE USERNAME=no-password2 AUTHENTICATED=TRUE
#?*GREETER-X-1 START-SESSION
#?GREETER-X-1 TERMINATE SIGNAL=15
# New session starts
-#?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=8 USER=have-password2
+#?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=8 USER=no-password2
#?XSERVER-1 ACCEPT-CONNECT
#?SESSION-X-1 CONNECT-XSERVER
# Switch to old session
-#?*SWITCH-TO-USER USERNAME=have-password1
-#?RUNNER SWITCH-TO-USER USERNAME=have-password1
-
-# Existing session is unlocked
-#?LOGIN1 UNLOCK-SESSION
-
-# Switch to greeter
-#?VT ACTIVATE VT=7
+#?*SWITCH-TO-USER USERNAME=no-password1
+#?RUNNER SWITCH-TO-USER USERNAME=no-password1
# Session is locked
#?LOGIN1 LOCK-SESSION
--- /dev/null
+#
+# Check that switching to a user and switching back works
+#
+
+[SeatDefaults]
+autologin-user=have-password1
+user-session=default
+
+#?RUNNER DAEMON-START
+#?*WAIT
+
+# X server starts
+#?XSERVER-0 START VT=7
+
+# Daemon connects when X server is ready
+#?*XSERVER-0 INDICATE-READY
+#?XSERVER-0 INDICATE-READY
+#?XSERVER-0 ACCEPT-CONNECT
+
+# Session starts
+#?SESSION-X-0 START XDG_SEAT=seat0 XDG_VTNR=7 USER=have-password1
+#?XSERVER-0 ACCEPT-CONNECT
+#?SESSION-X-0 CONNECT-XSERVER
+
+# Switch to another account
+#?*SWITCH-TO-USER USERNAME=no-password1
+#?RUNNER SWITCH-TO-USER USERNAME=no-password1
+
+# New X server starts
+#?XSERVER-1 START VT=8
+
+# Daemon connects when X server is ready
+#?*XSERVER-1 INDICATE-READY
+#?XSERVER-1 INDICATE-READY
+#?XSERVER-1 ACCEPT-CONNECT
+
+# Old session is locked
+#?LOGIN1 LOCK-SESSION
+
+# Session starts
+#?SESSION-X-1 START XDG_SEAT=seat0 XDG_VTNR=8 USER=no-password1
+#?XSERVER-1 ACCEPT-CONNECT
+#?SESSION-X-1 CONNECT-XSERVER
+
+# Switch to new session
+#?VT ACTIVATE VT=8
+
+# Switch back to original session
+#?*SWITCH-TO-USER USERNAME=have-password1
+#?RUNNER SWITCH-TO-USER USERNAME=have-password1
+
+# New X server starts
+#?XSERVER-2 START VT=9
+
+# Daemon connects when X server is ready
+#?*XSERVER-2 INDICATE-READY
+#?XSERVER-2 INDICATE-READY
+#?XSERVER-2 ACCEPT-CONNECT
+
+# Old session is locked
+#?LOGIN1 LOCK-SESSION
+
+# Greeter starts
+#?GREETER-X-2 START XDG_SEAT=seat0 XDG_VTNR=9
+#?XSERVER-2 ACCEPT-CONNECT
+#?GREETER-X-2 CONNECT-XSERVER
+#?GREETER-X-2 CONNECT-TO-DAEMON
+#?GREETER-X-2 CONNECTED-TO-DAEMON
+
+# Switch to greeter
+#?VT ACTIVATE VT=9
+
+# Requested user is automatically selected
+#?GREETER-X-2 SELECT-USER-HINT USERNAME=have-password1
+#?*GREETER-X-2 AUTHENTICATE USERNAME=have-password1
+#?GREETER-X-2 SHOW-PROMPT TEXT="Password:"
+
+# Login as existing user
+#?*GREETER-X-2 AUTHENTICATE USERNAME=have-password1
+#?GREETER-X-2 SHOW-PROMPT TEXT="Password:"
+#?*GREETER-X-2 RESPOND TEXT="password"
+#?GREETER-X-2 AUTHENTICATION-COMPLETE USERNAME=have-password1 AUTHENTICATED=TRUE
+#?*GREETER-X-2 START-SESSION
+
+# Session is unlocked
+#?LOGIN1 UNLOCK-SESSION
+
+# Switch to session
+#?VT ACTIVATE VT=7
+
+# Greeter and X server stop
+#?GREETER-X-2 TERMINATE SIGNAL=15
+#?XSERVER-2 TERMINATE SIGNAL=15
+
+# Cleanup
+#?*STOP-DAEMON
+#?SESSION-X-0 TERMINATE SIGNAL=15
+#?XSERVER-0 TERMINATE SIGNAL=15
+#?SESSION-X-1 TERMINATE SIGNAL=15
+#?XSERVER-1 TERMINATE SIGNAL=15
+#?RUNNER DAEMON-EXIT STATUS=0
--- /dev/null
+#!/bin/sh
+./src/dbus-env ./src/test-runner switch-to-user-switch-back test-gobject-greeter