[PC-BSD Commits] r18860 - pcbsd-projects/PCDM

svn at pcbsd.org svn at pcbsd.org
Wed Sep 5 10:07:57 PDT 2012


Author: kenmoore
Date: 2012-09-05 17:07:56 +0000 (Wed, 05 Sep 2012)
New Revision: 18860

Modified:
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
Log:
Update the system environment settings when logging in with PCDM



Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-05 16:24:52 UTC (rev 18859)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2012-09-05 17:07:56 UTC (rev 18860)
@@ -7,7 +7,7 @@
 #include "pcdm-config.h"
 #include "pcbsd-utils.h"
 
-QStringList displaynameList,usernameList,instXNameList,instXBinList,instXCommentList,instXIconList;
+QStringList displaynameList,usernameList,homedirList,instXNameList,instXBinList,instXCommentList,instXIconList;
 QString logFile;
 QString saveX,saveUsername;
 
@@ -40,7 +40,8 @@
 
 QStringList Backend::getSystemUsers(){
   if(usernameList.isEmpty()){
-    usernameList.clear(); displaynameList.clear(); //make sure the lists are empty
+    //make sure the lists are empty
+    usernameList.clear(); displaynameList.clear(); homedirList.clear();
     //Get all the users from the file "/etc/passwd"
     QStringList uList = Utils::runShellCommand("cat /etc/passwd");
 
@@ -60,6 +61,7 @@
         //Add this user to the lists if it is good
 	usernameList << uList[i].section(":",0,0).simplified();
 	displaynameList << uList[i].section(":",4,4).simplified();
+	homedirList << uList[i].section(":",5,5).simplified();
       }
     }
   }
@@ -93,16 +95,17 @@
   saveX.clear();
   
   //Get the user's home directory
-  
+  QString homeDir = getUserHomeDir(username);
   //Create the external process
   QProcess* p = new QProcess(0);
   //Setup the process environment
   QProcessEnvironment environ = QProcessEnvironment::systemEnvironment(); //current environment
   Backend::log("System Environment: " + environ.toStringList().join(" ") );
-  environ.insert("LOGNAME",username);
-  environ.insert("USERNAME",username);
-  //environ.insert("HOME",homeDir);
-  //environ.insert("PATH",environ->value("PATH")+":"+homeDir+"/bin");
+  environ.insert("LOGNAME",username); //Login name
+  environ.insert("USERNAME",username); //
+  environ.insert("USER",username);
+  environ.insert("HOME",homeDir);
+  environ.insert("PATH",environ.value("PATH")+":"+homeDir+"/bin");
   p->setProcessEnvironment(environ);
   //Startup the process
   Backend::log("Modified Environment: " + environ.toStringList().join(" ") );
@@ -118,6 +121,11 @@
   int i = displaynameList.indexOf(dspname);
   return usernameList[i];
 }
+QString Backend::getUserHomeDir(QString username){
+  int i = usernameList.indexOf(username);
+  if( i == -1 ){ i = displaynameList.indexOf(username); }
+  return homedirList[i];
+}
 
 QStringList Backend::keyModels()
 {

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2012-09-05 16:24:52 UTC (rev 18859)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2012-09-05 17:07:56 UTC (rev 18860)
@@ -41,7 +41,8 @@
     static QStringList languages();
     static void openLogFile(QString);
     static void log(QString);
-    static void startXSession();     
+    static void startXSession();  
+    static QString getUserHomeDir(QString);
     
 private:	
     static void loadXSessionsData();



More information about the Commits mailing list