Bug 228111

Summary: kdm needs to use ConsoleKit
Product: [Fedora] Fedora Reporter: David Zeuthen <davidz>
Component: kdebaseAssignee: Than Ngo <than>
Status: CLOSED RAWHIDE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: davidz, dennis, desktop-bugs, fedora, ilya.konstantinov, j, kevin, mclasen, pertusus, rdieter
Target Milestone: ---Keywords: Desktop, Patch, Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 6:3.5.6-6.fc7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-04-30 15:16:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 150226, 228110    
Attachments:
Description Flags
KDM patch to support ConsoleKit
none
kdebase specfile patch to include and apply the KDM ConsoleKit patch
none
Diff between GDM ConsoleKit code and my KDM one
none
KDM patch to support ConsoleKit (fixed)
none
First attempt at KDE 4 port of the patch
none
kdebase4 specfile patch to include and apply the KDM ConsoleKit patch
none
KDE 4 port of the patch (actually compiling) none

Description David Zeuthen 2007-02-10 01:22:02 UTC
+++ This bug was initially created as a clone of Bug #228079 +++

Description of problem:

Mounting a partition of an usb key through hal using gnome-mount 
or another program I am developing leads to
Mount error for /org/freedesktop/Hal/devices/volume_uuid_454C_0DAC_0:
DBus Error org.freedesktop.Hal.PermissionDenied: Permission denied: Not in
active session

It seems to me that it is caused by the latest rawhide update.
selinux is disabled.

I use fluxbox as window manager.

Version-Release number of selected component (if applicable):

hal-0.5.9-0.git20070206.1.fc7

How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

-- Additional comment from pertusus on 2007-02-09 16:36 EST --
Created an attachment (id=147816)
lshal -l -u  /org/freedesktop/Hal/devices/volume_uuid_454C_0DAC_0


-- Additional comment from davidz on 2007-02-09 17:32 EST --
Are you logging in via gdm? Also, is the ConsoleKit service running?


-- Additional comment from pertusus on 2007-02-09 17:38 EST --
I am not logging via gdm, but via wdm. 

How could I know whether ConsoleKit is running or not?

-- Additional comment from pertusus on 2007-02-09 17:39 EST --
(In reply to comment #3)

> 
> How could I know whether ConsoleKit is running or not?

I found that 
console-kit-daemon is stopped.

-- Additional comment from pertusus on 2007-02-09 17:43 EST --
Trying to launch it as root, I get:

#  /etc/init.d/ConsoleKit start
Starting console-kit daemon: 
** (console-kit-daemon:9970): WARNING **: Failed to acquire
org.freedesktop.ConsoleKit
FAILED

-- Additional comment from pertusus on 2007-02-09 18:18 EST --
This may be unrelated, but I restarted dbus and now ConsoleKit
segfaults:

# /usr/sbin/console-kit-daemon  --debug  --no-daemon
[ck_debug_init] ck-debug.c:106 (00:14:59):       Debugging enabled
[main] main.c:121 (00:14:59):    initializing console-kit-daemon 0.1.0
[get_active_native] ck-vt-monitor.c:233 (00:14:59):      Current VT: tty7
[get_active_native] ck-vt-monitor.c:238 (00:14:59):      VT 1:on
[get_active_native] ck-vt-monitor.c:238 (00:14:59):      VT 2:on
[get_active_native] ck-vt-monitor.c:238 (00:14:59):      VT 3:on
[get_active_native] ck-vt-monitor.c:238 (00:14:59):      VT 4:on
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 5:on
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 6:on
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 7:on
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 8:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 9:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 10:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 11:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 12:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 13:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 14:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 15:off
[get_active_native] ck-vt-monitor.c:238 (00:15:00):      VT 16:off
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 1
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 2
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 3
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 4
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 5
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 6
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 8
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 9
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 10
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 11
[watch_vts] ck-vt-monitor.c:271 (00:15:00):      Creating thread for vt 12
Erreur de segmentation


And the backtrace:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208337520 (LWP 10467)]
0x00ae0c90 in buffered_vfprintf (s=0xbee580, format=0x805245c "[%s] %s:%d
(%s):\t %s\n", args=0xb7fa2f2c "c\025\005\b�023\005\b�") at vfprintf.c:2122
2122    {
(gdb) bt
#0  0x00ae0c90 in buffered_vfprintf (s=0xbee580, format=0x805245c "[%s] %s:%d
(%s):\t %s\n", args=0xb7fa2f2c "c\025\005\b�023\005\b�") at vfprintf.c:2122
#1  0x00adcc5f in _IO_vfprintf_internal (s=0xbee580, format=0x805245c "[%s]
%s:%d (%s):\t %s\n", ap=0xb7fa2f2c "c\025\005\b�023\005\b�")
    at vfprintf.c:1270
#2  0x00b82c95 in ___fprintf_chk (fp=0xbee580, flag=1, format=0x805245c "[%s]
%s:%d (%s):\t %s\n") at fprintf_chk.c:37
#3  0x0804fa8e in ck_debug_real (func=0x8051563 "vt_thread_start",
file=0x80513cf "ck-vt-monitor.c", line=182, format=0x8051447 "VT_WAITACTIVE for
vt %d")
    at ck-debug.c:68
#4  0x0804c995 in vt_thread_start (data=0x9f0b180) at ck-vt-monitor.c:182
#5  0x0020229f in ?? () from /lib/libglib-2.0.so.0
#6  0x00d632db in start_thread (arg=0xb7fa3b90) at pthread_create.c:296
#7  0x00b6ed0e in clone () from /lib/libc.so.6


-- Additional comment from pertusus on 2007-02-09 18:32 EST --
Seems like the segfault is in the debugging code. I could start
ConsoleKit. The error is still the same, but I guess I have to
relogin or something along such that ConsoleKit knows that I am here,
as it was dead when i loggued in first.

-- Additional comment from pertusus on 2007-02-09 18:48 EST --
When loggued in gdm is works. Do you have an explanation?

-- Additional comment from davidz on 2007-02-09 20:17 EST --
Yes, see bug 228110 for details. Thanks.

Comment 1 jmccann 2007-02-19 17:31:27 UTC
See bug #228079 comment #10 for an explanation of the segfault.

Comment 2 Kevin Kofler 2007-04-17 23:46:06 UTC
Created attachment 152864 [details]
KDM patch to support ConsoleKit

The patch I'm attaching adds ConsoleKit support to KDM. I lifted some code
(most of it, actually, especially most of consolekit.[ch]) from GDM, but that
should be OK thanks to the GPL. :-)

WARNING: This hasn't tested beyond "it compiles" (which it does, at least on my
FC6 system; note that it ConsoleKit-devel is not required to build, only
dbus-devel). I hope some of the brave Rawhide users can help out with the
testing.

I'm also going to attach a specfile patch.

Comment 3 Kevin Kofler 2007-04-17 23:49:59 UTC
Created attachment 152865 [details]
kdebase specfile patch to include and apply the KDM ConsoleKit patch

This is the patch to apply to kdebase.spec.

NOTE: To test-build this on FC6, I also changed:
BuildRequires: libsmbclient-devel
to:
BuildRequires: samba >= 2.2.3a-5
but as this would actually be incorrect for F7, I reverted this before taking
the diff.

Comment 4 Rex Dieter 2007-04-18 13:13:15 UTC
Than, could you apply/test this patch asap?  I'd *really* like to see this in
f7t4 if at all possible.

Comment 5 Than Ngo 2007-04-23 11:59:05 UTC
it's now included in kdebase-3.5.6-6.fc7, which will be built today. Kevin, 
thanks for the patch, great work!

Comment 6 Than Ngo 2007-04-23 14:57:00 UTC
Kevin, have you tested kdm built with this patch?  I have built it on my test 
machine, it just crashed when i tried to login. 

Comment 7 Rex Dieter 2007-04-23 15:00:24 UTC
Prolly not, per comment #2 : WARNING: This hasn't tested beyond "it compiles" 
:(

Comment 8 Kevin Kofler 2007-04-24 07:01:00 UTC
So let's reopen this bug. :-( (I can't do it, I don't have fedorabugs 
permissions.)
I guess what's wrong is that D-Bus needs to be integrated with the main loop 
somehow (using 
the "dbus_connection_set_watch_functions", "dbus_connection_set_timeout_functions" 
and "dbus_connection_set_wakeup_main_function" functions and callbacks), 
there's a comment where those functions could be used. Unfortunately, KDM uses 
a custom main loop, not any of the standard ones (glib, Qt, ...) where 
it's "obvious" what the callbacks should do. :-( Someone needs to look into 
this further, but the bad news is that I certainly won't be able to do that 
before Thursday (i.e. 2 days from now).

Comment 9 Kevin Kofler 2007-04-24 07:04:13 UTC
Comment on attachment 152864 [details]
KDM patch to support ConsoleKit

Marking patch obsolete as it doesn't work, even without having a replacement
yet. :-(

Comment 10 David Zeuthen 2007-04-24 15:25:04 UTC
(In reply to comment #8)
> I guess what's wrong is that D-Bus needs to be integrated with the main loop 
> somehow

You don't need D-Bus mainloop integration if you just use blocking calls. You
may also want to check bug 237621 where there is talk of achieving the same
thing using the PAM module and setting a variable. HTH.


Comment 11 Rex Dieter 2007-04-24 18:31:10 UTC
FYI, pam_ck_connector , bug #228110 comment #15

Comment 12 Kevin Kofler 2007-04-25 23:53:29 UTC
If it's not mainloop integration that's needed, then why is it locking up?

Comment 13 Kevin Kofler 2007-04-26 15:43:32 UTC
Created attachment 153524 [details]
Diff between GDM ConsoleKit code and my KDM one

I don't think there's any logic bugs in my code because I'm using the exact
same algorithm as the known-good GDM. I've attached the diff between GDM's
ConsoleKit code and mine which makes this obvious. The only thing which is in
GDM's code and not in mine is mainloop integration: GDM calls
dbus_connection_setup_with_g_main, which I can't do in KDM because it doesn't
use GLib. That's why if mainloop integration isn't it, then I don't know why
GDM works and my patched KDM doesn't. Unfortunately, I don't have a Rawhide
machine here to do any debugging on this. :-(

Comment 14 Kevin Kofler 2007-04-27 03:43:30 UTC
Removing "blocks F7Test4" as it's obviously too late for that now. ;-( Also a 
nice way to try out my newly-acquired fedorabugs powers. ;-) Hopefully we can 
get this sorted out for the final.

Comment 15 Kevin Kofler 2007-04-27 12:40:36 UTC
I'm currently trying hard to debug this in QEMU. I know the problem is a 
segfault, but I don't know yet where exactly.

Comment 16 Kevin Kofler 2007-04-27 13:48:58 UTC
Than, could you please install that kdebase RPM on your test machine again, 
along with the corresponding -debuginfo RPM and Valgrind, and then run:
valgrind --trace-children=yes kdm -nodaemon
from runlevel 3? This is probably the only way we'll ever figure out where the 
segfault is happening, and Valgrind doesn't appear to work properly under QEMU, 
so I'm stuck.

Comment 17 Kevin Kofler 2007-04-28 13:55:05 UTC
Here's an e-mail from S.Çağlar Onur from Pardus. Than, I'm going to update my 
patch with his fix, so no debugging is needed, just fixing the patch in CVS and 
rebuilding.

===

Hi all;

While searching ConsoleKit support of KDM i found that [1] so i want to give 
it a try and i also reproduced the problem mentioned there, i had some free 
time to debug and here is the solution, it works perfectly for me :). 

I mailed you directly cause i don't have a bugzilla account @ 
bugzilla.redhat.com. I hope this wont create a problem.

--- kdebase-3.5.6-consolekit-kdm.patch.orig     2007-04-28 05:38:01.098664155 
+0300
+++ kdebase-3.5.6-consolekit-kdm.patch  2007-04-28 05:38:12.596910026 +0300
@@ -795,7 +795,7 @@
                SetupDisplay( td_setup );
  
 +#ifdef WITH_CONSOLE_KIT
-+      ck_session_cookie = open_ck_session (getpwnam(d->userName), d);
++      ck_session_cookie = open_ck_session (getpwnam(curuser), d);
 +      if (!(clientPid = StartClient(ck_session_cookie))) {
 +#else
        if (!(clientPid = StartClient())) {


[caglar@zangetsu][~/svk/devel/desktop/kde/base/kdebase/files]> 
ck-list-sessions
Session9:
        uid = '1000'
        realname = 'S.Çağlar Onur'
        seat = 'Seat1'
        session-type = ''
        active = TRUE
        x11-display = ':0'
        x11-display-device = '/dev/tty7'
        display-device = ''
        remote-host-name = ''
        is-local = TRUE
        on-since = '2007-04-28T02:37:13Z'

[1] https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=228111

Cheers
-- 
S.Çağlar Onur <caglar.tr>
http://cekirdek.pardus.org.tr/~caglar/

Linux is like living in a teepee. No Windows, no Gates and an Apache in house!

Comment 18 Kevin Kofler 2007-04-28 14:04:36 UTC
Created attachment 153710 [details]
KDM patch to support ConsoleKit (fixed)

Attaching the patch with S.Çağlar Onur's fix. Thanks!

Comment 19 Kevin Kofler 2007-04-28 14:13:51 UTC
Sebastian Vahl, once the updated kdebase has been built by Than Ngo and tagged 
for Rawhide by releng, it would be nice if you could make sure a KDE live CD 
snapshot with the new kdebase and KDM set as default is torrented for wider 
testing.

Comment 20 Sebastian Vahl 2007-04-28 21:29:33 UTC
(In reply to comment #19)
> Sebastian Vahl, once the updated kdebase has been built by Than Ngo and tagged 
> for Rawhide by releng, it would be nice if you could make sure a KDE live CD 
> snapshot with the new kdebase and KDM set as default is torrented for wider 
> testing.

I will test this tomorrow (or when I'm getting the new kdebase). If it's working
for me I'll ask Jeremy if he's planing to release new rawhide-livecds. If not
I'll ask Rex if he will provide them as a torrent.



Comment 21 Kevin Kofler 2007-04-28 22:00:53 UTC
We should also get redhat-artwork-kde (#236792, built, waiting for signature) 
into the spin, KDM warns about a missing background image without it.

Comment 22 Sebastian Vahl 2007-04-28 22:13:47 UTC
Shouldn't this be required by kdebase? But I can include this manually into the
spin when it' getting into rahide (and this bug is getting OT :)

Comment 23 Kevin Kofler 2007-04-28 22:16:52 UTC
Not possible before either kdebase moves to Extras or the merge happens (but in 
the latter case, redhat-artwork-kde should probably be merged back into 
redhat-artwork anyway).

Comment 24 Sebastian Vahl 2007-04-28 22:19:40 UTC
Ok. right. I'll will include redhat-artwork-kde manually then.

Comment 25 Jason Tibbitts 2007-04-29 02:43:16 UTC
Actually, there are currently packages in core which depend on packages in
extras (namely cdrkit, which many things depend on now that cdrwtools are gone
from Core).  So it's not an absolute prohibition, but I don't know what hacks
are required to make it work.  If you have a legitimate need to do that before
the merge, talk to releng.

Comment 26 Kevin Kofler 2007-04-29 03:42:59 UTC
If any other things BuildRequire such a package, it will choke the build system 
though, I don't know off hand if really nothing in Core BuildRequires kdebase.

Comment 27 Than Ngo 2007-04-30 15:16:51 UTC
it's non built in rawhide

Comment 28 Than Ngo 2007-04-30 15:17:02 UTC
it's now built in rawhide

Comment 29 Kevin Kofler 2007-05-01 01:43:30 UTC
And redhat-artwork-kde has now been pushed to extras-development, so it looks 
like everything should be in place for a new KDE Live CD snapshot with the next 
Rawhide push.

Comment 30 Kevin Kofler 2007-05-01 11:22:00 UTC
No, it's not in Rawhide:
http://www.redhat.com/archives/fedora-devel-list/2007-May/msg00019.html
Due to the freeze, it's not enough to build for dist-fc7 now, this needs to be 
explicitly pushed to f7final by Release Engineering.

Comment 31 Kevin Kofler 2007-05-01 11:24:23 UTC
It's "f7-final" actually, but the name doesn't matter because releng has to do 
it anyway. See:
https://www.redhat.com/archives/fedora-maintainers/2007-April/msg00582.html

Comment 32 Kevin Kofler 2007-05-01 12:50:51 UTC
*** Bug 228151 has been marked as a duplicate of this bug. ***

Comment 33 Kevin Kofler 2007-05-02 11:58:13 UTC
Now pushed to Rawhide by release engineering, thanks!
http://www.redhat.com/archives/fedora-devel-list/2007-May/msg00097.html

Comment 34 Kevin Kofler 2007-07-04 07:24:06 UTC
Created attachment 158502 [details]
First attempt at KDE 4 port of the patch

Here's a first attempt at porting this patch to KDE 3.91.0 (4.0 alpha 2).

WARNING: This comes "straight from the presses", I haven't tried compiling it
yet, let alone running the result. In particular, the CMake stuff may need more
work. (KDE only had checks for QtDBus and I needed the low-level D-Bus, so I
lifted the check from libzypp, edited it a bit to handle LIB_SUFFIX in a better
way, and added the FindPackage to workspace/kdm/backend/CMakeLists.txt and
${DBUS_LIBRARY} to the target_link_libraries in the same file.)

Moreover, I think this will need to be fully conditionalized before we can send
it upstream, right now #define WITH_CONSOLE_KIT is still hardcoded in dm.h.

Comment 35 Kevin Kofler 2007-07-11 08:10:46 UTC
Created attachment 158925 [details]
kdebase4 specfile patch to include and apply the KDM ConsoleKit patch

Here's the specfile patch against the current kdebase4.spec in kde-redhat
unstable. I'm currently testing compilation.

Comment 36 Kevin Kofler 2007-07-11 09:28:49 UTC
This fails to build.
.../workspace/kdm/backend/consolekit.c:31:23: error: dbus/dbus.h: No such file 
or directory
I need to tweak my CMake stuff. :-(

Comment 37 Rex Dieter 2007-07-11 11:40:58 UTC
Kevin, please open a separate bug for kde4 support (and/or file the rfe upstream
at bugs.kde.org).

Comment 38 Kevin Kofler 2007-07-11 11:50:41 UTC
Created attachment 158937 [details]
KDE 4 port of the patch (actually compiling)

This version of the patch actually compiles. (I added the missing
include_directories line.)

separate bug: Well, I was unsure against what to file it against as KDE 4 isn't
in Fedora yet, and I was more concerned about actually getting work done. ;-)

upstream: I'm going to move this upstream now that it compiles, but I think it
needs more work to be acceptable upstream: as I said further up this thread,
the ConsoleKit support isn't fully conditionalized (there's #ifdef
WITH_CONSOLE_KIT everywhere in the code, but the #define is currently hardcoded
rather than being set with CMake magic; this was the same in the KDE 3 version
of the patch) and I don't think upstream will want to make ConsoleKit a hard
requirement for KDE 4.