7199N/AFrom 05391989747e3c6044329002f0786c37f34a2f6c Mon Sep 17 00:00:00 2001
7199N/AFrom: Alan Coopersmith <alan.coopersmith@oracle.com>
7199N/ADate: Tue, 29 Dec 2015 15:51:45 -0800
7199N/ASubject: [PATCH 07/19] solaris-notty
7199N/A
7199N/AWorkaround the Solaris PAM & auditing subsystems requirements that
7199N/Aevery session cannot be attributed to a single device file, as if
7199N/Awe all still logged in on serial terminals.
7199N/A
7199N/AOriginal date:2009-10-16 owner:yippi type:branding
7199N/A---
7199N/A daemon/gdm-manager.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
7199N/A daemon/gdm-server.c | 37 +++++++++++++++++++++++++++++++++----
7199N/A 2 files changed, 81 insertions(+), 4 deletions(-)
7199N/A
7199N/Adiff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c
7199N/Aindex 3d1d2eb..46c07ca 100644
7199N/A--- a/daemon/gdm-manager.c
7199N/A+++ b/daemon/gdm-manager.c
7199N/A@@ -29,6 +29,11 @@
7199N/A #include <sys/stat.h>
7199N/A #include <sys/types.h>
7199N/A
7199N/A+#ifdef __sun
7199N/A+#include <utime.h>
7199N/A+#include <sys/param.h>
7199N/A+#endif
7199N/A+
7199N/A #include <glib.h>
7199N/A #include <glib/gi18n.h>
7199N/A #include <glib/gstdio.h>
7199N/A@@ -2467,6 +2472,46 @@ clean_embryonic_user_session (GdmSession *session)
7199N/A g_object_unref (session);
7199N/A }
7199N/A
7199N/A+static void
7199N/A+create_device (const char *dev)
7199N/A+{
7199N/A+#ifdef __sun
7199N/A+ gchar buf[MAXPATHLEN + 1];
7199N/A+ struct stat st;
7199N/A+
7199N/A+ if (dev == NULL || dev[0] == '\0')
7199N/A+ return;
7199N/A+
7199N/A+ if (strcmp (dev, "/dev/dtlocal") != 0 &&
7199N/A+ strcmp (dev, "/dev/dtremote") != 0 )
7199N/A+ return;
7199N/A+
7199N/A+ memset (buf, 0, sizeof (gchar) * (MAXPATHLEN + 1));
7199N/A+
7199N/A+ if (stat (dev, &st) != 0) {
7199N/A+ g_debug ("Creating pseudo-device %s", dev);
7199N/A+ symlink ("/dev/null", dev);
7199N/A+ } else if (readlink (dev, buf, MAXPATHLEN) > 0) {
7199N/A+ if (strcmp (buf, "/dev/null") == 0) {
7199N/A+ /* Touch symlink */
7199N/A+ struct utimbuf timebuf;
7199N/A+
7199N/A+ timebuf.modtime = time ((time_t *) 0);
7199N/A+ timebuf.actime = timebuf.modtime;
7199N/A+
7199N/A+ if ((utime (dev, &timebuf)) != 0)
7199N/A+ g_debug ("Problem updating access time of pseudo-device %s", dev);
7199N/A+ else
7199N/A+ g_debug ("Touching pseudo-device %s", dev);
7199N/A+ } else {
7199N/A+ g_debug ("Device %s points to %s", dev, buf);
7199N/A+ }
7199N/A+ } else {
7199N/A+ g_debug ("Device %s is not a symlink", dev);
7199N/A+ }
7199N/A+#endif
7199N/A+}
7199N/A+
7199N/A static GdmSession *
7199N/A create_embryonic_user_session_for_display (GdmManager *manager,
7199N/A GdmDisplay *display,
7199N/A@@ -2490,6 +2535,9 @@ create_embryonic_user_session_for_display (GdmManager *manager,
7199N/A "seat-id", &display_seat_id,
7199N/A NULL);
7199N/A display_device = get_display_device (manager, display);
7199N/A+ if (!display_device && !display_is_local)
7199N/A+ display_device = g_strdup ("/dev/dtremote");
7199N/A+ create_device (display_device);
7199N/A
7199N/A session = gdm_session_new (GDM_SESSION_VERIFICATION_MODE_LOGIN,
7199N/A allowed_user,
7199N/Adiff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
7199N/Aindex 2cec263..77c18a8 100644
7199N/A--- a/daemon/gdm-server.c
7199N/A+++ b/daemon/gdm-server.c
7199N/A@@ -96,6 +96,7 @@ struct GdmServerPrivate
7199N/A guint child_watch_id;
7199N/A
7199N/A gboolean is_initial;
7199N/A+ gboolean is_local;
7199N/A };
7199N/A
7199N/A enum {
7199N/A@@ -146,15 +147,43 @@ _gdm_server_query_ck_for_display_device (GdmServer *server)
7199N/A NULL,
7199N/A &status,
7199N/A &error);
7199N/A+ g_free (command);
7199N/A+
7199N/A if (! res) {
7199N/A g_warning ("Could not run helper: %s", error->message);
7199N/A g_error_free (error);
7199N/A- } else {
7199N/A- out = g_strstrip (out);
7199N/A- g_debug ("GdmServer: Got tty: '%s'", out);
7199N/A+ g_free (out);
7199N/A+ return NULL;
7199N/A }
7199N/A
7199N/A- g_free (command);
7199N/A+ out = g_strstrip (out);
7199N/A+
7199N/A+ /* There are several scenarios that the device will be "?"
7199N/A+ * 1. Local sessions without VT support. If the display is ":0",
7199N/A+ * we set the device as "/dev/console" to gain device permissions.
7199N/A+ * This only happens on those systems do not has VT support such as
7199N/A+ * old Solaris. So far, Linux and OpenSolaris with VT support.
7199N/A+ * 2. XDMCP sessions, we set device as "/dev/dtremote"
7199N/A+ * 3. Local sessions like Sun Ray, Xvfb, Xvnc, we set device as
7199N/A+ * "/dev/dtlocal"
7199N/A+ */
7199N/A+ if (g_str_equal (out, "?")) {
7199N/A+ if (!server->priv->is_local) {
7199N/A+ /* This is for XDMCP sessions. */
7199N/A+ out = g_strdup ("/dev/dtremote");
7199N/A+ } else {
7199N/A+ if (g_str_equal (server->priv->display_name, ":0")) {
7199N/A+ /* This is for local session run on console. */
7199N/A+ out = g_strdup ("/dev/console");
7199N/A+ } else {
7199N/A+ /* This is for local sessions like
7199N/A+ * Sun Ray, Xvfb, Xvnc, etc. */
7199N/A+ out = g_strdup ("/dev/dtlocal");
7199N/A+ }
7199N/A+ }
7199N/A+ }
7199N/A+
7199N/A+ g_debug ("GdmServer: Got tty: '%s'", out);
7199N/A
7199N/A return out;
7199N/A }
7199N/A--
7199N/A2.7.4
7199N/A