Bug 264947 - partitionmanager / kdesu : cannot run with root privileges
Summary: partitionmanager / kdesu : cannot run with root privileges
Status: RESOLVED DUPLICATE of bug 265026
Alias: None
Product: partitionmanager
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Volker Lanz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-31 13:19 UTC by Mark
Modified: 2011-02-01 00:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark 2011-01-31 13:19:57 UTC
Version:           unspecified (using KDE 4.6.0) 
OS:                Linux

starting up partitionmanager as a normal user, kdesu's dialog pops out as expected, asking for root's password, I fill in the password (I'm sure, no mistakes :) but the program fails to execute with root's privileges and falls back to 'limited mode' (=cannot apply changes). 

Here's program output: 

marek@beruska music]$ partitionmanager
partitionmanager      partitionmanager-bin  
[marek@beruska music]$ partitionmanager
which: no hal-lock in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/opt/oracle-sqldeveloper/bin:/usr/bin/core_perl:/opt/xxe/bin)
kdesu(24160) startApp: Daemon not safe (not sgid), not using it.
 
kdesu(24160)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /build/src/kdelibs-4.6.0/kdesu/process.cpp : 293 ]  Running "/bin/su"
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line "Password: "
kdesu(24160)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /build/src/kdelibs-4.6.0/kdesu/process.cpp : 293 ]  Running "/bin/su"
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line "Password: "
kdesu(24160)/kdesu (kdelibs) KDESu::PtyProcess::WaitSlave: [ /build/src/kdelibs-4.6.0/kdesu/process.cpp : 379 ]  Child pid 24167
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line ""
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line "kdesu_stub"
kdesu(24160)/kdesu (kdelibs) KDESu::PtyProcess::exec: [ /build/src/kdelibs-4.6.0/kdesu/process.cpp : 293 ]  Running "/bin/su"
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line "Password: "
kdesu(24160)/kdesu (kdelibs) KDESu::PtyProcess::WaitSlave: [ /build/src/kdelibs-4.6.0/kdesu/process.cpp : 379 ]  Child pid 24172
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line ""
kdesu(24160)/kdesu (kdelibs) KDESu::SuProcess::ConverseSU: [ /build/src/kdelibs-4.6.0/kdesu/su.cpp : 259 ]  Read line "kdesu_stub"
[marek@beruska music]$ sudo partitionmanager
Password: 
which: no hal-lock in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/opt/oracle-sqldeveloper/bin:/usr/bin/core_perl:/opt/xxe/bin)
No protocol specified
partitionmanager-bin: cannot connect to X server :0


Thanks, Marek

Reproducible: Always

Steps to Reproduce:
$ partitionmanager



$ ls -l /usr/bin/partitionmanager
-rwxr-xr-x 1 root root 1094 Sep  1 15:50 /usr/bin/partitionmanager
Comment 1 Mark 2011-01-31 13:40:44 UTC
called with kdesu directly it works ok. 
So 
$ partitionmanager opens a password dialog and fails
$ kdesu partitionmanager opens the same dialog and succeeds.
Comment 2 Volker Lanz 2011-01-31 16:18:57 UTC
Thank you for your interest in KDE Partition Manager and taking the time to submit this tracker entry.

It appears some recent commits to kdesu's source code brought about a change in behaviour for kdesu that KDE Partition Manager is not prepared for.

Background:

When you run KDE Partition Manager as non-root user it internally re-runs itself with any of kdesu, kdesudo, gksudo or gksu (in this order) asking for privileges. On ArchLinux, the first one to be found is kdesu, so it is being used.

To avoid endless redirects when elevating privileges fails KDE Partition Manager passes a "--dontsu" argument to the new instance of itself to remember not to ask again in that case.

Now kdesu seems to have changed how it handles arguments from the command line with 4.6.0 and thus KDE Partition Manager fails to get root privileges for you.

What KDE Partition Manager actually calls is this command:

$ kdesu "/usr/bin/partitionmanager-bin --dontsu"

If you run this from a shell you will find it does not work.

So much for the analysis and the background; about what needs fixing I'm not yet sure.
Comment 3 Volker Lanz 2011-01-31 16:19:49 UTC
Ossi, can I have your input on this? It seems you're maintaining kdesu from recent commits.
Comment 4 Oswald Buddenhagen 2011-01-31 17:48:13 UTC
please post the *exact* arguments you are passing to kdesu and i may be able to tell you what to fix.
Comment 5 Volker Lanz 2011-01-31 18:05:47 UTC
Thanks for trying to help, Ossi.

I don't quite see what additional information you're asking for. Let me repeat: This fails from a shell:

$ kdesu "/usr/bin/partitionmanager --dontsu"

To get KDE Partition Manager out of the picture, this also does not work:

$ kdesu "ls -l"

Just in case, this is the relevant code from KDE Partition Manager (line 86ff):

http://websvn.kde.org/branches/partitionmanager/1.0/partitionmanager/src/util/helpers.cpp?revision=1113777&view=markup
Comment 6 Oswald Buddenhagen 2011-01-31 18:10:47 UTC
use either
   kdesu -c "ls -l"
or
   kdesu ls -l
Comment 7 Volker Lanz 2011-01-31 18:33:00 UTC
The former suggestion would lead to a special case just for kdesu in the code. That would be unfortunate, but I'll consider it if we don't reach any other solution here.

The latter obviously does not work:

$ kdesu ls -l
kdesu: Unknown option 'l'.                                                                                                                                                          
kdesu: Use --help to get a list of available command line options.                                                                                                                  
As far as I can remember it, the kdesu "ls -l" approach worked when I implemented the code in question in KDE Partition Manager early in 2010. It still works with the other three privilege-elevation-methods, afaict.

My suspicion is that maybe one of the patches to kdesu to change its escaping behaviour unintentionally broke this. Is this possible?
Comment 8 Mark 2011-01-31 22:35:30 UTC
Guys, thank you both for such a quick support, this is really amazing! :) Good job and many thanks.
Comment 9 Oswald Buddenhagen 2011-01-31 23:41:13 UTC
well, the -c syntax is quite like plain su.

the argv-style syntax does indeed not quite work according to plan ... :}
please spin off a bug report for that if you want to.
Comment 10 Volker Lanz 2011-02-01 00:31:15 UTC

*** This bug has been marked as a duplicate of bug 265026 ***