diff options
Diffstat (limited to 'x11/gdm/files/patch-daemon_gdm-session-worker.c')
-rw-r--r-- | x11/gdm/files/patch-daemon_gdm-session-worker.c | 296 |
1 files changed, 98 insertions, 198 deletions
diff --git a/x11/gdm/files/patch-daemon_gdm-session-worker.c b/x11/gdm/files/patch-daemon_gdm-session-worker.c index 121ca11a0232..a05cb45b5d4c 100644 --- a/x11/gdm/files/patch-daemon_gdm-session-worker.c +++ b/x11/gdm/files/patch-daemon_gdm-session-worker.c @@ -1,31 +1,5 @@ -$OpenBSD: patch-daemon_gdm-session-worker_c,v 1.15 2017/03/12 12:58:03 nigel Exp $ - -REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit) -From 1ac67f522f5690c27023d98096ca817f12f7eb88 Mon Sep 17 00:00:00 2001 -From: Ray Strode <rstrode@redhat.com> -Date: Fri, 12 Jun 2015 13:28:01 -0400 -Subject: drop consolekit support - -REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit) -From 9be58c9ec9a3a411492a5182ac4b0d51fdc3a323 Mon Sep 17 00:00:00 2001 -From: Ray Strode <rstrode@redhat.com> -Date: Fri, 12 Jun 2015 13:48:52 -0400 -Subject: require logind support - -REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit) -From a9cacb929470eb82582396984c61d5b611bfeb1a Mon Sep 17 00:00:00 2001 -From: Ray Strode <rstrode@redhat.com> -Date: Fri, 12 Jun 2015 14:33:40 -0400 -Subject: session: drop session-type property - -REVERT - OpenBSD does not have a systemd implementation (we need ConsoleKit) -From 6942fb9b16bab7173bbd295fb19a9770289dbe0e Mon Sep 17 00:00:00 2001 -From: Tim Lunn <tim@feathertop.org> -Date: Mon, 11 Apr 2016 23:18:10 +1000 -Subject: gdm-session: set PAM_TTY when initialising pam - ---- daemon/gdm-session-worker.c.orig 2017-10-31 18:16:51.000000000 +0100 -+++ daemon/gdm-session-worker.c 2018-01-17 17:38:41.826277000 +0100 +--- daemon/gdm-session-worker.c.orig 2022-01-12 14:15:56 UTC ++++ daemon/gdm-session-worker.c @@ -28,9 +28,11 @@ #include <string.h> #include <sys/types.h> @@ -48,7 +22,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam #ifdef ENABLE_SYSTEMD_JOURNAL #include <systemd/sd-journal.h> -@@ -93,7 +97,7 @@ +@@ -94,7 +98,7 @@ #endif #ifndef GDM_SESSION_DEFAULT_PATH @@ -57,7 +31,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam #endif #ifndef GDM_SESSION_ROOT_UID -@@ -136,6 +140,10 @@ struct GdmSessionWorkerPrivate +@@ -126,6 +130,10 @@ struct GdmSessionWorkerPrivate int exit_code; @@ -68,17 +42,34 @@ Subject: gdm-session: set PAM_TTY when initialising pam pam_handle_t *pam_handle; GPid child_pid; -@@ -150,6 +158,7 @@ struct GdmSessionWorkerPrivate +@@ -140,6 +148,11 @@ struct GdmSessionWorkerPrivate char *hostname; char *username; char *log_file; ++#ifdef WITH_CONSOLE_KIT + char *session_type; ++ char *session_class; ++ char *session_service; ++#endif char *session_id; uid_t uid; gid_t gid; -@@ -223,6 +232,204 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker, - G_IMPLEMENT_INTERFACE (GDM_DBUS_TYPE_WORKER, - worker_interface_init)) +@@ -207,6 +220,12 @@ typedef int (* GdmSessionWorkerPamNewMessagesFunc) (in + struct pam_response **, + gpointer); + ++#ifdef WITH_CONSOLE_KIT ++static char * ++gdm_session_worker_get_environment_variable (GdmSessionWorker *worker, ++ const char *key); ++#endif ++ + G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker, + gdm_session_worker, + GDM_DBUS_TYPE_WORKER_SKELETON, +@@ -214,6 +233,211 @@ G_DEFINE_TYPE_WITH_CODE (GdmSessionWorker, + worker_interface_init) + G_ADD_PRIVATE (GdmSessionWorker)) +#ifdef WITH_CONSOLE_KIT +static gboolean @@ -94,7 +85,6 @@ Subject: gdm-session: set PAM_TTY when initialising pam + const char *display_name; + const char *display_device; + const char *display_hostname; -+ const char *session_type; + gint32 uid; + + g_assert (worker->priv->session_cookie == NULL); @@ -115,12 +105,6 @@ Subject: gdm-session: set PAM_TTY when initialising pam + display_device = ""; + } + -+ if (worker->priv->session_type != NULL) { -+ session_type = worker->priv->session_type; -+ } else { -+ session_type = ""; -+ } -+ + g_assert (worker->priv->username != NULL); + + gdm_get_pwent_for_name (worker->priv->username, &pwent); @@ -147,15 +131,29 @@ Subject: gdm-session: set PAM_TTY when initialising pam + g_variant_builder_add_parsed (&builder, "('x11-display', <%s>)", display_name); + g_variant_builder_add_parsed (&builder, "('remote-host-name', <%s>)", display_hostname); + g_variant_builder_add_parsed (&builder, "('is-local', <%b>)", worker->priv->display_is_local); -+ g_variant_builder_add_parsed (&builder, "('session-type', <%s>)", session_type); ++ ++ worker->priv->session_type = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_TYPE"); ++ if (worker->priv->session_type != NULL) { ++ g_variant_builder_add_parsed (&builder, "('session-type', <%s>)", worker->priv->session_type); ++ } ++ ++ worker->priv->session_class = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_CLASS"); ++ if (worker->priv->session_class != NULL) { ++ g_variant_builder_add_parsed (&builder, "('session-class', <%s>)", worker->priv->session_class); ++ } ++ ++ worker->priv->session_service = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_SERVICE"); ++ if (worker->priv->session_service != NULL) { ++ g_variant_builder_add_parsed (&builder, "('session-service', <%s>)", worker->priv->session_service); ++ } + + parameters = g_variant_builder_end (&builder); + in_args = g_variant_new_tuple (¶meters, 1); + + reply = g_dbus_connection_call_sync (system_bus, -+ "org.freedesktop.ConsoleKit", -+ "/org/freedesktop/ConsoleKit/Manager", -+ "org.freedesktop.ConsoleKit.Manager", ++ CK_NAME, ++ CK_MANAGER_PATH, ++ CK_MANAGER_INTERFACE, + "OpenSessionWithParameters", + in_args, + G_VARIANT_TYPE ("(s)"), @@ -202,9 +200,9 @@ Subject: gdm-session: set PAM_TTY when initialising pam + } + + reply = g_dbus_connection_call_sync (system_bus, -+ "org.freedesktop.ConsoleKit", -+ "/org/freedesktop/ConsoleKit/Manager", -+ "org.freedesktop.ConsoleKit.Manager", ++ CK_NAME, ++ CK_MANAGER_PATH, ++ CK_MANAGER_INTERFACE, + "CloseSession", + g_variant_new ("(s)", worker->priv->session_cookie), + G_VARIANT_TYPE ("(b)"), @@ -252,9 +250,9 @@ Subject: gdm-session: set PAM_TTY when initialising pam + } + + reply = g_dbus_connection_call_sync (system_bus, -+ "org.freedesktop.ConsoleKit", -+ "/org/freedesktop/ConsoleKit/Manager", -+ "org.freedesktop.ConsoleKit.Manager", ++ CK_NAME, ++ CK_MANAGER_PATH, ++ CK_MANAGER_INTERFACE, + "GetSessionForCookie", + g_variant_new ("(s)", worker->priv->session_cookie), + G_VARIANT_TYPE ("(o)"), @@ -281,7 +279,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam /* adapted from glib script_execute */ static void script_execute (const gchar *file, -@@ -674,7 +881,9 @@ gdm_session_worker_process_pam_message (GdmSessionWork +@@ -670,7 +894,9 @@ gdm_session_worker_process_pam_message (GdmSessionWork char *user_answer; gboolean res; char *utf8_msg; @@ -291,7 +289,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam if (response != NULL) { *response = NULL; -@@ -878,6 +1087,7 @@ gdm_session_worker_stop_auditor (GdmSessionWorker *wor +@@ -914,6 +1140,7 @@ gdm_session_worker_stop_auditor (GdmSessionWorker *wor worker->priv->auditor = NULL; } @@ -299,84 +297,43 @@ Subject: gdm-session: set PAM_TTY when initialising pam static void on_release_display (int signal) { -@@ -1003,6 +1213,7 @@ jump_to_vt (GdmSessionWorker *worker, +@@ -1056,6 +1283,7 @@ jump_to_vt (GdmSessionWorker *worker, close (active_vt_tty_fd); } +#endif static void - gdm_session_worker_uninitialize_pam (GdmSessionWorker *worker, -@@ -1033,11 +1244,13 @@ gdm_session_worker_uninitialize_pam (GdmSessionWorker - - gdm_session_worker_stop_auditor (worker); - -+#ifdef WITH_SYSTEMD - if (g_strcmp0 (worker->priv->display_seat_id, "seat0") == 0) { - if (worker->priv->login_vt != worker->priv->session_vt) { - jump_to_vt (worker, worker->priv->login_vt); - } - } -+#endif - - worker->priv->login_vt = 0; - worker->priv->session_vt = 0; -@@ -1088,6 +1301,7 @@ _get_xauth_for_pam (const char *x11_authority_file) - } - #endif - -+#ifdef WITH_SYSTEMD - static gboolean - ensure_login_vt (GdmSessionWorker *worker) - { -@@ -1099,7 +1313,7 @@ ensure_login_vt (GdmSessionWorker *worker) - - if (fd < 0) { - g_debug ("GdmSessionWorker: couldn't open VT master: %m"); -- return FALSE; -+ return FALSE; - } - - if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) { -@@ -1113,6 +1327,7 @@ out: - close (fd); - return got_login_vt; - } -+#endif - - static gboolean - gdm_session_worker_initialize_pam (GdmSessionWorker *worker, -@@ -1129,7 +1344,6 @@ gdm_session_worker_initialize_pam (GdmSessionWorker + gdm_session_worker_set_state (GdmSessionWorker *worker, +@@ -1158,7 +1386,9 @@ gdm_session_worker_initialize_pam (GdmSessionWorker { struct pam_conv pam_conversation; int error_code; -- char tty_string[256]; ++#ifdef WITH_SYSTEMD + char tty_string[256]; ++#endif g_assert (worker->priv->pam_handle == NULL); -@@ -1196,10 +1410,12 @@ gdm_session_worker_initialize_pam (GdmSessionWorker - } - } - -+#ifdef WITH_SYSTEMD - /* set seat ID */ -- if (seat_id != NULL && seat_id[0] != '\0') { -+ if (seat_id != NULL && seat_id[0] != '\0' && LOGIND_RUNNING()) { +@@ -1230,6 +1460,10 @@ gdm_session_worker_initialize_pam (GdmSessionWorker gdm_session_worker_set_environment_variable (worker, "XDG_SEAT", seat_id); } -+#endif ++#ifdef WITH_CONSOLE_KIT ++ gdm_session_worker_set_environment_variable (worker, "XDG_SESSION_SERVICE", service); ++#endif ++ if (strcmp (service, "gdm-launch-environment") == 0) { gdm_session_worker_set_environment_variable (worker, "XDG_SESSION_CLASS", "greeter"); -@@ -1208,6 +1424,7 @@ gdm_session_worker_initialize_pam (GdmSessionWorker + } +@@ -1237,12 +1471,14 @@ gdm_session_worker_initialize_pam (GdmSessionWorker g_debug ("GdmSessionWorker: state SETUP_COMPLETE"); - worker->priv->state = GDM_SESSION_WORKER_STATE_SETUP_COMPLETE; + gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SETUP_COMPLETE); +#ifdef WITH_SYSTEMD - /* Temporarily set PAM_TTY with the currently active VT (login screen) + /* Temporarily set PAM_TTY with the login VT, PAM_TTY will be reset with the users VT right before the user session is opened */ - ensure_login_vt (worker); -@@ -1215,6 +1432,7 @@ gdm_session_worker_initialize_pam (GdmSessionWorker + g_snprintf (tty_string, 256, "/dev/tty%d", GDM_INITIAL_VT); pam_set_item (worker->priv->pam_handle, PAM_TTY, tty_string); if (!display_is_local) worker->priv->password_is_required = TRUE; @@ -384,16 +341,20 @@ Subject: gdm-session: set PAM_TTY when initialising pam out: if (error_code != PAM_SUCCESS) { -@@ -1509,7 +1727,7 @@ _lookup_passwd_info (const char *username, +@@ -1545,7 +1781,11 @@ _lookup_passwd_info (const char *username, if (passwd_entry->pw_shell != NULL && passwd_entry->pw_shell[0] != '\0') { *shellp = g_strdup (passwd_entry->pw_shell); } else { - *shellp = g_strdup ("/bin/bash"); ++#if defined(__OpenBSD__) ++ *shellp = g_strdup ("/bin/ksh"); ++#else + *shellp = g_strdup ("/bin/sh"); ++#endif } } ret = TRUE; -@@ -1762,6 +1980,26 @@ gdm_session_worker_get_environment (GdmSessionWorker * +@@ -1689,6 +1929,20 @@ gdm_session_worker_get_environment (GdmSessionWorker * return (const char * const *) pam_getenvlist (worker->priv->pam_handle); } @@ -401,12 +362,6 @@ Subject: gdm-session: set PAM_TTY when initialising pam +static void +register_ck_session (GdmSessionWorker *worker) +{ -+#ifdef WITH_SYSTEMD -+ if (LOGIND_RUNNING()) { -+ return; -+ } -+#endif -+ + open_ck_session (worker); + + if (worker->priv->session_cookie != NULL) { @@ -420,17 +375,18 @@ Subject: gdm-session: set PAM_TTY when initialising pam static gboolean run_script (GdmSessionWorker *worker, const char *dir) -@@ -1792,6 +2030,9 @@ session_worker_child_watch (GPid pid, +@@ -1766,6 +2020,10 @@ session_worker_child_watch (GPid pid, : WIFSIGNALED (status) ? WTERMSIG (status) : -1); +#ifdef WITH_CONSOLE_KIT + close_ck_session (worker); +#endif - ++ gdm_session_worker_uninitialize_pam (worker, PAM_SUCCESS); -@@ -1982,6 +2223,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w + worker->priv->child_pid = -1; +@@ -1978,6 +2236,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w error_code = PAM_SUCCESS; @@ -438,7 +394,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam /* If we're in new vt mode, jump to the new vt now. There's no need to jump for * the other two modes: in the logind case, the session will activate itself when * ready, and in the reuse server case, we're already on the correct VT. */ -@@ -1990,6 +2232,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w +@@ -1986,6 +2245,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w jump_to_vt (worker, worker->priv->session_vt); } } @@ -446,7 +402,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam if (!worker->priv->is_program_session && !run_script (worker, GDMCONFDIR "/PostLogin")) { g_set_error (error, -@@ -2054,6 +2297,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w +@@ -2048,6 +2308,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w _exit (EXIT_FAILURE); } @@ -454,7 +410,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam /* Take control of the tty */ if (needs_controlling_terminal) { -@@ -2061,6 +2305,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w +@@ -2055,6 +2316,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w g_debug ("GdmSessionWorker: could not take control of tty: %m"); } } @@ -462,7 +418,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam #ifdef HAVE_LOGINCAP if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) { -@@ -2205,11 +2450,13 @@ gdm_session_worker_start_session (GdmSessionWorker *w +@@ -2186,6 +2448,7 @@ gdm_session_worker_start_session (GdmSessionWorker *w return TRUE; } @@ -470,33 +426,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam static gboolean set_up_for_new_vt (GdmSessionWorker *worker) { - int fd; - char vt_string[256], tty_string[256]; -+ struct vt_stat vt_state = { 0 }; - int session_vt = 0; - - fd = open ("/dev/tty0", O_RDWR | O_NOCTTY); -@@ -2219,6 +2466,11 @@ set_up_for_new_vt (GdmSessionWorker *worker) - return FALSE; - } - -+ if (ioctl (fd, VT_GETSTATE, &vt_state) < 0) { -+ g_debug ("GdmSessionWorker: couldn't get current VT: %m"); -+ goto fail; -+ } -+ - if (worker->priv->display_is_initial) { - session_vt = atoi (GDM_INITIAL_VT); - } else { -@@ -2228,6 +2480,7 @@ set_up_for_new_vt (GdmSessionWorker *worker) - } - } - -+ worker->priv->login_vt = vt_state.v_active; - worker->priv->session_vt = session_vt; - - close (fd); -@@ -2290,6 +2543,7 @@ fail: +@@ -2286,6 +2549,7 @@ fail: close (fd); return FALSE; } @@ -504,7 +434,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam static gboolean set_up_for_current_vt (GdmSessionWorker *worker, -@@ -2357,12 +2611,14 @@ set_up_for_current_vt (GdmSessionWorker *worker, +@@ -2353,12 +2617,14 @@ set_up_for_current_vt (GdmSessionWorker *worker, } #endif @@ -519,33 +449,31 @@ Subject: gdm-session: set PAM_TTY when initialising pam return TRUE; out: -@@ -2386,6 +2642,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo - return FALSE; - } +@@ -2384,6 +2650,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo break; -+#ifdef WITH_SYSTEMD case GDM_SESSION_DISPLAY_MODE_NEW_VT: case GDM_SESSION_DISPLAY_MODE_LOGIND_MANAGED: ++#ifdef WITH_SYSTEMD if (!set_up_for_new_vt (worker)) { -@@ -2396,6 +2653,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo + g_set_error (error, + GDM_SESSION_WORKER_ERROR, +@@ -2391,6 +2658,7 @@ gdm_session_worker_open_session (GdmSessionWorker *wo + "Unable to open VT"); return FALSE; } - break; +#endif + break; } - flags = 0; -@@ -2417,8 +2675,18 @@ gdm_session_worker_open_session (GdmSessionWorker *wo +@@ -2413,8 +2681,16 @@ gdm_session_worker_open_session (GdmSessionWorker *wo g_debug ("GdmSessionWorker: state SESSION_OPENED"); - worker->priv->state = GDM_SESSION_WORKER_STATE_SESSION_OPENED; + gdm_session_worker_set_state (worker, GDM_SESSION_WORKER_STATE_SESSION_OPENED); -+#ifdef WITH_SYSTEMD ++#if defined(WITH_SYSTEMD) session_id = gdm_session_worker_get_environment_variable (worker, "XDG_SESSION_ID"); -+#endif - -+#ifdef WITH_CONSOLE_KIT ++#elif defined(WITH_CONSOLE_KIT) + register_ck_session (worker); -+ + + if (session_id == NULL) { + session_id = get_ck_session_id (worker); + } @@ -554,27 +482,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam if (session_id != NULL) { g_free (worker->priv->session_id); worker->priv->session_id = session_id; -@@ -2523,6 +2791,19 @@ gdm_session_worker_handle_set_session_name (GdmDBusWor - } - - static gboolean -+gdm_session_worker_handle_set_session_type (GdmDBusWorker *object, -+ GDBusMethodInvocation *invocation, -+ const char *session_type) -+{ -+ GdmSessionWorker *worker = GDM_SESSION_WORKER (object); -+ g_debug ("GdmSessionWorker: session type set to %s", session_type); -+ g_free (worker->priv->session_type); -+ worker->priv->session_type = g_strdup (session_type); -+ gdm_dbus_worker_complete_set_session_type (object, invocation); -+ return TRUE; -+} -+ -+static gboolean - gdm_session_worker_handle_set_session_display_mode (GdmDBusWorker *object, - GDBusMethodInvocation *invocation, - const char *str) -@@ -2949,6 +3230,7 @@ gdm_session_worker_handle_open (GdmDBusWorker +@@ -2968,6 +3244,7 @@ gdm_session_worker_handle_open (GdmDBusWorker return TRUE; } @@ -582,7 +490,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam static char ** filter_extensions (const char * const *extensions) { -@@ -2974,6 +3256,7 @@ filter_extensions (const char * const *extensions) +@@ -2993,6 +3270,7 @@ filter_extensions (const char * const *extensions) return filtered_extensions; } @@ -590,7 +498,7 @@ Subject: gdm-session: set PAM_TTY when initialising pam static gboolean gdm_session_worker_handle_initialize (GdmDBusWorker *object, -@@ -2993,8 +3276,10 @@ gdm_session_worker_handle_initialize (GdmDBusWorker +@@ -3012,8 +3290,10 @@ gdm_session_worker_handle_initialize (GdmDBusWorker while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) { if (g_strcmp0 (key, "service") == 0) { worker->priv->service = g_variant_dup_string (value, NULL); @@ -601,11 +509,3 @@ Subject: gdm-session: set PAM_TTY when initialising pam } else if (g_strcmp0 (key, "username") == 0) { worker->priv->username = g_variant_dup_string (value, NULL); } else if (g_strcmp0 (key, "is-program-session") == 0) { -@@ -3434,6 +3719,7 @@ worker_interface_init (GdmDBusWorkerIface *interface) - interface->handle_open = gdm_session_worker_handle_open; - interface->handle_set_language_name = gdm_session_worker_handle_set_language_name; - interface->handle_set_session_name = gdm_session_worker_handle_set_session_name; -+ interface->handle_set_session_type = gdm_session_worker_handle_set_session_type; - interface->handle_set_session_display_mode = gdm_session_worker_handle_set_session_display_mode; - interface->handle_set_environment_variable = gdm_session_worker_handle_set_environment_variable; - interface->handle_start_program = gdm_session_worker_handle_start_program; |