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