17046
|
1 |
commit c7a1ad4850e394260cb61582aeefae8f95c3cae8
|
16844
|
2 |
Author: Halton Huo <[email protected]>
|
17046
|
3 |
Date: Fri Nov 27 22:01:20 2009 +0800
|
16844
|
4 |
|
17046
|
5 |
gdm-02-sdtlogin.diff
|
16844
|
6 |
|
16338
|
7 |
diff --git a/common/gdm-common.h b/common/gdm-common.h
|
16844
|
8 |
index 191bd70..634c091 100644
|
16338
|
9 |
--- a/common/gdm-common.h
|
|
10 |
+++ b/common/gdm-common.h
|
|
11 |
@@ -25,6 +25,11 @@
|
|
12 |
|
|
13 |
#include "gdm-common-unknown-origin.h"
|
|
14 |
|
|
15 |
+#ifdef __sun
|
|
16 |
+#define GDM_DT_DIR "/var/dt"
|
|
17 |
+#define GDM_SDTLOGIN_DIR "/var/dt/sdtlogin"
|
|
18 |
+#endif
|
|
19 |
+
|
|
20 |
G_BEGIN_DECLS
|
|
21 |
|
|
22 |
gboolean gdm_is_version_unstable (void);
|
|
23 |
diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c
|
17046
|
24 |
index 757ef62..7012811 100644
|
16338
|
25 |
--- a/daemon/gdm-server.c
|
|
26 |
+++ b/daemon/gdm-server.c
|
17046
|
27 |
@@ -646,6 +646,13 @@ gdm_server_spawn (GdmServer *server,
|
|
28 |
count ++;
|
|
29 |
}
|
|
30 |
g_free (socket_file);
|
|
31 |
+#if __sun
|
|
32 |
+ /* Remove old communication pipe, if present */
|
|
33 |
+ char *old_pipe;
|
|
34 |
+ old_pipe = g_strdup_printf ("%s/%d", GDM_SDTLOGIN_DIR, display_num);
|
|
35 |
+ g_unlink (old_pipe);
|
|
36 |
+ g_free (old_pipe);
|
16338
|
37 |
+#endif
|
|
38 |
}
|
|
39 |
|
|
40 |
env = get_server_environment (server);
|
|
41 |
diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c
|
16844
|
42 |
index 2ab53a0..8970297 100644
|
16338
|
43 |
--- a/daemon/gdm-session-worker.c
|
|
44 |
+++ b/daemon/gdm-session-worker.c
|
|
45 |
@@ -36,6 +36,13 @@
|
|
46 |
#include <libdevinfo.h>
|
|
47 |
#endif /* HAVE_LOGINDEVPERM */
|
|
48 |
|
|
49 |
+#if __sun
|
|
50 |
+#include <sys/param.h>
|
|
51 |
+#define GDM_PAM_QUAL
|
|
52 |
+#else
|
|
53 |
+#define GDM_PAM_QUAL const
|
|
54 |
+#endif
|
|
55 |
+
|
|
56 |
#include <security/pam_appl.h>
|
|
57 |
|
|
58 |
#include <glib.h>
|
20009
|
59 |
@@ -65,6 +72,7 @@
|
16338
|
60 |
#endif
|
|
61 |
|
|
62 |
#include "gdm-session-settings.h"
|
|
63 |
+#include "gdm-common.h"
|
|
64 |
|
|
65 |
#define GDM_SESSION_WORKER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SESSION_WORKER, GdmSessionWorkerPrivate))
|
|
66 |
|
20009
|
67 |
@@ -155,12 +163,115 @@ static void gdm_session_worker_final
|
16338
|
68 |
static void queue_state_change (GdmSessionWorker *worker);
|
|
69 |
|
|
70 |
typedef int (* GdmSessionWorkerPamNewMessagesFunc) (int,
|
|
71 |
- const struct pam_message **,
|
|
72 |
+ GDM_PAM_QUAL struct pam_message **,
|
|
73 |
struct pam_response **,
|
|
74 |
gpointer);
|
|
75 |
|
|
76 |
G_DEFINE_TYPE (GdmSessionWorker, gdm_session_worker, G_TYPE_OBJECT)
|
|
77 |
|
|
78 |
+#ifdef __sun
|
|
79 |
+void
|
|
80 |
+solaris_xserver_cred (char * username, struct passwd *passwd_entry, const char *x11_display_name)
|
|
81 |
+{
|
|
82 |
+ struct stat statbuf;
|
|
83 |
+ struct group *gr;
|
|
84 |
+ gid_t groups[NGROUPS_UMAX];
|
|
85 |
+ char *home, *disp, *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN];
|
|
86 |
+ int display_number = 0;
|
|
87 |
+ int retval, fd, i, nb;
|
|
88 |
+ int ngroups;
|
|
89 |
+
|
|
90 |
+ if (g_access (passwd_entry->pw_dir, F_OK) != 0) {
|
|
91 |
+ g_debug ("solaris_xserver_cred: no HOME dir access\n");
|
|
92 |
+ return;
|
|
93 |
+ }
|
|
94 |
+
|
|
95 |
+ /*
|
|
96 |
+ * Handshake with server. Make sure it created a pipe.
|
|
97 |
+ * Open and write.
|
|
98 |
+ */
|
|
99 |
+ if ((tmp = strstr (x11_display_name, ":")) != NULL) {
|
|
100 |
+ tmp++;
|
|
101 |
+ display_number = g_ascii_strtod (tmp, &p);
|
|
102 |
+
|
|
103 |
+ if (errno != 0) {
|
|
104 |
+ g_debug ("solaris_xserver_cred: problem getting display number\n");
|
|
105 |
+ return;
|
|
106 |
+ }
|
|
107 |
+ }
|
|
108 |
+
|
|
109 |
+ sprintf (pipe, "%s/%d", GDM_SDTLOGIN_DIR, display_number);
|
|
110 |
+
|
|
111 |
+ if (g_stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) {
|
|
112 |
+ if (! statbuf.st_mode & S_IFDIR) {
|
|
113 |
+ g_debug ("solaris_xserver_cred: %s is not a directory\n",
|
|
114 |
+ GDM_SDTLOGIN_DIR);
|
|
115 |
+ return;
|
|
116 |
+ }
|
|
117 |
+ } else {
|
|
118 |
+ g_debug ("solaris_xserver_cred: %s does not exist\n", GDM_SDTLOGIN_DIR);
|
|
119 |
+ return;
|
|
120 |
+ }
|
|
121 |
+
|
|
122 |
+ fd = open (pipe, O_RDWR);
|
|
123 |
+ g_unlink (pipe);
|
|
124 |
+
|
|
125 |
+ if (fd < 0) {
|
|
126 |
+ g_debug ("solaris_xserver_cred: could not open %s\n", pipe);
|
|
127 |
+ return;
|
|
128 |
+ }
|
|
129 |
+ if (fstat (fd, &statbuf) == 0 ) {
|
|
130 |
+ if ( ! statbuf.st_mode & S_IFIFO) {
|
|
131 |
+ close (fd);
|
|
132 |
+ g_debug ("solaris_xserver_cred: %s is not a pipe\n", pipe);
|
|
133 |
+ return;
|
|
134 |
+ }
|
|
135 |
+ } else {
|
|
136 |
+ close (fd);
|
|
137 |
+ g_debug ("solaris_xserver_cred: %s does not exist\n", pipe);
|
|
138 |
+ return;
|
|
139 |
+ }
|
|
140 |
+
|
|
141 |
+ sprintf (info, "GID=\"%d\"; ", passwd_entry->pw_gid);
|
|
142 |
+ nb = write (fd, info, strlen (info));
|
|
143 |
+ g_debug ("solaris_xserver_cred: %s\n", info);
|
|
144 |
+
|
|
145 |
+ if (initgroups (username, passwd_entry->pw_gid) == -1) {
|
|
146 |
+ ngroups = 0;
|
|
147 |
+ } else {
|
|
148 |
+ ngroups = getgroups (NGROUPS_UMAX, groups);
|
|
149 |
+ }
|
|
150 |
+
|
|
151 |
+ for (i=0; i < ngroups; i++) {
|
|
152 |
+ sprintf (info, "G_LIST_ID=\"%u\" ", groups[i]);
|
|
153 |
+ nb = write (fd, info, strlen (info));
|
|
154 |
+ g_debug ("solaris_xserver_cred: %s\n", info);
|
|
155 |
+ }
|
|
156 |
+
|
|
157 |
+ if (ngroups > 0) {
|
|
158 |
+ sprintf (info, ";");
|
|
159 |
+ write (fd, info, strlen (info));
|
|
160 |
+ }
|
|
161 |
+
|
|
162 |
+ sprintf (info, " HOME=\"%s\" ", passwd_entry->pw_dir);
|
|
163 |
+ nb = write (fd, info, strlen (info));
|
|
164 |
+ g_debug ("solaris_xserver_cred: %s\n", info);
|
|
165 |
+
|
|
166 |
+ sprintf (info, " UID=\"%d\" EOF=\"\";", passwd_entry->pw_uid);
|
|
167 |
+ nb = write (fd, info, strlen (info));
|
|
168 |
+ g_debug ("solaris_xserver_cred: %s\n", info);
|
|
169 |
+
|
|
170 |
+ /*
|
|
171 |
+ * Handshake with server. Make sure it read the pipe.
|
|
172 |
+ *
|
|
173 |
+ * Close file descriptor.
|
|
174 |
+ */
|
|
175 |
+ close (fd);
|
|
176 |
+
|
|
177 |
+ return;
|
|
178 |
+}
|
|
179 |
+#endif
|
|
180 |
+
|
|
181 |
GQuark
|
|
182 |
gdm_session_worker_error_quark (void)
|
|
183 |
{
|
20009
|
184 |
@@ -591,7 +702,11 @@ static gboolean
|
16338
|
185 |
gdm_session_worker_get_username (GdmSessionWorker *worker,
|
|
186 |
char **username)
|
|
187 |
{
|
|
188 |
+#ifdef __sun
|
|
189 |
+ gpointer item;
|
|
190 |
+#else
|
|
191 |
gconstpointer item;
|
|
192 |
+#endif
|
|
193 |
|
|
194 |
g_assert (worker->priv->pam_handle != NULL);
|
|
195 |
|
20009
|
196 |
@@ -865,7 +980,7 @@ gdm_session_worker_process_pam_message (
|
16338
|
197 |
|
|
198 |
static int
|
|
199 |
gdm_session_worker_pam_new_messages_handler (int number_of_messages,
|
|
200 |
- const struct pam_message **messages,
|
|
201 |
+ GDM_PAM_QUAL struct pam_message **messages,
|
|
202 |
struct pam_response **responses,
|
|
203 |
GdmSessionWorker *worker)
|
|
204 |
{
|
20009
|
205 |
@@ -2016,6 +2131,11 @@ gdm_session_worker_start_user_session (G
|
16338
|
206 |
|
20009
|
207 |
gdm_get_pwent_for_name (worker->priv->username, &passwd_entry);
|
16338
|
208 |
|
|
209 |
+#ifdef __sun
|
|
210 |
+ solaris_xserver_cred (worker->priv->username,
|
|
211 |
+ passwd_entry,
|
|
212 |
+ worker->priv->x11_display_name);
|
|
213 |
+#endif
|
|
214 |
#ifdef HAVE_LOGINDEVPERM
|
|
215 |
/*
|
|
216 |
* Only do logindevperm processing if /dev/console or
|
16844
|
217 |
diff --git a/daemon/main.c b/daemon/main.c
|
|
218 |
index 8577ba7..0f2a007 100644
|
16338
|
219 |
--- a/daemon/main.c
|
|
220 |
+++ b/daemon/main.c
|
16844
|
221 |
@@ -525,6 +525,21 @@ main (int argc,
|
16338
|
222 |
{ NULL }
|
|
223 |
};
|
|
224 |
|
|
225 |
+#ifdef __sun
|
|
226 |
+ {
|
|
227 |
+ struct stat statbuf;
|
|
228 |
+ int r;
|
|
229 |
+
|
|
230 |
+ r = stat (GDM_DT_DIR, &statbuf);
|
|
231 |
+ if (r < 0) {
|
|
232 |
+ g_mkdir (GDM_DT_DIR, 0755);
|
|
233 |
+ }
|
|
234 |
+
|
|
235 |
+ g_remove (GDM_SDTLOGIN_DIR);
|
|
236 |
+ g_mkdir (GDM_SDTLOGIN_DIR, 0700);
|
|
237 |
+ }
|
|
238 |
+#endif
|
|
239 |
+
|
|
240 |
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
|
241 |
textdomain (GETTEXT_PACKAGE);
|
|
242 |
setlocale (LC_ALL, "");
|