[PC-BSD Commits] r12246 - pcbsd/current/src-qt4/pc-softwaremanager

svn at pcbsd.org svn at pcbsd.org
Tue Aug 23 16:25:49 PDT 2011


Author: kris
Date: 2011-08-23 16:25:49 -0700 (Tue, 23 Aug 2011)
New Revision: 12246

Modified:
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
   pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
Log:

Add fix to AppCafe to check first if the user is apart of the "operator" group, and if not warn
and exit to avoid a crash later in loading process.



Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp	2011-08-23 16:22:57 UTC (rev 12245)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.cpp	2011-08-23 23:25:49 UTC (rev 12246)
@@ -50,6 +50,8 @@
    isWorkingOnPBI = false;
    autoUpdateSoftware = false;
 
+   // Check if member of group operator
+   checkGroupOperator();
 
    // Load the program preferences
    slotLoadSettings();
@@ -92,7 +94,7 @@
    connect(fileWatcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(PopulateList()));
 
    // Load any saved states for PBIs
-   loadStatePBI(); 
+   //loadStatePBI(); 
     
    // Get the username of the person running X
    RealUserName = getlogin();
@@ -117,6 +119,34 @@
   QTimer::singleShot(3000, this, SLOT(slotProcessPBIs() ) );
 }
 
+void PBM::checkGroupOperator()
+{
+   QString loginName = getlogin();
+   if ( loginName() == "root" )
+     return;
+
+   QString tmp;
+   QFile iFile("/etc/group");
+   if ( ! iFile.open(QIODevice::ReadOnly | QIODevice::Text))
+     return;
+                
+   while ( !iFile.atEnd() ) {
+     tmp = iFile.readLine().simplified();
+     if ( tmp.indexOf("operator") == 0 ) {
+	QStringList gNames = tmp.section(":", 3, 3).split(",");
+	break;
+     }
+   }
+   iFile.close();
+        
+   for ( int i = 0; i < gNames.size(); ++i )
+      if ( gNames.at(i).indexOf() == loginName )
+	    return;
+
+   QMessageBox::information( this, tr("Error!"), tr("Installing applications has been disabled for this user. Please add the user to the operator group or restart as root.") );
+   close();  
+}
+
 void PBM::slotQuitButtonClicked()
 {
   // Check if we are working right now
@@ -531,7 +561,6 @@
   {
     QMessageBox::information( this, tr("Error!"), tr("This program must be run as root!") );
     close();  
-	   
   }
 
 }

Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h	2011-08-23 16:22:57 UTC (rev 12245)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-main.h	2011-08-23 23:25:49 UTC (rev 12246)
@@ -106,6 +106,7 @@
     void slotSearchClicked();
 
 private:
+    void checkGroupOperator();
     void RemovePBI( PBI * pbi );
     void addBrowseWidget(QWidget *bwid);
     bool checkPBILoaded(QString name);

Modified: pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2011-08-23 16:22:57 UTC (rev 12245)
+++ pcbsd/current/src-qt4/pc-softwaremanager/softmanager-pbiupdate.cpp	2011-08-23 23:25:49 UTC (rev 12246)
@@ -352,7 +352,7 @@
   PopulateList();
 
   // Savestate in case we close
-  saveStatePBI();
+  //saveStatePBI();
 
   // Restart the PBI file watcher
   fileWatcher->addPath("/var/db/pbi/installed");
@@ -457,7 +457,7 @@
   	SoftwareListBox->resizeColumnToContents(0);
 
   	// Savestate in case we close
-  	saveStatePBI();
+  	//saveStatePBI();
 }
 
 // Save our PBI states



More information about the Commits mailing list