10 For the original definition, see Sun ASARC case 1995/390. |
10 For the original definition, see Sun ASARC case 1995/390. |
11 For the current implementation in the X server, see sun-src/os/dtlogin.c |
11 For the current implementation in the X server, see sun-src/os/dtlogin.c |
12 and dtlogin-userinfo.patch in open-src/xserver/xorg in the X gate. |
12 and dtlogin-userinfo.patch in open-src/xserver/xorg in the X gate. |
13 --- |
13 --- |
14 common/gdm-common.h | 5 ++ |
14 common/gdm-common.h | 5 ++ |
15 daemon/gdm-server.c | 11 +++++ |
15 daemon/gdm-server.c | 11 ++++ |
16 daemon/gdm-session-worker.c | 116 ++++++++++++++++++++++++++++++++++++++++++++ |
16 daemon/gdm-session-worker.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ |
17 daemon/main.c | 15 ++++++ |
17 daemon/main.c | 15 ++++++ |
18 4 files changed, 147 insertions(+) |
18 4 files changed, 150 insertions(+) |
19 |
19 |
20 diff --git a/common/gdm-common.h b/common/gdm-common.h |
20 diff --git a/common/gdm-common.h b/common/gdm-common.h |
21 index 19dbbbb..6ac61c0 100644 |
21 index 19dbbbb..6ac61c0 100644 |
22 --- a/common/gdm-common.h |
22 --- a/common/gdm-common.h |
23 +++ b/common/gdm-common.h |
23 +++ b/common/gdm-common.h |
54 + |
54 + |
55 env = get_server_environment (server); |
55 env = get_server_environment (server); |
56 |
56 |
57 freeme = g_strjoinv (" ", argv); |
57 freeme = g_strjoinv (" ", argv); |
58 diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c |
58 diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c |
59 index 291caad..93c9e82 100644 |
59 index 291caad..0b5ac16 100644 |
60 --- a/daemon/gdm-session-worker.c |
60 --- a/daemon/gdm-session-worker.c |
61 +++ b/daemon/gdm-session-worker.c |
61 +++ b/daemon/gdm-session-worker.c |
62 @@ -38,6 +38,7 @@ |
62 @@ -38,6 +38,7 @@ |
63 #include <pwd.h> |
63 #include <pwd.h> |
64 |
64 |
65 #if __sun |
65 #if __sun |
66 +#include <sys/param.h> |
66 +#include <sys/param.h> |
67 #define GDM_PAM_QUAL |
67 #define GDM_PAM_QUAL |
68 #else |
68 #else |
69 #define GDM_PAM_QUAL const |
69 #define GDM_PAM_QUAL const |
70 @@ -2044,6 +2045,115 @@ out: |
70 @@ -2044,6 +2045,118 @@ out: |
71 return fd; |
71 return fd; |
72 } |
72 } |
73 |
73 |
74 +#ifdef __sun |
74 +#ifdef __sun |
75 +static void |
75 +static void |
76 +solaris_xserver_cred (const char *username, struct passwd *passwd_entry, |
76 +solaris_xserver_cred (const char *username, struct passwd *passwd_entry, |
77 + const char *x11_display_name) |
77 + const char *x11_display_name) |
78 +{ |
78 +{ |
79 + FILE *fp; |
79 + static FILE *fp; |
80 + struct stat statbuf; |
80 + struct stat statbuf; |
81 + gid_t groups[NGROUPS_UMAX]; |
81 + gid_t groups[NGROUPS_UMAX]; |
82 + char *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN]; |
82 + char *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN]; |
83 + int display_number = 0; |
83 + int display_number = 0; |
84 + int fd, i; |
84 + int fd, i; |
85 + int ngroups; |
85 + int ngroups; |
86 + |
86 + |
87 + if (g_access (passwd_entry->pw_dir, F_OK) != 0) { |
87 + if (fp == NULL) { /* Open & setup fp on first access */ |
88 + g_debug ("solaris_xserver_cred: no HOME dir access\n"); |
88 + /* |
89 + return; |
89 + * Handshake with server. Make sure it created a pipe. |
90 + } |
90 + * Open and write. |
91 + |
91 + */ |
92 + /* |
92 + if ((tmp = strstr (x11_display_name, ":")) != NULL) { |
93 + * Handshake with server. Make sure it created a pipe. |
93 + tmp++; |
94 + * Open and write. |
94 + display_number = g_ascii_strtod (tmp, &p); |
95 + */ |
95 + |
96 + if ((tmp = strstr (x11_display_name, ":")) != NULL) { |
96 + if (errno != 0) { |
97 + tmp++; |
97 + g_warning ("solaris_xserver_cred: problem" |
98 + display_number = g_ascii_strtod (tmp, &p); |
98 + " getting display number\n"); |
99 + |
99 + return; |
100 + if (errno != 0) { |
100 + } |
101 + g_debug ("solaris_xserver_cred: problem getting display number\n"); |
101 + } |
102 + return; |
102 + |
103 + } |
103 + if (stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) { |
104 + } |
104 + if (! S_ISDIR(statbuf.st_mode)) { |
105 + |
105 + g_warning ("solaris_xserver_cred: %s is not" |
106 + if (g_stat (GDM_SDTLOGIN_DIR, &statbuf) == 0) { |
106 + " a directory\n", GDM_SDTLOGIN_DIR); |
107 + if (! S_ISDIR(statbuf.st_mode)) { |
107 + return; |
108 + g_debug ("solaris_xserver_cred: %s is not a directory\n", |
108 + } |
109 + GDM_SDTLOGIN_DIR); |
109 + } else { |
110 + return; |
110 + g_warning ("solaris_xserver_cred: %s: %s\n", |
111 + } |
111 + GDM_SDTLOGIN_DIR, g_strerror(errno)); |
112 + } else { |
112 + return; |
113 + g_debug ("solaris_xserver_cred: %s does not exist\n", GDM_SDTLOGIN_DIR); |
113 + } |
114 + return; |
114 + |
115 + } |
115 + snprintf (pipe, sizeof(pipe), "%s/%d", |
116 + |
116 + GDM_SDTLOGIN_DIR, display_number); |
117 + snprintf (pipe, sizeof(pipe), "%s/%d", GDM_SDTLOGIN_DIR, display_number); |
117 + fd = open (pipe, O_RDWR | O_CLOEXEC | O_NOFOLLOW); |
118 + fd = open (pipe, O_RDWR); |
118 + |
119 + g_remove (pipe); |
119 + if (fd < 0) { |
120 + |
120 + g_warning ("solaris_xserver_cred: could not open" |
121 + if (fd < 0) { |
121 + " %s: %s\n", pipe, g_strerror(errno)); |
122 + g_debug ("solaris_xserver_cred: could not open %s\n", pipe); |
122 + return; |
123 + return; |
123 + } |
124 + } |
124 + if (fstat (fd, &statbuf) == 0 ) { |
125 + if (fstat (fd, &statbuf) == 0 ) { |
125 + if (! S_ISFIFO(statbuf.st_mode)) { |
126 + if (! S_ISFIFO(statbuf.st_mode)) { |
126 + close (fd); |
|
127 + g_warning ("solaris_xserver_cred: %s is not" |
|
128 + " a pipe\n", pipe); |
|
129 + return; |
|
130 + } |
|
131 + } else { |
127 + close (fd); |
132 + close (fd); |
128 + g_debug ("solaris_xserver_cred: %s is not a pipe\n", pipe); |
133 + g_warning ("solaris_xserver_cred: %s: %s\n", |
129 + return; |
134 + pipe, g_strerror(errno)); |
130 + } |
135 + return; |
131 + } else { |
136 + } |
132 + close (fd); |
137 + fp = fdopen (fd, "w"); |
133 + g_debug ("solaris_xserver_cred: %s does not exist\n", pipe); |
138 + if (fp == NULL) { |
134 + return; |
139 + close (fd); |
135 + } |
140 + g_warning ("solaris_xserver_cred: could not fdopen" |
136 + fp = fdopen (fd, "w"); |
141 + " %s: %s\n", pipe, g_strerror(errno)); |
137 + if (fp == NULL) { |
142 + return; |
138 + close (fd); |
143 + } |
139 + g_debug ("solaris_xserver_cred: could not fdopen %s\n", pipe); |
|
140 + return; |
|
141 + } |
144 + } |
142 + |
145 + |
143 + snprintf (info, sizeof(info), "GID=\"%d\"; ", passwd_entry->pw_gid); |
146 + snprintf (info, sizeof(info), "GID=\"%d\"; ", passwd_entry->pw_gid); |
144 + fputs (info, fp); |
147 + fputs (info, fp); |
145 + g_debug ("solaris_xserver_cred: %s\n", info); |
148 + g_debug ("solaris_xserver_cred: %s\n", info); |
162 + |
165 + |
163 + snprintf (info, sizeof(info), " HOME=\"%s\" ", passwd_entry->pw_dir); |
166 + snprintf (info, sizeof(info), " HOME=\"%s\" ", passwd_entry->pw_dir); |
164 + fputs (info, fp); |
167 + fputs (info, fp); |
165 + g_debug ("solaris_xserver_cred: %s\n", info); |
168 + g_debug ("solaris_xserver_cred: %s\n", info); |
166 + |
169 + |
167 + snprintf (info, sizeof(info), " UID=\"%d\" EOF=\"\";", passwd_entry->pw_uid); |
170 + snprintf (info, sizeof(info), " UID=\"%d\" EOF=\"\";", |
|
171 + passwd_entry->pw_uid); |
168 + fputs (info, fp); |
172 + fputs (info, fp); |
169 + g_debug ("solaris_xserver_cred: %s\n", info); |
173 + g_debug ("solaris_xserver_cred: %s\n", info); |
170 + |
174 + |
171 + /* |
175 + /* |
172 + * Handshake with server. Make sure it read the pipe. |
176 + * Handshake with server. Make sure it read the pipe. |
173 + * |
177 + * |
174 + * Close file descriptor. |
178 + * Do not close file descriptor, but leave it open for further use. |
175 + */ |
179 + */ |
176 + fflush (fp); |
180 + VE_IGNORE_EINTR (fflush (fp)); |
177 + fclose (fp); |
|
178 + |
181 + |
179 + return; |
182 + return; |
180 +} |
183 +} |
181 +#endif |
184 +#endif |
182 + |
185 + |
183 static gboolean |
186 static gboolean |
184 gdm_session_worker_start_session (GdmSessionWorker *worker, |
187 gdm_session_worker_start_session (GdmSessionWorker *worker, |
185 GError **error) |
188 GError **error) |
186 @@ -2061,6 +2171,12 @@ gdm_session_worker_start_session (GdmSessionWorker *worker, |
189 @@ -2061,6 +2174,12 @@ gdm_session_worker_start_session (GdmSessionWorker *worker, |
187 worker->priv->arguments[0]); |
190 worker->priv->arguments[0]); |
188 } |
191 } |
189 |
192 |
190 +#ifdef __sun |
193 +#ifdef __sun |
191 + solaris_xserver_cred (worker->priv->username, |
194 + solaris_xserver_cred (worker->priv->username, |