]>
Commit | Line | Data |
---|---|---|
df33dfbd | 1 | diff -ur kdebase-workspace-4.0.72/systemsettings/mainwindow.cpp kdebase-workspace-4.0.72-rootprivs/systemsettings/mainwindow.cpp |
2 | --- kdebase-workspace-4.0.72/systemsettings/mainwindow.cpp 2008-04-30 15:58:34.000000000 +0200 | |
3 | +++ kdebase-workspace-4.0.72-rootprivs/systemsettings/mainwindow.cpp 2008-05-07 01:05:14.000000000 +0200 | |
4 | @@ -27,6 +27,7 @@ | |
5 | ||
6 | #include <QLayout> | |
7 | #include <QStackedWidget> | |
8 | +#include <QProcess> | |
9 | ||
10 | #include <KAction> | |
11 | #include <KActionCollection> | |
12 | @@ -42,6 +43,7 @@ | |
13 | #include <KStandardAction> | |
14 | #include <KTabWidget> | |
15 | #include <kcategorizedsortfilterproxymodel.h> | |
16 | +#include <KStandardDirs> | |
17 | #include <kcategorizedview.h> | |
18 | #include <kcategorydrawer.h> | |
19 | #include <kiconloader.h> | |
20 | @@ -297,9 +299,13 @@ | |
21 | return; | |
22 | ||
23 | MenuItem * mItem = selected.data( Qt::UserRole ).value<MenuItem*>(); | |
24 | + bool needsRootPrivs = false; | |
25 | if ( mItem ) { | |
26 | kDebug() << "Selected item: " << mItem->service->name(); | |
27 | kDebug() << "Comment: " << mItem->service->comment(); | |
28 | + | |
29 | + needsRootPrivs = mItem->service->property( "X-KDE-RootOnly", QVariant::Bool ).toBool(); | |
30 | + kDebug() << "Needs root privs:" << needsRootPrivs; | |
31 | } else { | |
32 | kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString(); | |
33 | Q_ASSERT(mItem); // Would core dump below. Do it now | |
34 | @@ -311,6 +317,35 @@ | |
35 | if ( groupWidget ) | |
36 | return; | |
37 | ||
38 | + if ( needsRootPrivs ) | |
39 | + { | |
40 | + QString kdesu = KStandardDirs::findExe( "kdesu" ); | |
41 | + //kDebug() << "kdesu path:" << kdesu; | |
42 | + | |
43 | + QString cmd = mItem->service->exec().trimmed(); | |
44 | + | |
45 | + /* Prepare the process to run the kcmshell */ | |
46 | + if ( cmd.left(5) == "kdesu" ) | |
47 | + { | |
48 | + cmd = cmd.remove(0,5).trimmed(); | |
49 | + | |
50 | + /* Remove all kdesu switches */ | |
51 | + while ( cmd.length() > 1 && cmd[ 0 ] == '-' ) | |
52 | + cmd = cmd.remove( 0, cmd.indexOf( ' ' ) ).trimmed(); | |
53 | + } | |
54 | + | |
55 | + if ( cmd.left(9) == "kcmshell4" ) | |
56 | + cmd = cmd.remove(0,9).trimmed(); | |
57 | + | |
58 | + QStringList args; | |
59 | + args << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() ); | |
60 | + | |
61 | + kDebug() << "Starting root module: " << args; | |
62 | + QProcess::execute( kdesu, args ); | |
63 | + | |
64 | + return; | |
65 | + } | |
66 | + | |
67 | groupWidget = moduleItemToWidgetDict[mItem->service]; | |
68 | ||
69 | if( !groupWidget ) { |