By default, Bugzilla does not search the list of RESOLVED bugs.
You can force it to do so by putting the upper-case word ALL in front of your search query, e.g.: ALL tdelibs
We recommend searching for bugs this way, as you may discover that your bug has already been resolved and fixed in a later release.
Bug 766 - kdesu: Functions incorrectly when installed in a non standard path
Summary: kdesu: Functions incorrectly when installed in a non standard path
Status: RESOLVED FIXED
Alias: None
Product: TDE
Classification: Unclassified
Component: tdelibs (show other bugs)
Version: R14.0.0 [Trinity]
Hardware: Other All
: P1 major
Assignee: Timothy Pearson
URL:
Depends on:
Blocks:
 
Reported: 2011-12-25 16:14 CST by Darrell
Modified: 2012-10-19 15:44 CDT (History)
2 users (show)

See Also:
Compiler Version:
TDE Version String:
Application Version:
Application Name: kdesu


Attachments
Fix hard-coded paths used by kdesu for root (732 bytes, patch)
2011-12-25 16:14 CST, Darrell
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darrell 2011-12-25 16:14:19 CST
Created attachment 244 [details]
Fix hard-coded paths used by kdesu for root

The hard-coded search paths for kdesu are incorrect.

Slackware 13.1.

On a couple of test machines I have both 3.5.10 and 3.5.13 installed. 3.5.10 is installed to /usr and 3.5.13 is installed to /opt/trinity. This kind of setup would be similar to having KDE4 installed. That is, this problem will be seen in those environments too.

I have /etc/profile.d scripts add /opt/trinity/bin to the beginning of the $PATH variable and startkde checks for that too.

All is well until using kdesu. For whatever reason, kdesu does not find root's profile settings for the app being opened. Instead the defaults are used. For example, when I open kate with kdesu (kdesu kate), the toolbar is the default toolbar rather than the customized toolbar I made for root's kate.

Temporarily renaming /usr/bin/kate (3.5.10) solves the problem and kdesu correctly opens kate with the correct toolbar. Somehow kdesu is getting confused with two apps named kate in the search $PATH.

I can overcome the problem by typing the full path of the app and adjusting shortcuts accordingly. For example, kdesu /opt/trinity/bin/kate. Doable but inconvenient --- computers are supposed to make lives easier, not harder. :)

I can overcome the problem by temporarily renaming /usr/bin/kate.

The root cause is TDE being installed in a non standard location.

Seems the problem is the file search paths that are hard-coded into kdesu. The search paths are hard-coded in kdelibs/kdesu/stub.cpp.

Those defaults succeed when there is only one app using a particular name. That no longer is the case with up to three similar desktop environments with all of the apps using the same name. Each desktop has to be installed in its own location and only one can be installed in the standard /usr/bin location. Individual distro maintainers can do as they please, but the safe upstream presumption for popular distros where TDE is an add-on, is KDE4 is already installed in /usr/bin. Therefore TDE always will be installed in a non standard location.

In stub.cpp, for root the $PATH string set in TDE looks like this:

/sbin:/bin:/usr/sbin:/usr/bin

When kdesu launches apps as root in TDE, the search order should look like this:

/sbin:/bin:/usr/sbin:$PREFIX/bin:/usr/bin

But the search order seems to be acting like this:

/sbin:/bin:/usr/sbin:/usr/bin:$PREFIX/bin

Which is exactly what is seen in stub.cpp:126.

Further the $PATH order in stub.cpp for root is incorrect. The current path in stub.cpp should have the sbin locations first, like this:

/sbin:/usr/sbin:/bin:/usr/bin

Further, the traditional $PATH order with su for root looks like this:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

The hard-coded path in stub.cpp does not include /usr/local. Those two locations should be included in the hard-coded path.

For TDE then, stub.cpp should look like this:

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:${PREFIX}/bin:/usr/bin:/bin

Line 126 in stub.cpp can be fixed with a direct patch because when the $PATH variable already exists, then all that is needed is to add the sbin locations for root. The existing $PATH already has $PREFIX/bin before /usr/bin, either through /etc/profile.d scripts or startkde.

I am attaching a patch for that straightforward change.

Line 128 still needs to support $PREFIX/bin before /usr/bin. That can't be fixed with a direct patch because the location of $PREFIX is unknown and can't be presumed to be located at /opt/trinity. Hopefully cmake can handle that change.

I tested patching stub.cpp with my patch and fixing line 128 on-the-fly from within my build script using sed:

if [ "$PREFIX" != "/usr/bin" ]; then
  sed -i "s|/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin|/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:${PREFIX}/bin:/usr/bin:/bin|" kdesu/stub.cpp
fi

That solved the problem. kdesu then opened $PREFIX/bin/kate and correctly found root's profile settings and displayed the correct toolbar.

A better method is needed to update line stub.cpp:128, but my on-the-fly sed fix should provide sufficient proof of concept of what is needed. However, line 128 should be changed only if $PREFIX/bin != /usr/bin.

Darrell
Comment 1 Timothy Pearson 2012-02-12 00:07:18 CST
(In reply to comment #0)
> The root cause is TDE being installed in a non standard location.

"Doctor, Doctor, it hurts when I do this"

"Don't do that"

:-))

Proper patch, with CMake support, committed to GIT in hash e131f10.

Thanks for reporting, and for the patch!
Comment 2 Darrell 2012-02-15 14:29:01 CST
Which patch includes the cmake revisions?
Comment 3 Timothy Pearson 2012-02-15 14:38:06 CST
(In reply to comment #2)
> Which patch includes the cmake revisions?

Should all be in e131f10.  The CMake files actually didn't need to be changed because they already exported the needed information.