--- lightdm-1.26.0/src/x-server.c 2018-02-07 00:31:03.000000000 +0000 +++ lightdm-1.26.0/src/x-server.c.new 2018-06-01 07:07:33.856561224 +0000 @@ -142,7 +142,11 @@ x_server_connect_session (DisplayServer g_autofree gchar *tty_text = NULL; g_autofree gchar *vt_text = NULL; +#ifdef __sun__ + tty_text = g_strdup_printf ("/dev/vt/%d", vt); +#else tty_text = g_strdup_printf ("/dev/tty%d", vt); +#endif session_set_tty (session, tty_text); vt_text = g_strdup_printf ("%d", vt); --- lightdm-1.19.3/src/session-child.c.~4~ 2016-08-09 20:12:33.810235770 +0300 +++ lightdm-1.19.3/src/session-child.c 2016-08-09 20:24:45.765910776 +0300 @@ -305,10 +305,50 @@ } if (xdisplay) { +#ifdef __sun__ + gchar *out; +#endif + #ifdef PAM_XDISPLAY pam_set_item (pam_handle, PAM_XDISPLAY, xdisplay); #endif + +#ifdef __sun__ + + /* We can't get real device name for X display on this stage. + * But we can use the following logic. + * 1. Local sessions without VT support. If the display is ":0", + * we can set device to tty if it starts with "/dev/vt/", otherwise we + * set the device as "/dev/console" to gain device permissions. + * The later 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 SunRay, Xvfb, Xvnc, we set device as + * "/dev/dtlocal" + */ + if (remote_host_name) { + /* This is for XDMCP sessions. */ + out = "/dev/dtremote"; + } else { + if (g_str_equal (xdisplay, ":0")) { + /* This is for local session run on console. */ + if (g_str_has_prefix(tty,"/dev/vt/")){ + out=tty; + } else { + out = "/dev/console"; + } + } else { + /* This is for local sessions like + * SunRay, Xvfb, Xvnc, etc. */ + out = "/dev/dtlocal"; + } + } + + g_printerr ("lightdm: Got tty: '%s'", out); + pam_set_item (pam_handle, PAM_TTY, out); +#else pam_set_item (pam_handle, PAM_TTY, xdisplay); +#endif }