summaryrefslogtreecommitdiff
path: root/monitor.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@ubuntu.com>2014-02-09 16:09:57 +0000
committerColin Watson <cjwatson@debian.org>2015-08-19 17:09:56 +0100
commit1197fd975ab8fd11b1ac83557ef750129b16c0d8 (patch)
treeab0af14bf4b460ffcb98e1aa6bb5d3f7032acf7d /monitor.c
parent5496170cd67abb653e385277bd83b69f1b10905d (diff)
Add support for registering ConsoleKit sessions on login
Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1450 Last-Updated: 2015-08-19 Patch-Name: consolekit.patch
Diffstat (limited to 'monitor.c')
-rw-r--r--monitor.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/monitor.c b/monitor.c
index 3a3d2f03b..12ed6fd00 100644
--- a/monitor.c
+++ b/monitor.c
@@ -104,6 +104,9 @@
104#include "authfd.h" 104#include "authfd.h"
105#include "match.h" 105#include "match.h"
106#include "ssherr.h" 106#include "ssherr.h"
107#ifdef USE_CONSOLEKIT
108#include "consolekit.h"
109#endif
107 110
108#ifdef GSSAPI 111#ifdef GSSAPI
109static Gssctxt *gsscontext = NULL; 112static Gssctxt *gsscontext = NULL;
@@ -169,6 +172,10 @@ int mm_answer_audit_command(int, Buffer *);
169 172
170static int monitor_read_log(struct monitor *); 173static int monitor_read_log(struct monitor *);
171 174
175#ifdef USE_CONSOLEKIT
176int mm_answer_consolekit_register(int, Buffer *);
177#endif
178
172static Authctxt *authctxt; 179static Authctxt *authctxt;
173 180
174#ifdef WITH_SSH1 181#ifdef WITH_SSH1
@@ -261,6 +268,9 @@ struct mon_table mon_dispatch_postauth20[] = {
261 {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, 268 {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
262 {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command}, 269 {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command},
263#endif 270#endif
271#ifdef USE_CONSOLEKIT
272 {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register},
273#endif
264 {0, 0, NULL} 274 {0, 0, NULL}
265}; 275};
266 276
@@ -306,6 +316,9 @@ struct mon_table mon_dispatch_postauth15[] = {
306 {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event}, 316 {MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
307 {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command}, 317 {MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command},
308#endif 318#endif
319#ifdef USE_CONSOLEKIT
320 {MONITOR_REQ_CONSOLEKIT_REGISTER, 0, mm_answer_consolekit_register},
321#endif
309#endif /* WITH_SSH1 */ 322#endif /* WITH_SSH1 */
310 {0, 0, NULL} 323 {0, 0, NULL}
311}; 324};
@@ -488,6 +501,9 @@ monitor_child_postauth(struct monitor *pmonitor)
488 monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1); 501 monitor_permit(mon_dispatch, MONITOR_REQ_PTY, 1);
489 monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1); 502 monitor_permit(mon_dispatch, MONITOR_REQ_PTYCLEANUP, 1);
490 } 503 }
504#ifdef USE_CONSOLEKIT
505 monitor_permit(mon_dispatch, MONITOR_REQ_CONSOLEKIT_REGISTER, 1);
506#endif
491 507
492 for (;;) 508 for (;;)
493 monitor_read(pmonitor, mon_dispatch, NULL); 509 monitor_read(pmonitor, mon_dispatch, NULL);
@@ -2191,3 +2207,29 @@ mm_answer_gss_updatecreds(int socket, Buffer *m) {
2191 2207
2192#endif /* GSSAPI */ 2208#endif /* GSSAPI */
2193 2209
2210#ifdef USE_CONSOLEKIT
2211int
2212mm_answer_consolekit_register(int sock, Buffer *m)
2213{
2214 Session *s;
2215 char *tty, *display;
2216 char *cookie = NULL;
2217
2218 debug3("%s entering", __func__);
2219
2220 tty = buffer_get_string(m, NULL);
2221 display = buffer_get_string(m, NULL);
2222 s = session_by_tty(tty);
2223 if (s != NULL)
2224 cookie = consolekit_register(s, display);
2225 buffer_clear(m);
2226 buffer_put_cstring(m, cookie != NULL ? cookie : "");
2227 mm_request_send(sock, MONITOR_ANS_CONSOLEKIT_REGISTER, m);
2228
2229 free(cookie);
2230 free(display);
2231 free(tty);
2232
2233 return (0);
2234}
2235#endif /* USE_CONSOLEKIT */