summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in3
-rw-r--r--configure.ac25
-rw-r--r--consolekit.c241
-rw-r--r--consolekit.h24
-rw-r--r--monitor.c42
-rw-r--r--monitor.h2
-rw-r--r--monitor_wrap.c30
-rw-r--r--monitor_wrap.h4
-rw-r--r--session.c13
-rw-r--r--session.h6
10 files changed, 389 insertions, 1 deletions
diff --git a/Makefile.in b/Makefile.in
index 3d2a328e7..c406aecef 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -111,7 +111,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
111 sftp-server.o sftp-common.o \ 111 sftp-server.o sftp-common.o \
112 roaming_common.o roaming_serv.o \ 112 roaming_common.o roaming_serv.o \
113 sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \ 113 sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
114 sandbox-seccomp-filter.o sandbox-capsicum.o 114 sandbox-seccomp-filter.o sandbox-capsicum.o \
115 consolekit.o
115 116
116MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out 117MANPAGES = moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
117MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5 118MANPAGES_IN = moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
diff --git a/configure.ac b/configure.ac
index 4d55c46fc..cd6acaf9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4188,6 +4188,30 @@ AC_ARG_WITH([kerberos5],
4188AC_SUBST([GSSLIBS]) 4188AC_SUBST([GSSLIBS])
4189AC_SUBST([K5LIBS]) 4189AC_SUBST([K5LIBS])
4190 4190
4191# Check whether user wants ConsoleKit support
4192CONSOLEKIT_MSG="no"
4193LIBCK_CONNECTOR=""
4194AC_ARG_WITH(consolekit,
4195 [ --with-consolekit Enable ConsoleKit support],
4196 [ if test "x$withval" != "xno" ; then
4197 AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
4198 if test "$PKGCONFIG" != "no"; then
4199 AC_MSG_CHECKING([for ck-connector])
4200 if $PKGCONFIG --exists ck-connector; then
4201 CKCON_CFLAGS=`$PKGCONFIG --cflags ck-connector`
4202 CKCON_LIBS=`$PKGCONFIG --libs ck-connector`
4203 CPPFLAGS="$CPPFLAGS $CKCON_CFLAGS"
4204 SSHDLIBS="$SSHDLIBS $CKCON_LIBS"
4205 AC_MSG_RESULT([yes])
4206 AC_DEFINE(USE_CONSOLEKIT, 1, [Define if you want ConsoleKit support.])
4207 CONSOLEKIT_MSG="yes"
4208 else
4209 AC_MSG_RESULT([no])
4210 fi
4211 fi
4212 fi ]
4213)
4214
4191# Looking for programs, paths and files 4215# Looking for programs, paths and files
4192 4216
4193PRIVSEP_PATH=/var/empty 4217PRIVSEP_PATH=/var/empty
@@ -4989,6 +5013,7 @@ echo " MD5 password support: $MD5_MSG"
4989echo " libedit support: $LIBEDIT_MSG" 5013echo " libedit support: $LIBEDIT_MSG"
4990echo " Solaris process contract support: $SPC_MSG" 5014echo " Solaris process contract support: $SPC_MSG"
4991echo " Solaris project support: $SP_MSG" 5015echo " Solaris project support: $SP_MSG"
5016echo " ConsoleKit support: $CONSOLEKIT_MSG"
4992echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG" 5017echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
4993echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG" 5018echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
4994echo " BSD Auth support: $BSD_AUTH_MSG" 5019echo " BSD Auth support: $BSD_AUTH_MSG"
diff --git a/consolekit.c b/consolekit.c
new file mode 100644
index 000000000..0266f06a2
--- /dev/null
+++ b/consolekit.c
@@ -0,0 +1,241 @@
1/*
2 * Copyright (c) 2008 Colin Watson. All rights reserved.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16/*
17 * Loosely based on pam-ck-connector, which is:
18 *
19 * Copyright (c) 2007 David Zeuthen <davidz@redhat.com>
20 *
21 * Permission is hereby granted, free of charge, to any person
22 * obtaining a copy of this software and associated documentation
23 * files (the "Software"), to deal in the Software without
24 * restriction, including without limitation the rights to use,
25 * copy, modify, merge, publish, distribute, sublicense, and/or sell
26 * copies of the Software, and to permit persons to whom the
27 * Software is furnished to do so, subject to the following
28 * conditions:
29 *
30 * The above copyright notice and this permission notice shall be
31 * included in all copies or substantial portions of the Software.
32 *
33 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
35 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
37 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
38 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 * OTHER DEALINGS IN THE SOFTWARE.
41 */
42
43#include "includes.h"
44
45#ifdef USE_CONSOLEKIT
46
47#include <ck-connector.h>
48
49#include "openbsd-compat/sys-queue.h"
50#include "xmalloc.h"
51#include "channels.h"
52#include "key.h"
53#include "hostfile.h"
54#include "auth.h"
55#include "log.h"
56#include "misc.h"
57#include "servconf.h"
58#include "canohost.h"
59#include "session.h"
60#include "consolekit.h"
61
62extern ServerOptions options;
63extern u_int utmp_len;
64
65void
66set_active(const char *cookie)
67{
68 DBusError err;
69 DBusConnection *connection;
70 DBusMessage *message = NULL, *reply = NULL;
71 char *sid;
72 DBusMessageIter iter, subiter;
73 const char *interface, *property;
74 dbus_bool_t active;
75
76 dbus_error_init(&err);
77 connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &err);
78 if (!connection) {
79 if (dbus_error_is_set(&err)) {
80 error("unable to open DBus connection: %s",
81 err.message);
82 dbus_error_free(&err);
83 }
84 goto out;
85 }
86 dbus_connection_set_exit_on_disconnect(connection, FALSE);
87
88 message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
89 "/org/freedesktop/ConsoleKit/Manager",
90 "org.freedesktop.ConsoleKit.Manager",
91 "GetSessionForCookie");
92 if (!message)
93 goto out;
94 if (!dbus_message_append_args(message, DBUS_TYPE_STRING, &cookie,
95 DBUS_TYPE_INVALID)) {
96 if (dbus_error_is_set(&err)) {
97 error("unable to get current session: %s",
98 err.message);
99 dbus_error_free(&err);
100 }
101 goto out;
102 }
103
104 dbus_error_init(&err);
105 reply = dbus_connection_send_with_reply_and_block(connection, message,
106 -1, &err);
107 if (!reply) {
108 if (dbus_error_is_set(&err)) {
109 error("unable to get current session: %s",
110 err.message);
111 dbus_error_free(&err);
112 }
113 goto out;
114 }
115
116 dbus_error_init(&err);
117 if (!dbus_message_get_args(reply, &err,
118 DBUS_TYPE_OBJECT_PATH, &sid,
119 DBUS_TYPE_INVALID)) {
120 if (dbus_error_is_set(&err)) {
121 error("unable to get current session: %s",
122 err.message);
123 dbus_error_free(&err);
124 }
125 goto out;
126 }
127 dbus_message_unref(reply);
128 dbus_message_unref(message);
129 message = reply = NULL;
130
131 message = dbus_message_new_method_call("org.freedesktop.ConsoleKit",
132 sid, "org.freedesktop.DBus.Properties", "Set");
133 if (!message)
134 goto out;
135 interface = "org.freedesktop.ConsoleKit.Session";
136 property = "active";
137 if (!dbus_message_append_args(message,
138 DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property,
139 DBUS_TYPE_INVALID))
140 goto out;
141 dbus_message_iter_init_append(message, &iter);
142 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT,
143 DBUS_TYPE_BOOLEAN_AS_STRING, &subiter))
144 goto out;
145 active = TRUE;
146 if (!dbus_message_iter_append_basic(&subiter, DBUS_TYPE_BOOLEAN,
147 &active))
148 goto out;
149 if (!dbus_message_iter_close_container(&iter, &subiter))
150 goto out;
151
152 dbus_error_init(&err);
153 reply = dbus_connection_send_with_reply_and_block(connection, message,
154 -1, &err);
155 if (!reply) {
156 if (dbus_error_is_set(&err)) {
157 error("unable to make current session active: %s",
158 err.message);
159 dbus_error_free(&err);
160 }
161 goto out;
162 }
163
164out:
165 if (reply)
166 dbus_message_unref(reply);
167 if (message)
168 dbus_message_unref(message);
169}
170
171/*
172 * We pass display separately rather than using s->display because the
173 * latter is not available in the monitor when using privsep.
174 */
175
176char *
177consolekit_register(Session *s, const char *display)
178{
179 DBusError err;
180 const char *tty = s->tty;
181 const char *remote_host_name;
182 dbus_bool_t is_local = FALSE;
183 const char *cookie = NULL;
184
185 if (s->ckc) {
186 debug("already registered with ConsoleKit");
187 return xstrdup(ck_connector_get_cookie(s->ckc));
188 }
189
190 s->ckc = ck_connector_new();
191 if (!s->ckc) {
192 error("ck_connector_new failed");
193 return NULL;
194 }
195
196 if (!tty)
197 tty = "";
198 if (!display)
199 display = "";
200 remote_host_name = get_remote_name_or_ip(utmp_len, options.use_dns);
201 if (!remote_host_name)
202 remote_host_name = "";
203
204 dbus_error_init(&err);
205 if (!ck_connector_open_session_with_parameters(s->ckc, &err,
206 "unix-user", &s->pw->pw_uid,
207 "display-device", &tty,
208 "x11-display", &display,
209 "remote-host-name", &remote_host_name,
210 "is-local", &is_local,
211 NULL)) {
212 if (dbus_error_is_set(&err)) {
213 debug("%s", err.message);
214 dbus_error_free(&err);
215 } else {
216 debug("insufficient privileges or D-Bus / ConsoleKit "
217 "not available");
218 }
219 return NULL;
220 }
221
222 debug("registered uid=%d on tty='%s' with ConsoleKit",
223 s->pw->pw_uid, s->tty);
224
225 cookie = ck_connector_get_cookie(s->ckc);
226 set_active(cookie);
227 return xstrdup(cookie);
228}
229
230void
231consolekit_unregister(Session *s)
232{
233 if (s->ckc) {
234 debug("unregistering ConsoleKit session %s",
235 ck_connector_get_cookie(s->ckc));
236 ck_connector_unref(s->ckc);
237 s->ckc = NULL;
238 }
239}
240
241#endif /* USE_CONSOLEKIT */
diff --git a/consolekit.h b/consolekit.h
new file mode 100644
index 000000000..8ce371690
--- /dev/null
+++ b/consolekit.h
@@ -0,0 +1,24 @@
1/*
2 * Copyright (c) 2008 Colin Watson. All rights reserved.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifdef USE_CONSOLEKIT
18
19struct Session;
20
21char * consolekit_register(struct Session *, const char *);
22void consolekit_unregister(struct Session *);
23
24#endif /* USE_CONSOLEKIT */
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 */
diff --git a/monitor.h b/monitor.h
index 2d82b8b84..fd8d92cd0 100644
--- a/monitor.h
+++ b/monitor.h
@@ -70,6 +70,8 @@ enum monitor_reqtype {
70 70
71 MONITOR_REQ_AUTHROLE = 154, 71 MONITOR_REQ_AUTHROLE = 154,
72 72
73 MONITOR_REQ_CONSOLEKIT_REGISTER = 156, MONITOR_ANS_CONSOLEKIT_REGISTER = 157,
74
73}; 75};
74 76
75struct mm_master; 77struct mm_master;
diff --git a/monitor_wrap.c b/monitor_wrap.c
index 6ae72a03b..2a0fe9bf6 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -1151,3 +1151,33 @@ mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *store)
1151 1151
1152#endif /* GSSAPI */ 1152#endif /* GSSAPI */
1153 1153
1154#ifdef USE_CONSOLEKIT
1155char *
1156mm_consolekit_register(Session *s, const char *display)
1157{
1158 Buffer m;
1159 char *cookie;
1160
1161 debug3("%s entering", __func__);
1162
1163 if (s->ttyfd == -1)
1164 return NULL;
1165 buffer_init(&m);
1166 buffer_put_cstring(&m, s->tty);
1167 buffer_put_cstring(&m, display != NULL ? display : "");
1168 mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_CONSOLEKIT_REGISTER, &m);
1169 buffer_clear(&m);
1170
1171 mm_request_receive_expect(pmonitor->m_recvfd,
1172 MONITOR_ANS_CONSOLEKIT_REGISTER, &m);
1173 cookie = buffer_get_string(&m, NULL);
1174 buffer_free(&m);
1175
1176 /* treat empty cookie as missing cookie */
1177 if (strlen(cookie) == 0) {
1178 free(cookie);
1179 cookie = NULL;
1180 }
1181 return (cookie);
1182}
1183#endif /* USE_CONSOLEKIT */
diff --git a/monitor_wrap.h b/monitor_wrap.h
index 57e740f89..682939215 100644
--- a/monitor_wrap.h
+++ b/monitor_wrap.h
@@ -108,4 +108,8 @@ int mm_skey_respond(void *, u_int, char **);
108/* zlib allocation hooks */ 108/* zlib allocation hooks */
109void mm_init_compression(struct mm_master *); 109void mm_init_compression(struct mm_master *);
110 110
111#ifdef USE_CONSOLEKIT
112char *mm_consolekit_register(struct Session *, const char *);
113#endif /* USE_CONSOLEKIT */
114
111#endif /* _MM_WRAP_H_ */ 115#endif /* _MM_WRAP_H_ */
diff --git a/session.c b/session.c
index afac4a58f..c6bd7286b 100644
--- a/session.c
+++ b/session.c
@@ -94,6 +94,7 @@
94#include "kex.h" 94#include "kex.h"
95#include "monitor_wrap.h" 95#include "monitor_wrap.h"
96#include "sftp.h" 96#include "sftp.h"
97#include "consolekit.h"
97 98
98#if defined(KRB5) && defined(USE_AFS) 99#if defined(KRB5) && defined(USE_AFS)
99#include <kafs.h> 100#include <kafs.h>
@@ -1144,6 +1145,9 @@ do_setup_env(Session *s, const char *shell)
1144#if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN) 1145#if !defined (HAVE_LOGIN_CAP) && !defined (HAVE_CYGWIN)
1145 char *path = NULL; 1146 char *path = NULL;
1146#endif 1147#endif
1148#ifdef USE_CONSOLEKIT
1149 const char *ckcookie = NULL;
1150#endif /* USE_CONSOLEKIT */
1147 1151
1148 /* Initialize the environment. */ 1152 /* Initialize the environment. */
1149 envsize = 100; 1153 envsize = 100;
@@ -1288,6 +1292,11 @@ do_setup_env(Session *s, const char *shell)
1288 child_set_env(&env, &envsize, "KRB5CCNAME", 1292 child_set_env(&env, &envsize, "KRB5CCNAME",
1289 s->authctxt->krb5_ccname); 1293 s->authctxt->krb5_ccname);
1290#endif 1294#endif
1295#ifdef USE_CONSOLEKIT
1296 ckcookie = PRIVSEP(consolekit_register(s, s->display));
1297 if (ckcookie)
1298 child_set_env(&env, &envsize, "XDG_SESSION_COOKIE", ckcookie);
1299#endif /* USE_CONSOLEKIT */
1291#ifdef USE_PAM 1300#ifdef USE_PAM
1292 /* 1301 /*
1293 * Pull in any environment variables that may have 1302 * Pull in any environment variables that may have
@@ -2351,6 +2360,10 @@ session_pty_cleanup2(Session *s)
2351 2360
2352 debug("session_pty_cleanup: session %d release %s", s->self, s->tty); 2361 debug("session_pty_cleanup: session %d release %s", s->self, s->tty);
2353 2362
2363#ifdef USE_CONSOLEKIT
2364 consolekit_unregister(s);
2365#endif /* USE_CONSOLEKIT */
2366
2354 /* Record that the user has logged out. */ 2367 /* Record that the user has logged out. */
2355 if (s->pid != 0) 2368 if (s->pid != 0)
2356 record_logout(s->pid, s->tty, s->pw->pw_name); 2369 record_logout(s->pid, s->tty, s->pw->pw_name);
diff --git a/session.h b/session.h
index ef6593c34..a6b69837b 100644
--- a/session.h
+++ b/session.h
@@ -26,6 +26,8 @@
26#ifndef SESSION_H 26#ifndef SESSION_H
27#define SESSION_H 27#define SESSION_H
28 28
29struct _CkConnector;
30
29#define TTYSZ 64 31#define TTYSZ 64
30typedef struct Session Session; 32typedef struct Session Session;
31struct Session { 33struct Session {
@@ -61,6 +63,10 @@ struct Session {
61 char *name; 63 char *name;
62 char *val; 64 char *val;
63 } *env; 65 } *env;
66
67#ifdef USE_CONSOLEKIT
68 struct _CkConnector *ckc;
69#endif /* USE_CONSOLEKIT */
64}; 70};
65 71
66void do_authenticated(Authctxt *); 72void do_authenticated(Authctxt *);