1 Use /var/dt/sdtlogin pipe, created by xorg server, to send user ids,
2 so that server could drop privileges.
4 --- lightdm-1.19.3/src/session-child.c.~8~ 2017-10-25 09:04:02.187093081 +0000
5 +++ lightdm-1.19.3/src/session-child.c 2017-10-25 09:09:14.198153389 +0000
11 +solaris_xserver_cred (const char *username, uid_t uid, gid_t gid, const char *home_dir,
12 + const char *xdisplay)
15 + struct stat statbuf;
16 + gid_t groups[NGROUPS_UMAX];
17 + char *tmp, *p, pipe[MAXPATHLEN], info[MAXPATHLEN];
18 + int display_number = 0;
22 + if (fp == NULL) { /* Open & setup fp on first access */
24 + * Handshake with server. Make sure it created a pipe.
27 + if ((tmp = strstr (xdisplay, ":")) != NULL) {
29 + display_number = g_ascii_strtod (tmp, &p);
32 + g_warning ("solaris_xserver_cred: problem"
33 + " getting display number\n");
38 + if (stat (SDTLOGIN_DIR, &statbuf) == 0) {
39 + if (! S_ISDIR(statbuf.st_mode)) {
40 + g_warning ("solaris_xserver_cred: %s is not"
41 + " a directory\n", SDTLOGIN_DIR);
45 + g_warning ("solaris_xserver_cred: %s: %s\n",
46 + SDTLOGIN_DIR, g_strerror(errno));
50 + snprintf (pipe, sizeof(pipe), "%s/%d",
51 + SDTLOGIN_DIR, display_number);
52 + fd = open (pipe, O_RDWR | O_CLOEXEC | O_NOFOLLOW);
55 + g_warning ("solaris_xserver_cred: could not open"
56 + " %s: %s\n", pipe, g_strerror(errno));
59 + if (fstat (fd, &statbuf) == 0 ) {
60 + if (! S_ISFIFO(statbuf.st_mode)) {
62 + g_warning ("solaris_xserver_cred: %s is not"
68 + g_warning ("solaris_xserver_cred: %s: %s\n",
69 + pipe, g_strerror(errno));
72 + fp = fdopen (fd, "w");
75 + g_warning ("solaris_xserver_cred: could not fdopen"
76 + " %s: %s\n", pipe, g_strerror(errno));
81 + snprintf (info, sizeof(info), "GID=\"%d\"; ", gid);
83 + g_debug ("solaris_xserver_cred: %s\n", info);
85 + if (initgroups (username, gid) == -1) {
88 + ngroups = getgroups (NGROUPS_UMAX, groups);
91 + for (i=0; i < ngroups; i++) {
92 + snprintf (info, sizeof(info), "G_LIST_ID=\"%u\" ", groups[i]);
94 + g_debug ("solaris_xserver_cred: %s\n", info);
101 + snprintf (info, sizeof(info), " HOME=\"%s\" ", home_dir);
103 + g_debug ("solaris_xserver_cred: %s\n", info);
105 + snprintf (info, sizeof(info), " UID=\"%d\" EOF=\"\";",
108 + g_debug ("solaris_xserver_cred: %s\n", info);
111 + * Handshake with server. Make sure it read the pipe.
113 + * Do not close file descriptor, but leave it open for further use.
123 @@ -813,6 +813,13 @@ session_child_run (int argc, char **argv
124 uid_t uid = user_get_uid (user);
125 gid_t gid = user_get_gid (user);
126 const gchar *home_directory = user_get_home_directory (user);
129 + if (xdisplay) { /* Should always be true */
130 + solaris_xserver_cred (username, uid, gid, home_directory, xdisplay);
137 --- lightdm-1.19.3/common/configuration.h.1 2017-10-25 08:43:04.689998057 +0000
138 +++ lightdm-1.19.3/common/configuration.h 2017-10-25 08:44:56.582620720 +0000
140 #ifndef CONFIGURATION_H_
141 #define CONFIGURATION_H_
144 + * Perhaps, it's not the best place for it, but it's the only common header
145 + * of lightdm.c and sesion-child.c
148 +#define DT_DIR "/var/dt"
149 +#define SDTLOGIN_DIR "/var/dt/sdtlogin"
152 #include <glib-object.h>
155 --- lightdm-1.19.3/src/lightdm.c.~4~ 2017-10-25 09:12:24.672787804 +0000
156 +++ lightdm-1.19.3/src/lightdm.c 2017-10-25 11:05:49.884502470 +0000
158 #include <sys/stat.h>
160 #include <glib/gi18n.h>
161 +#include <glib/gstdio.h>
164 #include <sys/stat.h>
166 g_warning ("Failed to make cache directory %s: %s", dir, strerror (errno));
171 + struct stat statbuf;
174 + r = stat (DT_DIR, &statbuf);
176 + g_mkdir (DT_DIR, 0755);
179 + r = stat (SDTLOGIN_DIR, &statbuf);
181 + g_mkdir (SDTLOGIN_DIR, 0700);
188 /* Show queued messages once logging is complete */