Bug 154232

Summary: When using KDE su the password window hangs after wrong password
Product: [Applications] kdesu Reporter: Klaus Dimde <klaus>
Component: generalAssignee: kdesu bugs tracker <kdesu-bugs-null>
Status: RESOLVED FIXED    
Severity: crash CC: thomas.friedrichsmeier
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: patch for testing
better approach

Description Klaus Dimde 2007-12-17 16:14:24 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 4.2.2 
OS:                Linux

When calling kuser (or any program that uses KDE su) from the start menu the password dialog pops up. If I enter a wrong password (or no at all) the password dialogs hangs and nothing happens. Btw when I enter the right password nothing happens either but at least the dialog disappears.
Comment 1 Thomas Friedrichsmeier 2007-12-17 16:38:07 UTC
I'm re-assigning this to kdesu.

Could you give more details on the exact version of KDE (SVN revision, if available) you are using? There have been some changes in kdesu for related problems, so it would be good to know, whether your problem continues despite of these changes, or whether it is likely to have been fixed meanwhile.

Further, could you provide the output of
# which kdesu
(needed as conceivably the KDE 3 version got picked up, and some distributions override kdesu (esp. Ubuntu)).

Also, could you try something like:
# kdesu -c echo "test"
and post the debug output for a failed attempt?

Thanks.
Comment 2 Klaus Dimde 2007-12-18 19:11:59 UTC
I've updated and compiled today (svn info yields 750046), I had some strange misconfigurations so I cleanly rebuild kde (as root in /opt/kde4, no old kde3 installation). kdesu was installed in /opt/kde4/lib/kde4/libexec and this wasn't in my path so I've added it to $PATH (still same error). My distribution is clfs so there should be no override. 

#kdesu dir or #kdesu -c echo "test" gives:
kdesu -c echo "test"
kdesu(19692)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 293 ]  Running ` "/bin/su" '
kdesu(19692)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "Password: " >
kdesu(19692)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 293 ]  Running ` "/bin/su" '
kdesu(19692)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "Password: " >
kdesu(19692)/kdesu (kdelibs) KDESu::PtyProcess::WaitSlave: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 373 ]  Child pid  19709
kdesu(19692)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "" >
Getötet 

Last line means killed after I closed hanging the window.

Calling kdesu dir with the right password gives:
kdesu(21035)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 293 ]  Running ` "/bin/su" '
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "Password: " >
kdesu(21035)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 293 ]  Running ` "/bin/su" '
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "Password: " >
kdesu(21035)/kdesu (kdelibs) KDESu::PtyProcess::WaitSlave: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 373 ]  Child pid  21057
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "" >
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "kdesu_stub" >
kdesu(21035)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 293 ]  Running ` "/bin/su" '
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "Password: " >
kdesu(21035)/kdesu (kdelibs) KDESu::PtyProcess::WaitSlave: [ /sources/kde4/src/kdelibs/kdesu/process.cpp : 373 ]  Child pid  21059
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "" >
kdesu(21035)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /sources/kde4/src/kdelibs/kdesu/su.cpp : 254 ]  Read line < "kdesu_stub" >

and nothing more.

I hope this helps more
Comment 3 Thomas Friedrichsmeier 2007-12-20 12:18:23 UTC
Thanks for the added info. One more thing, just to make sure:

It is expected that there is *some* hang during a failed attempt. This is simply due to the timeout in "su" when you enter a wrong password. I believe by default this should be around three seconds, and in fact the dialog will not update at all during that timeout (which is pretty ugly, but at least no regression with respect to kdesu in KDE 3).

I don't know, how long you waited before killing, but could you try waiting a bit longer, just to see whether this might be caused by the timeout?

For comparison, could you run
# su
-- wrong password
*twice* and check how long the second attempt times out?
Comment 4 Klaus Dimde 2007-12-20 19:53:41 UTC
I've waited way more than three seconds (it's running about 15 minutes now without any response). What's a little bit strange, that su on terminal with a wrong password has no timeout or error message at all (shadow 4.0.18.2). 
Perhaps this helps too:
with a wrong password /var/log/auth.log says:
Dec 20 19:52:29 KLAUS su[13455]: Authentication failed for root
Dec 20 19:52:29 KLAUS su[13455]: FAILED su for root by kladim
Dec 20 19:52:29 KLAUS su[13455]: - pts/3 kladim:root

with a right password it says:
Dec 20 19:55:02 KLAUS su[13485]: Successful su for root by kladim
Dec 20 19:55:02 KLAUS su[13485]: + pts/3 kladim:root
Dec 20 19:55:03 KLAUS su[13487]: Successful su for root by kladim
Dec 20 19:55:03 KLAUS su[13487]: + pts/3 kladim:root

Comment 5 Thomas Friedrichsmeier 2007-12-20 23:09:16 UTC
Created attachment 22642 [details]
patch for testing

> What's a little bit strange, that su on terminal with a wrong password has no
timeout or error message at all (shadow 4.0.18.2).

That's interesting, in fact. And I guess it's the cause of this bug. kdesu
waits for *some* output (indirectly with Process::readLine()), and if that is
not "kdesu_stub", it knows authorization went wrong.

The attached patch should make sure that it will also notice when su exits
silently.

Since I cannot reproduce, here (my su gives an error message), could you please
test this (apply in kdelibs/kdesu/), and report whether it works?
Comment 6 Klaus Dimde 2007-12-21 09:51:38 UTC
Patch works for me. Now I'm told that the password is wrong and no frozen window.

But still nothing happens when I enter the right password (except that the dialog disappears). I didn't mark the bug as resolved for this reason yet.
Comment 7 Thomas Friedrichsmeier 2007-12-21 15:45:52 UTC
Thanks it's good to know the patch fixes the (first) problem. However, I think it may not be quite right, yet (it might be possible to read remaining data, even after the process has exited), and I'm not familiar enough with those calls. So somebody else, please review this.

Regarding the second part (nothing happens with the correct password), could you check whether this is the same issue as bug #154188? (Note: Calling
# kdesu -c echo "test"
will not print "test" either way, but
# kdesu -t -c echo "test"
should.)
Comment 8 Klaus Dimde 2007-12-21 16:09:12 UTC
Ok checked it, it seems to be at least very similar to bug #154188 (although I get a slightly different error message). I will post my findings there and assume this bug resolved. 
Comment 9 Thomas Friedrichsmeier 2007-12-21 16:16:39 UTC
Ok, thanks.

For anybody reading this: Keep in mind, the patch is not committed to SVN, yet, so don't close this bug too early.
Comment 10 Oswald Buddenhagen 2008-02-23 20:19:27 UTC
Created attachment 23684 [details]
better approach

this patch is actually correct - at least in theory. please test.
Comment 11 Oswald Buddenhagen 2010-11-06 20:25:08 UTC
patch committed in jun 2008