patches/gdm-02-sdtlogin.diff
author halton
Fri, 23 Oct 2009 09:01:51 +0000
changeset 16844 5a55ad37c87d
parent 16436 ecf5fc7080eb
permissions -rw-r--r--
2009-10-23 Halton Huo <[email protected]> Updated to fix d.o.o #11313 and #12070. * patches/ConsoleKit-01-ck-dynamic.diff: * patches/gdm-02-sdtlogin.diff:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     1
commit fab96d9b841eb1a7ff742a41483b021fb0589a96
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     2
Author: Halton Huo <[email protected]>
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     3
Date:   Fri Oct 23 16:22:16 2009 +0800
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     4
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     5
    Adds SDTLOGIN interface, which drops the Xserver to user
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     6
    perms rather than running as root, for added security on Solaris.
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     7
    
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     8
    At the same time, This patch allows slave process wait the X lock file is released.
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
     9
    When user logout, console-kit-daemon will start a new session on same display.
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    10
    On Solaris, Xorg seems to stop slower which cause the new session starting
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    11
    failure. This patch is let slave process wait the X lock file is released.
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    12
    Linux does not have this problem, it is solaris only.
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    13
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    14
diff --git a/common/gdm-common.h b/common/gdm-common.h
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    15
index 191bd70..634c091 100644
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    16
--- a/common/gdm-common.h
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    17
+++ b/common/gdm-common.h
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    18
@@ -25,6 +25,11 @@
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    19
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    20
 #include "gdm-common-unknown-origin.h"
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    21
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    22
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    23
+#define GDM_DT_DIR "/var/dt"
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    24
+#define GDM_SDTLOGIN_DIR "/var/dt/sdtlogin"
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    25
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    26
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    27
 G_BEGIN_DECLS
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    28
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    29
 gboolean       gdm_is_version_unstable            (void);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    30
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    31
index 8289a8e..4ea07de 100644
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    32
--- a/daemon/gdm-server.c
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    33
+++ b/daemon/gdm-server.c
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    34
@@ -33,6 +33,9 @@
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    35
 #include <grp.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    36
 #include <signal.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    37
 #include <sys/resource.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    38
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    39
+#include <sys/param.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    40
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    41
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    42
 #include <glib.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    43
 #include <glib/gi18n.h>
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    44
@@ -626,6 +629,37 @@ gdm_server_spawn (GdmServer  *server,
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    45
                 _exit (SERVER_ABORT);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    46
         }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    47
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    48
+#if __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    49
+        {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    50
+                /* Remove old communication pipe, if present */
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    51
+                char old_pipe[MAXPATHLEN];
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    52
+                char *p, *tmp;
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    53
+                char *lock_file;
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    54
+                int display_num;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    55
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    56
+                if ((tmp = strstr (server->priv->display_name, ":")) != NULL) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    57
+                        tmp++;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    58
+                        display_num = g_ascii_strtod (tmp, &p);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    59
+
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    60
+                        lock_file = g_strdup_printf ("/tmp/.X%d-lock", display_num);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    61
+
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    62
+                        /* Solaris needs quit X slowly, adding this hacking
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    63
+                           to avoid restart session failure */
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    64
+                        while (1) {
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    65
+                                if (!g_file_test (lock_file, G_FILE_TEST_EXISTS))
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    66
+                                        break;
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    67
+                                sleep (1);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    68
+                        }
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    69
+                        g_free (lock_file);
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    70
+
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    71
+                        if (errno == 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    72
+                                sprintf (old_pipe, "%s/%d", GDM_SDTLOGIN_DIR, display_num);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    73
+                                g_unlink (old_pipe);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    74
+                        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    75
+                }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    76
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    77
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    78
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    79
         env = get_server_environment (server);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    80
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    81
         freeme = g_strjoinv (" ", argv);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    82
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
    83
index 2ab53a0..8970297 100644
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    84
--- a/daemon/gdm-session-worker.c
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    85
+++ b/daemon/gdm-session-worker.c
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    86
@@ -36,6 +36,13 @@
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    87
 #include <libdevinfo.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    88
 #endif  /* HAVE_LOGINDEVPERM */
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    89
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    90
+#if __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    91
+#include <sys/param.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    92
+#define GDM_PAM_QUAL
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    93
+#else
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    94
+#define GDM_PAM_QUAL const
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    95
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    96
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    97
 #include <security/pam_appl.h>
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    98
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
    99
 #include <glib.h>
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   100
@@ -64,6 +71,7 @@
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   101
 #endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   102
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   103
 #include "gdm-session-settings.h"
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   104
+#include "gdm-common.h"
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   105
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   106
 #define GDM_SESSION_WORKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SESSION_WORKER, GdmSessionWorkerPrivate))
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   107
 
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   108
@@ -156,12 +164,115 @@ static void     gdm_session_worker_finalize     (GObject               *object);
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   109
 static void     queue_state_change              (GdmSessionWorker      *worker);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   110
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   111
 typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   112
-                                                    const struct pam_message **,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   113
+                                                    GDM_PAM_QUAL struct pam_message **,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   114
                                                     struct pam_response **,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   115
                                                     gpointer);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   116
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   117
 G_DEFINE_TYPE (GdmSessionWorker, gdm_session_worker, G_TYPE_OBJECT)
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   118
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   119
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   120
+void
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   121
+solaris_xserver_cred (char * username, struct passwd *passwd_entry, const char *x11_display_name)
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   122
+{
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   123
+        struct stat statbuf;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   124
+        struct group *gr;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   125
+        gid_t  groups[NGROUPS_UMAX];
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   126
+        char *home, *disp, *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN];
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   127
+        int display_number = 0;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   128
+        int retval, fd, i, nb;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   129
+        int ngroups;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   130
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   131
+        if (g_access (passwd_entry->pw_dir, F_OK) != 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   132
+                g_debug ("solaris_xserver_cred: no HOME dir access\n");
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   133
+                return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   134
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   135
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   136
+        /*
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   137
+         * Handshake with server. Make sure it created a pipe.
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   138
+         * Open and write.
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   139
+         */
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   140
+        if ((tmp = strstr (x11_display_name, ":")) != NULL) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   141
+                tmp++;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   142
+                display_number = g_ascii_strtod (tmp, &p);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   143
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   144
+                if (errno != 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   145
+                        g_debug ("solaris_xserver_cred: problem getting display number\n");
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   146
+                        return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   147
+                }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   148
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   149
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   150
+        sprintf (pipe, "%s/%d", GDM_SDTLOGIN_DIR, display_number);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   151
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   152
+        if (g_stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   153
+                if (! statbuf.st_mode & S_IFDIR) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   154
+                        g_debug ("solaris_xserver_cred: %s is not a directory\n",
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   155
+                                 GDM_SDTLOGIN_DIR);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   156
+                        return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   157
+                }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   158
+        } else {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   159
+                g_debug ("solaris_xserver_cred: %s does not exist\n", GDM_SDTLOGIN_DIR);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   160
+                return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   161
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   162
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   163
+        fd = open (pipe, O_RDWR);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   164
+        g_unlink (pipe);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   165
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   166
+        if (fd < 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   167
+                g_debug ("solaris_xserver_cred: could not open %s\n", pipe);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   168
+                return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   169
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   170
+        if (fstat (fd, &statbuf) == 0 ) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   171
+                if ( ! statbuf.st_mode & S_IFIFO) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   172
+                        close (fd);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   173
+                        g_debug ("solaris_xserver_cred: %s is not a pipe\n", pipe);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   174
+                        return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   175
+                }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   176
+        } else {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   177
+                close (fd);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   178
+                g_debug ("solaris_xserver_cred: %s does not exist\n", pipe);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   179
+                return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   180
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   181
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   182
+        sprintf (info, "GID=\"%d\"; ", passwd_entry->pw_gid);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   183
+        nb = write (fd, info, strlen (info));
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   184
+        g_debug ("solaris_xserver_cred: %s\n", info);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   185
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   186
+        if (initgroups (username, passwd_entry->pw_gid) == -1) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   187
+                ngroups = 0;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   188
+        } else {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   189
+                ngroups = getgroups (NGROUPS_UMAX, groups);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   190
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   191
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   192
+        for (i=0; i < ngroups; i++) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   193
+                sprintf (info, "G_LIST_ID=\"%u\" ", groups[i]);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   194
+                nb = write (fd, info, strlen (info));
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   195
+                g_debug ("solaris_xserver_cred: %s\n", info);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   196
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   197
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   198
+        if (ngroups > 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   199
+                sprintf (info, ";");
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   200
+                write (fd, info, strlen (info));
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   201
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   202
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   203
+        sprintf (info, " HOME=\"%s\" ", passwd_entry->pw_dir);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   204
+        nb = write (fd, info, strlen (info));
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   205
+        g_debug ("solaris_xserver_cred: %s\n", info);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   206
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   207
+        sprintf (info, " UID=\"%d\" EOF=\"\";", passwd_entry->pw_uid);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   208
+        nb = write (fd, info, strlen (info));
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   209
+        g_debug ("solaris_xserver_cred: %s\n", info);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   210
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   211
+        /*
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   212
+         * Handshake with server. Make sure it read the pipe.
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   213
+         *
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   214
+         * Close file descriptor.
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   215
+         */
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   216
+        close (fd);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   217
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   218
+        return;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   219
+}
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   220
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   221
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   222
 GQuark
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   223
 gdm_session_worker_error_quark (void)
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   224
 {
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   225
@@ -592,7 +703,11 @@ static gboolean
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   226
 gdm_session_worker_get_username (GdmSessionWorker  *worker,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   227
                                  char             **username)
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   228
 {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   229
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   230
+        gpointer item;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   231
+#else
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   232
         gconstpointer item;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   233
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   234
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   235
         g_assert (worker->priv->pam_handle != NULL);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   236
 
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   237
@@ -861,7 +976,7 @@ gdm_session_worker_process_pam_message (GdmSessionWorker          *worker,
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   238
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   239
 static int
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   240
 gdm_session_worker_pam_new_messages_handler (int                        number_of_messages,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   241
-                                             const struct pam_message **messages,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   242
+                                             GDM_PAM_QUAL struct pam_message **messages,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   243
                                              struct pam_response      **responses,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   244
                                              GdmSessionWorker          *worker)
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   245
 {
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   246
@@ -1987,6 +2102,11 @@ gdm_session_worker_start_user_session (GdmSessionWorker  *worker,
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   247
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   248
         passwd_entry = getpwnam (worker->priv->username);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   249
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   250
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   251
+        solaris_xserver_cred (worker->priv->username,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   252
+                              passwd_entry,
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   253
+                              worker->priv->x11_display_name);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   254
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   255
 #ifdef  HAVE_LOGINDEVPERM
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   256
         /*
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   257
          * Only do logindevperm processing if /dev/console or
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   258
diff --git a/daemon/main.c b/daemon/main.c
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   259
index 8577ba7..0f2a007 100644
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   260
--- a/daemon/main.c
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   261
+++ b/daemon/main.c
16844
5a55ad37c87d 2009-10-23 Halton Huo <[email protected]>
halton
parents: 16436
diff changeset
   262
@@ -525,6 +525,21 @@ main (int    argc,
16338
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   263
                 { NULL }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   264
         };
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   265
 
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   266
+#ifdef __sun
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   267
+        {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   268
+                struct stat statbuf;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   269
+                int r;
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   270
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   271
+                r = stat (GDM_DT_DIR, &statbuf);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   272
+                if (r < 0) {
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   273
+                        g_mkdir (GDM_DT_DIR, 0755);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   274
+                }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   275
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   276
+                g_remove (GDM_SDTLOGIN_DIR);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   277
+                g_mkdir (GDM_SDTLOGIN_DIR, 0700);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   278
+        }
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   279
+#endif
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   280
+
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   281
         bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   282
         textdomain (GETTEXT_PACKAGE);
7f746135863a 2009-08-24 Brian Cameron <[email protected]>
yippi
parents:
diff changeset
   283
         setlocale (LC_ALL, "");