View | Details | Raw Unified | Return to bug 528829
Collapse All | Expand All

(-)file_not_specified_in_diff (-7 / +140 lines)
Line  Link Here
--
1
configure.ac |   14 ++++++++
configure.ac |   14 ++++++++
2
dm.h         |    3 +
1
dm.h         |    3 +
3
resource.c   |   13 +++++++
2
resource.c   |   13 +++++++
4
session.c    |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3
session.c    |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
xdm.man.cpp  |    6 +++
4
xdm.man.cpp  |    6 +++
6
5 files changed, 135 insertions(+), 1 deletion(-)
5
5 files changed, 135 insertions(+), 1 deletion(-)
7
-- a/configure.ac
6
++ b/configure.ac
Lines 362-367 Link Here
362
362
363
AM_CONDITIONAL(DYNAMIC_GREETER, test x$DYNAMIC_GREETER = xyes)
363
AM_CONDITIONAL(DYNAMIC_GREETER, test x$DYNAMIC_GREETER = xyes)
364
364
365
# ConsoleKit support
366
AC_ARG_WITH(consolekit, AC_HELP_STRING([--with-consolekit], [Use ConsoleKit]),
367
	[USE_CONSOLEKIT=$withval], [USE_CONSOLEKIT=yes])
368
if test x"$USE_CONSOLEKIT" != xno; then
369
	PKG_CHECK_MODULES(CK_CONNECTOR, ck-connector,
370
		[USE_CONSOLEKIT=yes], [USE_CONSOLEKIT=no])
371
	if test x"$USE_CONSOLEKIT" = xyes; then
372
		AC_DEFINE([USE_CONSOLEKIT], 1, [Define to 1 to use ConsoleKit])
373
		XDM_CFLAGS="$XDM_CFLAGS $CK_CONNECTOR_CFLAGS"
374
		XDM_LIBS="$XDM_LIBS $CK_CONNECTOR_LIBS"
375
	fi
376
fi
377
dnl AM_CONDITIONAL(USE_CONSOLEKIT, test$USE_CONSOLEKIT = xyes)
378
365
#
379
#
366
#  XDM
380
#  XDM
367
#
381
#
368
-- a/session.c
382
++ b/session.c
Lines 66-71 Link Here
66
#endif
66
#endif
67
#endif /* USE_PAM */
67
#endif /* USE_PAM */
68
68
69
#ifdef USE_CONSOLEKIT
70
#include <ck-connector.h>
71
#include <dbus/dbus.h>
72
#endif
73
69
#ifdef __SCO__
74
#ifdef __SCO__
70
#include <prot.h>
75
#include <prot.h>
71
#endif
76
#endif
Lines 472-477 Link Here
472
    }
477
    }
473
}
478
}
474
479
480
#ifdef USE_CONSOLEKIT
481
482
static CkConnector *connector;
483
484
static int openCKSession(struct verify_info *verify, struct display *d)
485
{
486
    int ret;
487
    DBusError error;
488
    char  *remote_host_name = "";
489
    dbus_bool_t is_local;
490
    char *display_name = "";
491
    char *display_device = "";
492
    char devtmp[16];
493
494
    if (!use_consolekit)
495
	return 1;
496
497
    is_local = d->displayType.location == Local;
498
    if (d->peerlen > 0 && d->peer)
499
	remote_host_name = d->peer;
500
    if (d->name)
501
	display_name = d->name;
502
    /* how can we get the corresponding tty at best...? */
503
    if (d->windowPath) {
504
	display_device = strchr(d->windowPath, ':');
505
	if (display_device && display_device[1])
506
	    display_device++;
507
	else
508
	    display_device = d->windowPath;
509
	snprintf(devtmp, sizeof(devtmp), "/dev/tty%s", display_device);
510
	display_device = devtmp;
511
    }
512
513
    connector = ck_connector_new();
514
    if (!connector) {
515
	LogOutOfMem("ck_connector");
516
	return 0;
517
    }
518
519
    dbus_error_init(&error);
520
    ret = ck_connector_open_session_with_parameters(
521
		connector, &error,
522
		"unix-user", &verify->uid,
523
		"x11-display", &display_name,
524
		"x11-display-device", &display_device,
525
		"remote-host-name", &remote_host_name,
526
		"is-local", &is_local,
527
		NULL);
528
    if (!ret) {
529
	if (dbus_error_is_set(&error)) {
530
	    LogError("Dbus error: %s\n", error.message);
531
	    dbus_error_free(&error);
532
	} else {
533
	    LogError("ConsoleKit error\n");
534
	}
535
	ck_connector_unref(connector);
536
	connector = NULL;
537
	return 0;
538
    }
539
540
    verify->userEnviron = setEnv(verify->userEnviron,
541
		"XDG_SESSION_COOKIE", ck_connector_get_cookie(connector));
542
    return 1;
543
}
544
545
static void closeCKSession(void)
546
{
547
    DBusError error;
548
549
    if (!connector)
550
	return;
551
552
    dbus_error_init(&error);
553
    if (!ck_connector_close_session(connector, &error)) {
554
	if (dbus_error_is_set(&error)) {
555
	    LogError("Dbus error: %s\n", error.message);
556
	    dbus_error_free(&error);
557
	} else {
558
	    LogError("ConsoleKit close error\n");
559
	}
560
    }
561
    ck_connector_unref(connector);
562
    connector = NULL;
563
}
564
#else
565
#define openCKSession(v,d)	1
566
#define closeCKSession()
567
#endif
568
475
void
569
void
476
SessionExit (struct display *d, int status, int removeAuth)
570
SessionExit (struct display *d, int status, int removeAuth)
477
{
571
{
Lines 486-491 Link Here
486
    }
580
    }
487
#endif
581
#endif
488
582
583
    closeCKSession();
584
489
    /* make sure the server gets reset after the session is over */
585
    /* make sure the server gets reset after the session is over */
490
    if (d->serverPid >= 2 && d->resetSignal)
586
    if (d->serverPid >= 2 && d->resetSignal)
491
	kill (d->serverPid, d->resetSignal);
587
	kill (d->serverPid, d->resetSignal);
Lines 568-573 Link Here
568
#ifdef USE_PAM
664
#ifdef USE_PAM
569
    if (pamh) pam_open_session(pamh, 0);
665
    if (pamh) pam_open_session(pamh, 0);
570
#endif
666
#endif
667
668
    if (!openCKSession(verify, d))
669
	return 0;
670
571
    switch (pid = fork ()) {
671
    switch (pid = fork ()) {
572
    case 0:
672
    case 0:
573
	CleanUpChild ();
673
	CleanUpChild ();
574
-- a/dm.h
674
++ b/dm.h
Lines 325-330 Link Here
325
extern char	*prngdSocket;
325
extern char	*prngdSocket;
326
extern int	prngdPort;
326
extern int	prngdPort;
327
#endif
327
#endif
328
#ifdef USE_CONSOLEKIT
329
extern int	use_consolekit;
330
#endif
328
331
329
extern char	*greeterLib;
332
extern char	*greeterLib;
330
extern char	*willing;
333
extern char	*willing;
331
-- a/resource.c
334
++ b/resource.c
Lines 68-73 Link Here
68
char	*prngdSocket;
68
char	*prngdSocket;
69
int	prngdPort;
69
int	prngdPort;
70
#endif
70
#endif
71
#ifdef USE_CONSOLEKIT
72
int	use_consolekit;
73
#endif
71
74
72
char	*greeterLib;
75
char	*greeterLib;
73
char	*willing;
76
char	*willing;
Lines 258-263 Link Here
258
				"false"} ,
261
				"false"} ,
259
{ "willing",	"Willing",	DM_STRING,	&willing,
262
{ "willing",	"Willing",	DM_STRING,	&willing,
260
				""} ,
263
				""} ,
264
#ifdef USE_CONSOLEKIT
265
{ "consoleKit",	"ConsoleKit",	DM_BOOL,	(char **) &use_consolekit,
266
				"true"} ,
267
#endif
261
};
268
};
262
269
263
# define NUM_DM_RESOURCES	(sizeof DmResources / sizeof DmResources[0])
270
# define NUM_DM_RESOURCES	(sizeof DmResources / sizeof DmResources[0])
Lines 440-446 Link Here
440
{"-debug",	"*debugLevel",		XrmoptionSepArg,	(caddr_t) NULL },
447
{"-debug",	"*debugLevel",		XrmoptionSepArg,	(caddr_t) NULL },
441
{"-xrm",	NULL,			XrmoptionResArg,	(caddr_t) NULL },
448
{"-xrm",	NULL,			XrmoptionResArg,	(caddr_t) NULL },
442
{"-daemon",	".daemonMode",		XrmoptionNoArg,		"true"         },
449
{"-daemon",	".daemonMode",		XrmoptionNoArg,		"true"         },
443
{"-nodaemon",	".daemonMode",		XrmoptionNoArg,		"false"        }
450
{"-nodaemon",	".daemonMode",		XrmoptionNoArg,		"false"        },
451
#ifdef USE_CONSOLEKIT
452
{"-consolekit",	".consoleKit",		XrmoptionNoArg,		"true"  },
453
{"-noconsolekit", ".consoleKit",	XrmoptionNoArg,		"false" }
454
#endif
444
};
455
};
445
456
446
static int	originalArgc;
457
static int	originalArgc;
447
-- a/xdm.man.cpp
458
++ b/xdm.man.cpp
Lines 51-56 Link Here
51
] [
51
] [
52
.B \-session
52
.B \-session
53
.I session_program
53
.I session_program
54
] [
55
.B \-noconsolekit
54
]
56
]
55
.SH DESCRIPTION
57
.SH DESCRIPTION
56
.I Xdm
58
.I Xdm
Lines 218-223 Link Here
218
.IP "\fB\-xrm\fP \fIresource_specification\fP"
220
.IP "\fB\-xrm\fP \fIresource_specification\fP"
219
Allows an arbitrary resource to be specified, as in most
221
Allows an arbitrary resource to be specified, as in most
220
X Toolkit applications.
222
X Toolkit applications.
223
.IP "\fB\-noconsolekit\fP"
224
Specifies ``false'' as the value for the \fBDisplayManager.consoleKit\fP
225
resource.
226
This suppresses the session management using ConsoleKit.
221
.SH RESOURCES
227
.SH RESOURCES
222
At many stages the actions of
228
At many stages the actions of
223
.I xdm
229
.I xdm

Return to bug 528829