gdm-03-sdtlogin.diff revision 20788
17797N/Acommit c7a1ad4850e394260cb61582aeefae8f95c3cae8
17595N/AAuthor: Halton Huo <halton.huo@sun.com>
17797N/ADate: Fri Nov 27 22:01:20 2009 +0800
17595N/A
17797N/A gdm-02-sdtlogin.diff
17595N/A
17089N/Adiff --git a/common/gdm-common.h b/common/gdm-common.h
17595N/Aindex 191bd70..634c091 100644
17089N/A--- a/common/gdm-common.h
17089N/A+++ b/common/gdm-common.h
20788N/A@@ -26,6 +26,11 @@
17089N/A
17089N/A #include "gdm-common-unknown-origin.h"
17089N/A
17089N/A+#ifdef __sun
17089N/A+#define GDM_DT_DIR "/var/dt"
17089N/A+#define GDM_SDTLOGIN_DIR "/var/dt/sdtlogin"
17089N/A+#endif
17089N/A+
20788N/A #define GDM_CUSTOM_SESSION "custom"
17089N/A
20788N/A G_BEGIN_DECLS
17089N/Adiff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
17797N/Aindex 757ef62..7012811 100644
17089N/A--- a/daemon/gdm-server.c
17089N/A+++ b/daemon/gdm-server.c
17797N/A@@ -646,6 +646,13 @@ gdm_server_spawn (GdmServer *server,
17797N/A count ++;
17797N/A }
17797N/A g_free (socket_file);
17797N/A+#if __sun
17797N/A+ /* Remove old communication pipe, if present */
17797N/A+ char *old_pipe;
17797N/A+ old_pipe = g_strdup_printf ("%s/%d", GDM_SDTLOGIN_DIR, display_num);
17797N/A+ g_unlink (old_pipe);
17797N/A+ g_free (old_pipe);
17089N/A+#endif
17089N/A }
17089N/A
17089N/A env = get_server_environment (server);
17089N/Adiff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
17595N/Aindex 2ab53a0..8970297 100644
17089N/A--- a/daemon/gdm-session-worker.c
17089N/A+++ b/daemon/gdm-session-worker.c
20788N/A@@ -32,6 +32,13 @@
20788N/A #include <grp.h>
20788N/A #include <pwd.h>
17089N/A
17089N/A+#if __sun
17089N/A+#include <sys/param.h>
17089N/A+#define GDM_PAM_QUAL
17089N/A+#else
17089N/A+#define GDM_PAM_QUAL const
17089N/A+#endif
17089N/A+
17089N/A #include <security/pam_appl.h>
17089N/A
17089N/A #include <glib.h>
20788N/A@@ -61,6 +68,7 @@
17089N/A #endif
17089N/A
17089N/A #include "gdm-session-settings.h"
17089N/A+#include "gdm-common.h"
17089N/A
17089N/A #define GDM_SESSION_WORKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SESSION_WORKER, GdmSessionWorkerPrivate))
17089N/A
20788N/A@@ -151,12 +159,115 @@ static void gdm_session_worker_final
17089N/A static void queue_state_change (GdmSessionWorker *worker);
17089N/A
17089N/A typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
17089N/A- const struct pam_message **,
17089N/A+ GDM_PAM_QUAL struct pam_message **,
17089N/A struct pam_response **,
17089N/A gpointer);
17089N/A
17089N/A G_DEFINE_TYPE (GdmSessionWorker, gdm_session_worker, G_TYPE_OBJECT)
17089N/A
17089N/A+#ifdef __sun
17089N/A+void
17089N/A+solaris_xserver_cred (char * username, struct passwd *passwd_entry, const char *x11_display_name)
17089N/A+{
17089N/A+ struct stat statbuf;
17089N/A+ struct group *gr;
17089N/A+ gid_t groups[NGROUPS_UMAX];
17089N/A+ char *home, *disp, *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN];
17089N/A+ int display_number = 0;
17089N/A+ int retval, fd, i, nb;
17089N/A+ int ngroups;
17089N/A+
17089N/A+ if (g_access (passwd_entry->pw_dir, F_OK) != 0) {
17089N/A+ g_debug ("solaris_xserver_cred: no HOME dir access\n");
17089N/A+ return;
17089N/A+ }
17089N/A+
17089N/A+ /*
17089N/A+ * Handshake with server. Make sure it created a pipe.
17089N/A+ * Open and write.
17089N/A+ */
17089N/A+ if ((tmp = strstr (x11_display_name, ":")) != NULL) {
17089N/A+ tmp++;
17089N/A+ display_number = g_ascii_strtod (tmp, &p);
17089N/A+
17089N/A+ if (errno != 0) {
17089N/A+ g_debug ("solaris_xserver_cred: problem getting display number\n");
17089N/A+ return;
17089N/A+ }
17089N/A+ }
17089N/A+
17089N/A+ sprintf (pipe, "%s/%d", GDM_SDTLOGIN_DIR, display_number);
17089N/A+
17089N/A+ if (g_stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) {
17089N/A+ if (! statbuf.st_mode & S_IFDIR) {
17089N/A+ g_debug ("solaris_xserver_cred: %s is not a directory\n",
17089N/A+ GDM_SDTLOGIN_DIR);
17089N/A+ return;
17089N/A+ }
17089N/A+ } else {
17089N/A+ g_debug ("solaris_xserver_cred: %s does not exist\n", GDM_SDTLOGIN_DIR);
17089N/A+ return;
17089N/A+ }
17089N/A+
17089N/A+ fd = open (pipe, O_RDWR);
17089N/A+ g_unlink (pipe);
17089N/A+
17089N/A+ if (fd < 0) {
17089N/A+ g_debug ("solaris_xserver_cred: could not open %s\n", pipe);
17089N/A+ return;
17089N/A+ }
17089N/A+ if (fstat (fd, &statbuf) == 0 ) {
17089N/A+ if ( ! statbuf.st_mode & S_IFIFO) {
17089N/A+ close (fd);
17089N/A+ g_debug ("solaris_xserver_cred: %s is not a pipe\n", pipe);
17089N/A+ return;
17089N/A+ }
17089N/A+ } else {
17089N/A+ close (fd);
17089N/A+ g_debug ("solaris_xserver_cred: %s does not exist\n", pipe);
17089N/A+ return;
17089N/A+ }
17089N/A+
17089N/A+ sprintf (info, "GID=\"%d\"; ", passwd_entry->pw_gid);
17089N/A+ nb = write (fd, info, strlen (info));
17089N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
17089N/A+
17089N/A+ if (initgroups (username, passwd_entry->pw_gid) == -1) {
17089N/A+ ngroups = 0;
17089N/A+ } else {
17089N/A+ ngroups = getgroups (NGROUPS_UMAX, groups);
17089N/A+ }
17089N/A+
17089N/A+ for (i=0; i < ngroups; i++) {
17089N/A+ sprintf (info, "G_LIST_ID=\"%u\" ", groups[i]);
17089N/A+ nb = write (fd, info, strlen (info));
17089N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
17089N/A+ }
17089N/A+
17089N/A+ if (ngroups > 0) {
17089N/A+ sprintf (info, ";");
17089N/A+ write (fd, info, strlen (info));
17089N/A+ }
17089N/A+
17089N/A+ sprintf (info, " HOME=\"%s\" ", passwd_entry->pw_dir);
17089N/A+ nb = write (fd, info, strlen (info));
17089N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
17089N/A+
17089N/A+ sprintf (info, " UID=\"%d\" EOF=\"\";", passwd_entry->pw_uid);
17089N/A+ nb = write (fd, info, strlen (info));
17089N/A+ g_debug ("solaris_xserver_cred: %s\n", info);
17089N/A+
17089N/A+ /*
17089N/A+ * Handshake with server. Make sure it read the pipe.
17089N/A+ *
17089N/A+ * Close file descriptor.
17089N/A+ */
17089N/A+ close (fd);
17089N/A+
17089N/A+ return;
17089N/A+}
17089N/A+#endif
17089N/A+
17089N/A GQuark
17089N/A gdm_session_worker_error_quark (void)
17089N/A {
18964N/A@@ -591,7 +702,11 @@ static gboolean
17089N/A gdm_session_worker_get_username (GdmSessionWorker *worker,
17089N/A char **username)
17089N/A {
17089N/A+#ifdef __sun
17089N/A+ gpointer item;
17089N/A+#else
17089N/A gconstpointer item;
17089N/A+#endif
17089N/A
17089N/A g_assert (worker->priv->pam_handle != NULL);
17089N/A
20788N/A@@ -870,7 +985,7 @@ gdm_session_worker_process_pam_message (
17089N/A
17089N/A static int
17089N/A gdm_session_worker_pam_new_messages_handler (int number_of_messages,
17089N/A- const struct pam_message **messages,
17089N/A+ GDM_PAM_QUAL struct pam_message **messages,
17089N/A struct pam_response **responses,
17089N/A GdmSessionWorker *worker)
17089N/A {
20788N/A@@ -1732,6 +1847,12 @@ gdm_session_worker_start_user_session (G
20788N/A g_debug ("GdmSessionWorker: opening user session with program '%s'",
20788N/A worker->priv->arguments[0]);
17089N/A
17089N/A+#ifdef __sun
17089N/A+ solaris_xserver_cred (worker->priv->username,
17089N/A+ passwd_entry,
17089N/A+ worker->priv->x11_display_name);
17089N/A+#endif
20788N/A+
20788N/A error_code = PAM_SUCCESS;
20788N/A
20788N/A session_pid = fork ();
17595N/Adiff --git a/daemon/main.c b/daemon/main.c
17595N/Aindex 8577ba7..0f2a007 100644
17089N/A--- a/daemon/main.c
17089N/A+++ b/daemon/main.c
17595N/A@@ -525,6 +525,21 @@ main (int argc,
17089N/A { NULL }
17089N/A };
17089N/A
17089N/A+#ifdef __sun
17089N/A+ {
17089N/A+ struct stat statbuf;
17089N/A+ int r;
17089N/A+
17089N/A+ r = stat (GDM_DT_DIR, &statbuf);
17089N/A+ if (r < 0) {
17089N/A+ g_mkdir (GDM_DT_DIR, 0755);
17089N/A+ }
17089N/A+
17089N/A+ g_remove (GDM_SDTLOGIN_DIR);
17089N/A+ g_mkdir (GDM_SDTLOGIN_DIR, 0700);
17089N/A+ }
17089N/A+#endif
17089N/A+
17089N/A bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
17089N/A textdomain (GETTEXT_PACKAGE);
17089N/A setlocale (LC_ALL, "");