SOURCES: kde4-kdebase-workspace-rootprivs.patch (NEW) - call kdesu when roo...

shadzik shadzik at pld-linux.org
Thu Jun 26 12:40:43 CEST 2008


Author: shadzik                      Date: Thu Jun 26 10:40:43 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- call kdesu when root priviledges are needed
- stolen from fedora

---- Files affected:
SOURCES:
   kde4-kdebase-workspace-rootprivs.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/kde4-kdebase-workspace-rootprivs.patch
diff -u /dev/null SOURCES/kde4-kdebase-workspace-rootprivs.patch:1.1
--- /dev/null	Thu Jun 26 12:40:44 2008
+++ SOURCES/kde4-kdebase-workspace-rootprivs.patch	Thu Jun 26 12:40:38 2008
@@ -0,0 +1,69 @@
+diff -ur kdebase-workspace-4.0.72/systemsettings/mainwindow.cpp kdebase-workspace-4.0.72-rootprivs/systemsettings/mainwindow.cpp
+--- kdebase-workspace-4.0.72/systemsettings/mainwindow.cpp	2008-04-30 15:58:34.000000000 +0200
++++ kdebase-workspace-4.0.72-rootprivs/systemsettings/mainwindow.cpp	2008-05-07 01:05:14.000000000 +0200
+@@ -27,6 +27,7 @@
+ 
+ #include <QLayout>
+ #include <QStackedWidget>
++#include <QProcess>
+ 
+ #include <KAction>
+ #include <KActionCollection>
+@@ -42,6 +43,7 @@
+ #include <KStandardAction>
+ #include <KTabWidget>
+ #include <kcategorizedsortfilterproxymodel.h>
++#include <KStandardDirs>
+ #include <kcategorizedview.h>
+ #include <kcategorydrawer.h>
+ #include <kiconloader.h>
+@@ -297,9 +299,13 @@
+         return;
+ 
+     MenuItem * mItem = selected.data( Qt::UserRole ).value<MenuItem*>();
++    bool needsRootPrivs = false;
+     if ( mItem ) {
+         kDebug() << "Selected item: " << mItem->service->name();
+         kDebug() << "Comment:       " << mItem->service->comment();
++
++        needsRootPrivs = mItem->service->property( "X-KDE-RootOnly", QVariant::Bool ).toBool();
++        kDebug() << "Needs root privs:" << needsRootPrivs;
+     } else {
+         kDebug() << ":'( Got dud pointer from " << selected.data( Qt::DisplayRole ).toString();
+         Q_ASSERT(mItem); // Would core dump below. Do it now
+@@ -311,6 +317,35 @@
+     if ( groupWidget )
+         return;
+ 
++    if ( needsRootPrivs )
++    {
++        QString kdesu = KStandardDirs::findExe( "kdesu" );
++        //kDebug() << "kdesu path:" << kdesu;
++
++        QString cmd = mItem->service->exec().trimmed();
++
++        /* Prepare the process to run the kcmshell */
++        if ( cmd.left(5) == "kdesu" )
++        {
++            cmd = cmd.remove(0,5).trimmed();
++
++            /* Remove all kdesu switches */
++            while ( cmd.length() > 1 && cmd[ 0 ] == '-' )
++                cmd = cmd.remove( 0, cmd.indexOf( ' ' ) ).trimmed();
++        }
++
++        if ( cmd.left(9) == "kcmshell4" )
++            cmd = cmd.remove(0,9).trimmed();
++
++        QStringList args;
++        args << "-c" << QString( "%1 %2 --lang %3" ).arg( KStandardDirs::locate("exe", "kcmshell4") ).arg( cmd ).arg( KGlobal::locale()->language() );
++
++        kDebug() << "Starting root module: " << args;
++        QProcess::execute( kdesu, args );
++
++        return;
++    }
++
+     groupWidget = moduleItemToWidgetDict[mItem->service];
+ 
+     if( !groupWidget ) {
================================================================


More information about the pld-cvs-commit mailing list