]>
Commit | Line | Data |
---|---|---|
0fcc1ff4 | 1 | --- |
2 | configure.ac | 14 ++++++++ | |
3 | dm.h | 3 + | |
4 | resource.c | 13 +++++++ | |
5 | session.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
6 | xdm.man.cpp | 6 +++ | |
7 | 5 files changed, 135 insertions(+), 1 deletion(-) | |
8 | ||
9 | Index: xdm-1.1.10/configure.ac | |
10 | =================================================================== | |
21d22656 MK |
11 | diff -urNp -x '*.orig' xdm-1.1.12.org/configure.ac xdm-1.1.12/configure.ac |
12 | --- xdm-1.1.12.org/configure.ac 2019-03-02 22:06:13.000000000 +0000 | |
13 | +++ xdm-1.1.12/configure.ac 2022-04-06 18:25:09.812244306 +0000 | |
14 | @@ -429,6 +429,20 @@ AM_CONDITIONAL(HAS_XDM_AUTH, test x$xdma | |
15 | AC_SUBST(XDM_CFLAGS) | |
16 | AC_SUBST(XDM_LIBS) | |
0fcc1ff4 | 17 | |
18 | +# ConsoleKit support | |
19 | +AC_ARG_WITH(consolekit, AC_HELP_STRING([--with-consolekit], [Use ConsoleKit]), | |
20 | + [USE_CONSOLEKIT=$withval], [USE_CONSOLEKIT=yes]) | |
21 | +if test x"$USE_CONSOLEKIT" != xno; then | |
22 | + PKG_CHECK_MODULES(CK_CONNECTOR, ck-connector, | |
23 | + [USE_CONSOLEKIT=yes], [USE_CONSOLEKIT=no]) | |
24 | + if test x"$USE_CONSOLEKIT" = xyes; then | |
25 | + AC_DEFINE([USE_CONSOLEKIT], 1, [Define to 1 to use ConsoleKit]) | |
26 | + XDM_CFLAGS="$XDM_CFLAGS $CK_CONNECTOR_CFLAGS" | |
27 | + XDM_LIBS="$XDM_LIBS $CK_CONNECTOR_LIBS" | |
28 | + fi | |
29 | +fi | |
30 | +dnl AM_CONDITIONAL(USE_CONSOLEKIT, test$USE_CONSOLEKIT = xyes) | |
31 | + | |
32 | # | |
21d22656 | 33 | # xdmshell |
0fcc1ff4 | 34 | # |
21d22656 MK |
35 | diff -urNp -x '*.orig' xdm-1.1.12.org/include/dm.h xdm-1.1.12/include/dm.h |
36 | --- xdm-1.1.12.org/include/dm.h 2019-03-02 22:06:13.000000000 +0000 | |
37 | +++ xdm-1.1.12/include/dm.h 2022-04-06 18:25:09.813244308 +0000 | |
38 | @@ -327,6 +327,9 @@ extern char *randomFile; | |
39 | extern char *prngdSocket; | |
40 | extern int prngdPort; | |
41 | # endif | |
42 | +#ifdef USE_CONSOLEKIT | |
43 | +extern int use_consolekit; | |
44 | +#endif | |
45 | ||
46 | extern char *greeterLib; | |
47 | extern char *willing; | |
48 | diff -urNp -x '*.orig' xdm-1.1.12.org/man/xdm.man xdm-1.1.12/man/xdm.man | |
49 | --- xdm-1.1.12.org/man/xdm.man 2019-03-02 22:06:13.000000000 +0000 | |
50 | +++ xdm-1.1.12/man/xdm.man 2022-04-06 18:25:09.813244308 +0000 | |
51 | @@ -48,6 +48,8 @@ xdm \- X Display Manager with support fo | |
52 | ] [ | |
53 | .B \-session | |
54 | .I session_program | |
55 | +] [ | |
56 | +.B \-noconsolekit | |
57 | ] | |
58 | .SH DESCRIPTION | |
59 | .I Xdm | |
60 | @@ -215,6 +217,10 @@ indicates the program to run as the sess | |
61 | .IP "\fB\-xrm\fP \fIresource_specification\fP" | |
62 | Allows an arbitrary resource to be specified, as in most | |
63 | X Toolkit applications. | |
64 | +.IP "\fB\-noconsolekit\fP" | |
65 | +Specifies ``false'' as the value for the \fBDisplayManager.consoleKit\fP | |
66 | +resource. | |
67 | +This suppresses the session management using ConsoleKit. | |
68 | .SH RESOURCES | |
69 | At many stages the actions of | |
70 | .I xdm | |
71 | diff -urNp -x '*.orig' xdm-1.1.12.org/xdm/resource.c xdm-1.1.12/xdm/resource.c | |
72 | --- xdm-1.1.12.org/xdm/resource.c 2019-03-02 22:06:13.000000000 +0000 | |
73 | +++ xdm-1.1.12/xdm/resource.c 2022-04-06 18:25:09.813244308 +0000 | |
74 | @@ -65,6 +65,9 @@ char *randomDevice; | |
75 | char *prngdSocket; | |
76 | int prngdPort; | |
77 | #endif | |
78 | +#ifdef USE_CONSOLEKIT | |
79 | +int use_consolekit; | |
80 | +#endif | |
81 | ||
82 | char *greeterLib; | |
83 | char *willing; | |
84 | @@ -192,6 +195,10 @@ struct dmResources { | |
85 | "false"} , | |
86 | { "willing", "Willing", DM_STRING, &willing, | |
87 | ""} , | |
88 | +#ifdef USE_CONSOLEKIT | |
89 | +{ "consoleKit", "ConsoleKit", DM_BOOL, (char **) &use_consolekit, | |
90 | + "true"} , | |
91 | +#endif | |
92 | }; | |
93 | ||
94 | #define NUM_DM_RESOURCES (sizeof DmResources / sizeof DmResources[0]) | |
95 | @@ -377,7 +384,11 @@ XrmOptionDescRec optionTable [] = { | |
96 | {"-debug", "*debugLevel", XrmoptionSepArg, (caddr_t) NULL }, | |
97 | {"-xrm", NULL, XrmoptionResArg, (caddr_t) NULL }, | |
98 | {"-daemon", ".daemonMode", XrmoptionNoArg, "true" }, | |
99 | -{"-nodaemon", ".daemonMode", XrmoptionNoArg, "false" } | |
100 | +{"-nodaemon", ".daemonMode", XrmoptionNoArg, "false" }, | |
101 | +#ifdef USE_CONSOLEKIT | |
102 | +{"-consolekit", ".consoleKit", XrmoptionNoArg, "true" }, | |
103 | +{"-noconsolekit", ".consoleKit", XrmoptionNoArg, "false" } | |
104 | +#endif | |
105 | }; | |
106 | ||
107 | static int originalArgc; | |
108 | diff -urNp -x '*.orig' xdm-1.1.12.org/xdm/session.c xdm-1.1.12/xdm/session.c | |
109 | --- xdm-1.1.12.org/xdm/session.c 2019-03-02 22:06:13.000000000 +0000 | |
110 | +++ xdm-1.1.12/xdm/session.c 2022-04-06 18:25:09.812244306 +0000 | |
2ac26d5e | 111 | @@ -73,6 +73,11 @@ extern int key_setnet(struct key_netstar |
0fcc1ff4 | 112 | # endif |
113 | #endif /* USE_PAM */ | |
114 | ||
115 | +#ifdef USE_CONSOLEKIT | |
116 | +#include <ck-connector.h> | |
117 | +#include <dbus/dbus.h> | |
118 | +#endif | |
119 | + | |
2ac26d5e JB |
120 | #ifdef USE_SELINUX |
121 | #include <selinux/selinux.h> | |
122 | #include <selinux/get_context_list.h> | |
123 | @@ -523,6 +528,97 @@ UnsecureDisplay (struct display *d, Disp | |
0fcc1ff4 | 124 | } |
125 | } | |
126 | ||
127 | +#ifdef USE_CONSOLEKIT | |
128 | + | |
129 | +static CkConnector *connector; | |
130 | + | |
131 | +static int openCKSession(struct verify_info *verify, struct display *d) | |
132 | +{ | |
133 | + int ret; | |
134 | + DBusError error; | |
135 | + char *remote_host_name = ""; | |
136 | + dbus_bool_t is_local; | |
137 | + char *display_name = ""; | |
138 | + char *display_device = ""; | |
139 | + char devtmp[16]; | |
140 | + | |
141 | + if (!use_consolekit) | |
142 | + return 1; | |
143 | + | |
144 | + is_local = d->displayType.location == Local; | |
145 | + if (d->peerlen > 0 && d->peer) | |
146 | + remote_host_name = d->peer; | |
147 | + if (d->name) | |
148 | + display_name = d->name; | |
149 | + /* how can we get the corresponding tty at best...? */ | |
150 | + if (d->windowPath) { | |
151 | + display_device = strchr(d->windowPath, ':'); | |
152 | + if (display_device && display_device[1]) | |
153 | + display_device++; | |
154 | + else | |
155 | + display_device = d->windowPath; | |
156 | + snprintf(devtmp, sizeof(devtmp), "/dev/tty%s", display_device); | |
157 | + display_device = devtmp; | |
158 | + } | |
159 | + | |
160 | + connector = ck_connector_new(); | |
161 | + if (!connector) { | |
162 | + LogOutOfMem("ck_connector"); | |
163 | + return 0; | |
164 | + } | |
165 | + | |
166 | + dbus_error_init(&error); | |
167 | + ret = ck_connector_open_session_with_parameters( | |
168 | + connector, &error, | |
169 | + "unix-user", &verify->uid, | |
170 | + "x11-display", &display_name, | |
171 | + "x11-display-device", &display_device, | |
172 | + "remote-host-name", &remote_host_name, | |
173 | + "is-local", &is_local, | |
174 | + NULL); | |
175 | + if (!ret) { | |
176 | + if (dbus_error_is_set(&error)) { | |
177 | + LogError("Dbus error: %s\n", error.message); | |
178 | + dbus_error_free(&error); | |
179 | + } else { | |
180 | + LogError("ConsoleKit error\n"); | |
181 | + } | |
182 | + LogError("console-kit-daemon not running?\n"); | |
183 | + ck_connector_unref(connector); | |
184 | + connector = NULL; | |
185 | + return 0; | |
186 | + } | |
187 | + | |
188 | + verify->userEnviron = setEnv(verify->userEnviron, | |
189 | + "XDG_SESSION_COOKIE", ck_connector_get_cookie(connector)); | |
190 | + return 1; | |
191 | +} | |
192 | + | |
193 | +static void closeCKSession(void) | |
194 | +{ | |
195 | + DBusError error; | |
196 | + | |
197 | + if (!connector) | |
198 | + return; | |
199 | + | |
200 | + dbus_error_init(&error); | |
201 | + if (!ck_connector_close_session(connector, &error)) { | |
202 | + if (dbus_error_is_set(&error)) { | |
203 | + LogError("Dbus error: %s\n", error.message); | |
204 | + dbus_error_free(&error); | |
205 | + } else { | |
206 | + LogError("ConsoleKit close error\n"); | |
207 | + } | |
208 | + LogError("console-kit-daemon not running?\n"); | |
209 | + } | |
210 | + ck_connector_unref(connector); | |
211 | + connector = NULL; | |
212 | +} | |
213 | +#else | |
214 | +#define openCKSession(v,d) 1 | |
215 | +#define closeCKSession() | |
216 | +#endif | |
217 | + | |
218 | void | |
219 | SessionExit (struct display *d, int status, int removeAuth) | |
220 | { | |
2ac26d5e | 221 | @@ -537,6 +633,8 @@ SessionExit (struct display *d, int stat |
0fcc1ff4 | 222 | } |
223 | #endif | |
224 | ||
225 | + closeCKSession(); | |
226 | + | |
227 | /* make sure the server gets reset after the session is over */ | |
228 | if (d->serverPid >= 2 && d->resetSignal) | |
229 | kill (d->serverPid, d->resetSignal); | |
2ac26d5e | 230 | @@ -614,6 +712,10 @@ StartClient ( |
0fcc1ff4 | 231 | #ifdef USE_PAM |
232 | if (pamh) pam_open_session(pamh, 0); | |
233 | #endif | |
234 | + | |
235 | + if (!openCKSession(verify, d)) | |
236 | + return 0; | |
237 | + | |
238 | switch (pid = fork ()) { | |
239 | case 0: | |
240 | CleanUpChild (); |