Bug 50406 - kdesu locks very often on FreeBSD
Summary: kdesu locks very often on FreeBSD
Status: RESOLVED FIXED
Alias: None
Product: kdesu
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: FreeBSD Ports FreeBSD
: NOR normal
Target Milestone: ---
Assignee: groot
URL:
Keywords:
: 55540 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-11-08 13:21 UTC by Andriy I Pylypenko
Modified: 2004-10-19 16:20 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for kdelibs/kdesu/su.cpp (963 bytes, patch)
2002-12-06 10:20 UTC, Andriy I Pylypenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andriy I Pylypenko 2002-11-08 13:21:44 UTC
Version:            (using KDE KDE 3.0.4)
Installed from:    FreeBSD Ports
Compiler:          gcc version 2.95.4 20020320 [FreeBSD] 
OS:          FreeBSD

kdesu works great, but very often locks forever before password prompt dialog appears.
This problem is araised from race condition when kdesu attempts to kill su with SIGTERM but su or, rather, skey_getpass(3) apparently blocks this signal.
I have no idea how to resolve this problem correctly. But changing SIGTERM to SIGKILL does the work for me :-)
Comment 1 metrol 2002-12-06 05:29:51 UTC
I'm personally jealous of the reporter on this bug.  I have never seen kdesu
even approach functioning under FreeBSD.  I thought this was pretty well covered
here on bugs.kde, but this is the only mention of this I've found.

I guess we won't be seeing a fix before 3.1 on this.  Until then, suppose we
could at least call this bug confirmed?
Comment 2 Andriy I Pylypenko 2002-12-06 10:20:51 UTC
Created attachment 579 [details]
Patch for kdelibs/kdesu/su.cpp
Comment 3 Andriy I Pylypenko 2002-12-06 10:22:22 UTC
Subject: Re:  kdesu locks very often on FreeBSD         

On 6 Dec 2002 metrol@metrol.net wrote:

> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter.
>
> http://bugs.kde.org/show_bug.cgi?id=50406
> metrol@metrol.net changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |metrol@metrol.net
>
>
>
> ------- Additional Comments From metrol@metrol.net  2002-12-06 05:29 -------
> I'm personally jealous of the reporter on this bug.  I have never seen kdesu
> even approach functioning under FreeBSD.  I thought this was pretty well covered
> here on bugs.kde, but this is the only mention of this I've found.
>
> I guess we won't be seeing a fix before 3.1 on this.  Until then, suppose we
> could at least call this bug confirmed?

Ok, here follows full story.

I've been using KDE under FreeBSD since version 1 and know that at least
from version 2 kdesu is not working very well - I've saw it run couple of
times but the most often it simply locked forever.

This situation annoyed me very badly recently and I've decided to explore
this bug. I've inserted some checkpoints and found out that kdesu program
does not have any bugs related to this problem but instead bug is in
libkdesu. After some additional work on debugging kdelibs and su itself
I've found that there is case when SuProcess does send SIGTERM but su does
not react to this signal at all. Killing su manually with the same signal
works well. I've concluded that the most probably there is the short time
interval when su is blocking signals and SuProcess sends SIGNAL at that
interval. So I've decided not to explore this race contition and simply
change SIGTERM to SIGKILL.

I know that this is not the most elegant solution but it works pretty well
on two FreeBSD 4.7-STABLE systems.

Please see the patch submitted.

  Kind regards,
  Andriy I Pylypenko
  PAI1-RIPE

Comment 4 metrol 2002-12-06 11:41:10 UTC
I applied the patch to the kdelibs port with a slight modification to the path.
 I then rebuilt kdelibs3, and also verified that the patch applied properly. 
It's different, but certainly not fixed here.

Before if I were to enter "kdesu konqueror" it would lock up after I put in a
pw.  It would not provide back a dialog until I manually killed kdesud.

Now, it still locks up when I give it a pw, but upon cancelling the command I
can retry without having to first kill kdesud.

Other than that, it's still inop over here.  It was definitely worth a shot though.
Comment 5 Andriy I Pylypenko 2002-12-06 12:47:09 UTC
Subject: Re:  kdesu locks very often on FreeBSD         

On 6 Dec 2002 metrol@metrol.net wrote:

> I applied the patch to the kdelibs port with a slight modification to
> the path.
>  I then rebuilt kdelibs3, and also verified that the patch applied
> properly.  It's different, but certainly not fixed here.
>
> Before if I were to enter "kdesu konqueror" it would lock up after I put
> in a pw.  It would not provide back a dialog until I manually killed
> kdesud.
>
> Now, it still locks up when I give it a pw, but upon cancelling the
> command I can retry without having to first kill kdesud.
>
> Other than that, it's still inop over here.  It was definitely worth a
> shot though.

It looks like you have another bug. 'kdesu konqueror' command is working
fine on my systems as well as others. In my case kdesu locked up before
any dialog appears.

I've just tried to reproduce your bug. I've completely deleted ~/.kde* and
let KDE create new config, tried to use KOI8-R locale and ISO8859-1. I
tried to run X server via startx and kdm. But I was not able to reproduce
the bug - kdesu is always working just fine for me :-\

Please tell me version of your FreeBSD system. Did you installed KDE via
ports? What version of XFree86 are you using? What locale are you using?
Are you running kde as root or regular user? Could you supply me with your
/var/run/dmesg.boot?

I'll try to catch the bug.

  Kind regards,
  Andriy I Pylypenko
  PAI1-RIPE


Comment 6 Alan Eldridge 2002-12-07 00:01:36 UTC
Subject: Re:  kdesu locks very often on FreeBSD

On Fri, Dec 06, 2002 at 11:47:10AM -0000, Andriy I Pylypenko wrote:

>It looks like you have another bug. 'kdesu konqueror' command is working
>fine on my systems as well as others. In my case kdesu locked up before
>any dialog appears.
>
>I've just tried to reproduce your bug. I've completely deleted ~/.kde* and
>let KDE create new config, tried to use KOI8-R locale and ISO8859-1. I
>tried to run X server via startx and kdm. But I was not able to reproduce
>the bug - kdesu is always working just fine for me :-\
>
>Please tell me version of your FreeBSD system. Did you installed KDE via
>ports? What version of XFree86 are you using? What locale are you using?
>Are you running kde as root or regular user? Could you supply me with your
>/var/run/dmesg.boot?
>
>I'll try to catch the bug.

I appreciate the help. I have been busy with Bad Real Life Events(tm)
and haven't been able to do much with kdesu since I took it over. I am
working on a new design, but that won't help what is broken now.

I expect to give this more attention around Christmas time, as I think
I'll be relatively free then for a week or so.
Comment 7 metrol 2002-12-07 04:06:03 UTC
I don't believe there's another bug on my system, as everything else works as
advertised here.  I did attempt backing up my .kde directory and having a fresh
one created for testing.  Seemed reasonable to try.  No change to kdesu's behavior.

FreeBSD Version:
4.7-STABLE #0: Mon Nov 11 21:32:40 PST 2002

All of my KDE ports are up to date with the ports tree, plus your attached patch
to kdelibs3.  No international patches have been applied.  English is all I
talk, and just barely at that :)  If you could explain how a copy of dmesg would
help to troubleshoot this problem I'll supply that in a private mail.  I can
tell you here that I'm running on an IBM Thinkpad T23.  I have no known hardware
or resource conflicts, nor any clever hardware that might interfere with KDE's
proper operation.

Are you sure that su.cpp is the only file you modified during your
troubleshooting of this problem?  The patch does seem to address at least part
of the problem with kdesud.  It feels like there must be some other tid bit that
also needs a little tweaking.

What a wonderful Christmas present for all the KDE users in FreeBSD land this
would be!
Comment 8 Lauri Watts 2003-03-06 15:56:18 UTC
*** Bug 55540 has been marked as a duplicate of this bug. ***
Comment 9 groot 2003-04-28 13:59:59 UTC
There's several different situations possible. If the daemon is not running and cannot run 
(because it's not setgid) then kdesu tries to run su: itself. Unfortunately the assumptions of the 
readLine() function are not met in FreeBSD, and neither does kdesu know about "su: you are not 
in the correct group (wheel) to su root", so often readLine() returns the "su:" part of that error 
message and kdesu interprets it as a password: prompt. After that, things go south in a variety of 
interesting ways. I'm working on it. 
 
Comment 10 groot 2003-10-16 12:43:34 UTC
Subject: [PATCH] kdesu hangs on freebsd

Thanks to gentle nudging and BIC fixes from Waldo, and applying the patch 
already shown in #50406, kdesu now really seems to work on FBSD. Without 
using the kdesu demon, I can:

	kdesu konqueror
	use administrator mode in kcontrol

I do have to go back and check if users _not_ in wheel still get sensible 
error messages, though. Committing anyway.