diff options
author | Colin Watson <cjwatson@ubuntu.com> | 2014-02-09 16:09:57 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2014-03-19 16:40:05 +0000 |
commit | f4858fd1a10d1621e5e3ad5f2400dd17d156ced7 (patch) | |
tree | fd32a151706ddc21e063edb81d9352305fd43f7d /monitor.c | |
parent | 29a3d408fe0b8e91aed47ec4ad26d0c0a16e8f65 (diff) |
Add support for registering ConsoleKit sessions on login
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1450
Last-Updated: 2013-09-14
Patch-Name: consolekit.patch
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -98,6 +98,9 @@ | |||
98 | #include "jpake.h" | 98 | #include "jpake.h" |
99 | #include "roaming.h" | 99 | #include "roaming.h" |
100 | #include "authfd.h" | 100 | #include "authfd.h" |
101 | #ifdef USE_CONSOLEKIT | ||
102 | #include "consolekit.h" | ||
103 | #endif | ||
101 | 104 | ||
102 | #ifdef GSSAPI | 105 | #ifdef GSSAPI |
103 | static Gssctxt *gsscontext = NULL; | 106 | static Gssctxt *gsscontext = NULL; |
@@ -193,6 +196,10 @@ int mm_answer_audit_command(int, Buffer *); | |||
193 | 196 | ||
194 | static int monitor_read_log(struct monitor *); | 197 | static int monitor_read_log(struct monitor *); |
195 | 198 | ||
199 | #ifdef USE_CONSOLEKIT | ||
200 | int mm_answer_consolekit_register(int, Buffer *); | ||
201 | #endif | ||
202 | |||
196 | static Authctxt *authctxt; | 203 | static Authctxt *authctxt; |
197 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ | 204 | static BIGNUM *ssh1_challenge = NULL; /* used for ssh1 rsa auth */ |
198 | 205 | ||
@@ -285,6 +292,9 @@ struct mon_table mon_dispatch_postauth20[] = { | |||
285 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | 292 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, |
286 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, | 293 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, |
287 | #endif | 294 | #endif |
295 | #ifdef USE_CONSOLEKIT | ||
296 | {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
297 | #endif | ||
288 | {0, 0, NULL} | 298 | {0, 0, NULL} |
289 | }; | 299 | }; |
290 | 300 | ||
@@ -327,6 +337,9 @@ struct mon_table mon_dispatch_postauth15[] = { | |||
327 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | 337 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, |
328 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, | 338 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, |
329 | #endif | 339 | #endif |
340 | #ifdef USE_CONSOLEKIT | ||
341 | {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
342 | #endif | ||
330 | {0, 0, NULL} | 343 | {0, 0, NULL} |
331 | }; | 344 | }; |
332 | 345 | ||
@@ -514,6 +527,9 @@ monitor_child_postauth(struct monitor *pmonitor) | |||
514 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); | 527 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); |
515 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); | 528 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); |
516 | } | 529 | } |
530 | #ifdef USE_CONSOLEKIT | ||
531 | monitor_permit(mon_dispatch, MONITOR_REQ_CONSOLEKIT_REGISTER, 1); | ||
532 | #endif | ||
517 | 533 | ||
518 | for (;;) | 534 | for (;;) |
519 | monitor_read(pmonitor, mon_dispatch, NULL); | 535 | monitor_read(pmonitor, mon_dispatch, NULL); |
@@ -2493,3 +2509,30 @@ mm_answer_jpake_check_confirm(int sock, Buffer *m) | |||
2493 | } | 2509 | } |
2494 | 2510 | ||
2495 | #endif /* JPAKE */ | 2511 | #endif /* JPAKE */ |
2512 | |||
2513 | #ifdef USE_CONSOLEKIT | ||
2514 | int | ||
2515 | mm_answer_consolekit_register(int sock, Buffer *m) | ||
2516 | { | ||
2517 | Session *s; | ||
2518 | char *tty, *display; | ||
2519 | char *cookie = NULL; | ||
2520 | |||
2521 | debug3("%s entering", __func__); | ||
2522 | |||
2523 | tty = buffer_get_string(m, NULL); | ||
2524 | display = buffer_get_string(m, NULL); | ||
2525 | s = session_by_tty(tty); | ||
2526 | if (s != NULL) | ||
2527 | cookie = consolekit_register(s, display); | ||
2528 | buffer_clear(m); | ||
2529 | buffer_put_cstring(m, cookie != NULL ? cookie : ""); | ||
2530 | mm_request_send(sock, MONITOR_ANS_CONSOLEKIT_REGISTER, m); | ||
2531 | |||
2532 | free(cookie); | ||
2533 | free(display); | ||
2534 | free(tty); | ||
2535 | |||
2536 | return (0); | ||
2537 | } | ||
2538 | #endif /* USE_CONSOLEKIT */ | ||