diff options
author | Colin Watson <cjwatson@ubuntu.com> | 2014-02-09 16:09:57 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2014-10-07 14:27:14 +0100 |
commit | f51fe0c55e54c12db952624e980d18f39c41e581 (patch) | |
tree | 02f5526eaff2259689a4290b2646d0bf1c04f612 /monitor.c | |
parent | aca34215fc0e85d6b49e04f0a3cd0db79732125e (diff) |
Add support for registering ConsoleKit sessions on login
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1450
Last-Updated: 2014-10-07
Patch-Name: consolekit.patch
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -100,6 +100,9 @@ | |||
100 | #include "ssh2.h" | 100 | #include "ssh2.h" |
101 | #include "roaming.h" | 101 | #include "roaming.h" |
102 | #include "authfd.h" | 102 | #include "authfd.h" |
103 | #ifdef USE_CONSOLEKIT | ||
104 | #include "consolekit.h" | ||
105 | #endif | ||
103 | 106 | ||
104 | #ifdef GSSAPI | 107 | #ifdef GSSAPI |
105 | static Gssctxt *gsscontext = NULL; | 108 | static Gssctxt *gsscontext = NULL; |
@@ -190,6 +193,10 @@ int mm_answer_audit_command(int, Buffer *); | |||
190 | 193 | ||
191 | static int monitor_read_log(struct monitor *); | 194 | static int monitor_read_log(struct monitor *); |
192 | 195 | ||
196 | #ifdef USE_CONSOLEKIT | ||
197 | int mm_answer_consolekit_register(int, Buffer *); | ||
198 | #endif | ||
199 | |||
193 | static Authctxt *authctxt; | 200 | static Authctxt *authctxt; |
194 | 201 | ||
195 | #ifdef WITH_SSH1 | 202 | #ifdef WITH_SSH1 |
@@ -282,6 +289,9 @@ struct mon_table mon_dispatch_postauth20[] = { | |||
282 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, | 289 | {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, |
283 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, | 290 | {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, |
284 | #endif | 291 | #endif |
292 | #ifdef USE_CONSOLEKIT | ||
293 | {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register}, | ||
294 | #endif | ||
285 | {0, 0, NULL} | 295 | {0, 0, NULL} |
286 | }; | 296 | }; |
287 | 297 | ||
@@ -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 | #endif /* WITH_SSH1 */ | 343 | #endif /* WITH_SSH1 */ |
331 | {0, 0, NULL} | 344 | {0, 0, NULL} |
332 | }; | 345 | }; |
@@ -509,6 +522,9 @@ monitor_child_postauth(struct monitor *pmonitor) | |||
509 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); | 522 | monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); |
510 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); | 523 | monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); |
511 | } | 524 | } |
525 | #ifdef USE_CONSOLEKIT | ||
526 | monitor_permit(mon_dispatch, MONITOR_REQ_CONSOLEKIT_REGISTER, 1); | ||
527 | #endif | ||
512 | 528 | ||
513 | for (;;) | 529 | for (;;) |
514 | monitor_read(pmonitor, mon_dispatch, NULL); | 530 | monitor_read(pmonitor, mon_dispatch, NULL); |
@@ -2296,3 +2312,29 @@ mm_answer_gss_updatecreds(int socket, Buffer *m) { | |||
2296 | 2312 | ||
2297 | #endif /* GSSAPI */ | 2313 | #endif /* GSSAPI */ |
2298 | 2314 | ||
2315 | #ifdef USE_CONSOLEKIT | ||
2316 | int | ||
2317 | mm_answer_consolekit_register(int sock, Buffer *m) | ||
2318 | { | ||
2319 | Session *s; | ||
2320 | char *tty, *display; | ||
2321 | char *cookie = NULL; | ||
2322 | |||
2323 | debug3("%s entering", __func__); | ||
2324 | |||
2325 | tty = buffer_get_string(m, NULL); | ||
2326 | display = buffer_get_string(m, NULL); | ||
2327 | s = session_by_tty(tty); | ||
2328 | if (s != NULL) | ||
2329 | cookie = consolekit_register(s, display); | ||
2330 | buffer_clear(m); | ||
2331 | buffer_put_cstring(m, cookie != NULL ? cookie : ""); | ||
2332 | mm_request_send(sock, MONITOR_ANS_CONSOLEKIT_REGISTER, m); | ||
2333 | |||
2334 | free(cookie); | ||
2335 | free(display); | ||
2336 | free(tty); | ||
2337 | |||
2338 | return (0); | ||
2339 | } | ||
2340 | #endif /* USE_CONSOLEKIT */ | ||