7199N/AFrom f7978982d31f67867d8200f9f3102eb423312abc Mon Sep 17 00:00:00 2001
7199N/AFrom: Alan Coopersmith <alan.coopersmith@oracle.com>
7199N/ADate: Tue, 29 Dec 2015 12:50:16 -0800
7199N/ASubject: [PATCH 04/19] sdtlogin
7199N/AAdds SDTLOGIN interface, which drops the Xserver to user
7199N/Aperms rather than running as root, for added security on Solaris.
7199N/AOriginal date:2008-05-06 owner:yippi type:feature
7199N/AFor the original definition, see Sun ASARC case 1995/390.
7199N/A 4 files changed, 147 insertions(+)
7199N/Aindex 19dbbbb..6ac61c0 100644
7199N/A@@ -42,6 +42,11 @@ GQuark gdm_common_error_quark (void);
7199N/A typedef char * (*GdmExpandVarFunc) (const char *var,
7199N/A int gdm_wait_on_pid (int pid);
7199N/Aindex 08f2354..2cec263 100644
7199N/A@@ -742,6 +742,17 @@ gdm_server_spawn (GdmServer *server,
7199N/A+ /* Remove old communication pipe, if present */
7199N/A+ char *display_num = strchr(server->priv->display_name, ':');
7199N/A+ if (display_num != NULL && display_num[1] != '\0') {
7199N/A+ char *old_pipe = g_strdup_printf ("%s/%s", GDM_SDTLOGIN_DIR,
7199N/A+ VE_IGNORE_EINTR (g_remove (old_pipe));
7199N/A env = get_server_environment (server);
7199N/A freeme = g_strjoinv (" ", argv);
7199N/Aindex 291caad..93c9e82 100644
7199N/A@@ -2044,6 +2045,115 @@ out:
7199N/A+solaris_xserver_cred (const char *username, struct passwd *passwd_entry,
7199N/A+ const char *x11_display_name)
7199N/A+ gid_t groups[NGROUPS_UMAX];
7199N/A+ char *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN];
7199N/A+ if (g_access (passwd_entry->pw_dir, F_OK) != 0) {
7199N/A+ g_debug ("solaris_xserver_cred: no HOME dir access\n");
7199N/A+ * Handshake with server. Make sure it created a pipe.
7199N/A+ if ((tmp = strstr (x11_display_name, ":")) != NULL) {
7199N/A+ display_number = g_ascii_strtod (tmp, &p);
7199N/A+ g_debug ("solaris_xserver_cred: problem getting display number\n");
7199N/A+ if (g_stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) {
7199N/A+ g_debug ("solaris_xserver_cred: %s is not a directory\n",
7199N/A+ g_debug ("solaris_xserver_cred: %s does not exist\n", GDM_SDTLOGIN_DIR);
7199N/A+ snprintf (pipe, sizeof(pipe), "%s/%d", GDM_SDTLOGIN_DIR, display_number);
7199N/A+ g_debug ("solaris_xserver_cred: could not open %s\n", pipe);
7199N/A+ if (fstat (fd, &statbuf) == 0 ) {
7199N/A+ g_debug ("solaris_xserver_cred: %s is not a pipe\n", pipe);
7199N/A+ g_debug ("solaris_xserver_cred: %s does not exist\n", pipe);
7199N/A+ g_debug ("solaris_xserver_cred: could not fdopen %s\n", pipe);
7199N/A+ snprintf (info, sizeof(info), "GID=\"%d\"; ", passwd_entry->pw_gid);
7199N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
7199N/A+ if (initgroups (username, passwd_entry->pw_gid) == -1) {
7199N/A+ ngroups = getgroups (NGROUPS_UMAX, groups);
7199N/A+ for (i=0; i < ngroups; i++) {
7199N/A+ snprintf (info, sizeof(info), "G_LIST_ID=\"%u\" ", groups[i]);
7199N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
7199N/A+ snprintf (info, sizeof(info), " HOME=\"%s\" ", passwd_entry->pw_dir);
7199N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
7199N/A+ snprintf (info, sizeof(info), " UID=\"%d\" EOF=\"\";", passwd_entry->pw_uid);
7199N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
7199N/A+ * Handshake with server. Make sure it read the pipe.
7199N/A gdm_session_worker_start_session (GdmSessionWorker *worker,
7199N/A@@ -2061,6 +2171,12 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
7199N/A worker->priv->arguments[0]);
7199N/A+ solaris_xserver_cred (worker->priv->username,
7199N/A+ worker->priv->x11_display_name);
7199N/Aindex ca2dda3..50f6e94 100644
7199N/A@@ -324,6 +324,21 @@ main (int argc,
7199N/A+ r = stat (GDM_DT_DIR, &statbuf);
7199N/A+ g_mkdir (GDM_DT_DIR, 0755);
7199N/A+ g_remove (GDM_SDTLOGIN_DIR);
7199N/A+ g_mkdir (GDM_SDTLOGIN_DIR, 0700);
7199N/A bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
7199N/A textdomain (GETTEXT_PACKAGE);