diff options
author | Colin Watson <cjwatson@ubuntu.com> | 2014-02-09 16:09:57 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2014-03-20 00:32:21 +0000 |
commit | 7a26d16efb4ee303c8d66ee82caf9d0686f4a074 (patch) | |
tree | 131e8962617e1f41402ba2468ad331dd888c101a /monitor.c | |
parent | ef912859a4300360164292abe47b5516c8ee4a13 (diff) |
Add support for registering ConsoleKit sessions on login
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1450
Last-Updated: 2014-03-20
Patch-Name: consolekit.patch
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -97,6 +97,9 @@ | |||
97 | #include "ssh2.h" | 97 | #include "ssh2.h" |
98 | #include "roaming.h" | 98 | #include "roaming.h" |
99 | #include "authfd.h" | 99 | #include "authfd.h" |
100 | #ifdef USE_CONSOLEKIT | ||
101 | #include "consolekit.h" | ||
102 | #endif | ||
100 | 103 | ||
101 | #ifdef GSSAPI | 104 | #ifdef GSSAPI |
102 | static Gssctxt *gsscontext = NULL; | 105 | static Gssctxt *gsscontext = NULL; |
@@ -187,6 +190,10 @@ int mm_answer_audit_command(int, Buffer *); | |||
187 | 190 | ||
188 | static int monitor_read_log(struct monitor *); | 191 | static int monitor_read_log(struct monitor *); |
189 | 192 | ||
193 | #ifdef USE_CONSOLEKIT | ||
194 | int mm_answer_consolekit_register(int, Buffer *); | ||
195 | #endif | ||
196 | |||
190 | static Authctxt *authctxt; | 197 | static Authctxt *authctxt; |
191 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ | 198 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ |
192 | 199 | ||
@@ -272,6 +279,9 @@ struct mon_table mon_dispatch_postauth20[] = { | |||
272 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | 279 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, |
273 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, | 280 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, |
274 | #endif | 281 | #endif |
282 | #ifdef USE_CONSOLEKIT | ||
283 | {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
284 | #endif | ||
275 | {0, 0, NULL} | 285 | {0, 0, NULL} |
276 | }; | 286 | }; |
277 | 287 | ||
@@ -314,6 +324,9 @@ struct mon_table mon_dispatch_postauth15[] = { | |||
314 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | 324 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, |
315 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, | 325 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, |
316 | #endif | 326 | #endif |
327 | #ifdef USE_CONSOLEKIT | ||
328 | {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
329 | #endif | ||
317 | {0, 0, NULL} | 330 | {0, 0, NULL} |
318 | }; | 331 | }; |
319 | 332 | ||
@@ -492,6 +505,9 @@ monitor_child_postauth(struct monitor *pmonitor) | |||
492 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); | 505 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); |
493 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); | 506 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); |
494 | } | 507 | } |
508 | #ifdef USE_CONSOLEKIT | ||
509 | monitor_permit(mon_dispatch, MONITOR_REQ_CONSOLEKIT_REGISTER, 1); | ||
510 | #endif | ||
495 | 511 | ||
496 | for (;;) | 512 | for (;;) |
497 | monitor_read(pmonitor, mon_dispatch, NULL); | 513 | monitor_read(pmonitor, mon_dispatch, NULL); |
@@ -2269,3 +2285,29 @@ mm_answer_gss_updatecreds(int socket, Buffer *m) { | |||
2269 | 2285 | ||
2270 | #endif /* GSSAPI */ | 2286 | #endif /* GSSAPI */ |
2271 | 2287 | ||
2288 | #ifdef USE_CONSOLEKIT | ||
2289 | int | ||
2290 | mm_answer_consolekit_register(int sock, Buffer *m) | ||
2291 | { | ||
2292 | Session *s; | ||
2293 | char *tty, *display; | ||
2294 | char *cookie = NULL; | ||
2295 | |||
2296 | debug3("%s entering", __func__); | ||
2297 | |||
2298 | tty = buffer_get_string(m, NULL); | ||
2299 | display = buffer_get_string(m, NULL); | ||
2300 | s = session_by_tty(tty); | ||
2301 | if (s != NULL) | ||
2302 | cookie = consolekit_register(s, display); | ||
2303 | buffer_clear(m); | ||
2304 | buffer_put_cstring(m, cookie != NULL ? cookie : ""); | ||
2305 | mm_request_send(sock, MONITOR_ANS_CONSOLEKIT_REGISTER, m); | ||
2306 | |||
2307 | free(cookie); | ||
2308 | free(display); | ||
2309 | free(tty); | ||
2310 | |||
2311 | return (0); | ||
2312 | } | ||
2313 | #endif /* USE_CONSOLEKIT */ | ||