[PC-BSD Commits] r19046 - pcbsd-projects/PCDM
svn at pcbsd.org
svn at pcbsd.org
Tue Sep 11 09:32:03 PDT 2012
Author: kenmoore
Date: 2012-09-11 16:32:02 +0000 (Tue, 11 Sep 2012)
New Revision: 19046
Modified:
pcbsd-projects/PCDM/pcdm-backend.cpp
Log:
Found a working solution to running startup scripts for PCDM within a QProcess, now to test it.
Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp 2012-09-11 15:47:20 UTC (rev 19045)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp 2012-09-11 16:32:02 UTC (rev 19046)
@@ -93,14 +93,21 @@
}
Backend::log("Starting up Desktop environment ("+saveX+") as user ("+saveUsername+")");
//Use the saved information
- QString username = saveUsername;
- QString cmd = "su "+username+" -c "+saveX; //switch user command to start the DE
- // Get any startup scripts
+ QString cmd = "su "+saveUsername+" -c \""; //switch user command to start process properly
+ // Get any startup scripts and append them to the startup command
QDir sdir(Config::loginScriptsDir());
QStringList child = sdir.entryList(QDir::Files | QDir::Executable | QDir::NoDotAndDotDot);
-
+ if(!child.isEmpty()){
+ cmd.append(child.join("; "));
+ cmd.append("; ");
+ }
+ //Add the DE startup command to the end
+ cmd.append(saveX);
+ //Finish up the command formatting
+ cmd.append("\"");
+ Backend::log("Startup command: "+cmd);
// Get the user's home directory
- QString homeDir = getUserHomeDir(username);
+ QString homeDir = getUserHomeDir(saveUsername);
// Get the current locale code
QLocale mylocale;
QString langCode = mylocale.name();
@@ -111,12 +118,12 @@
//Backend::log("System Environment: " + environ.toStringList().join(" ") );
// Setup any specialized environment variables
// USER, HOME, and SHELL are set by the "su" login
- environ.insert("LOGNAME",username); //Login name
- environ.insert("USERNAME",username); // Username
+ environ.insert("LOGNAME",saveUsername); //Login name
+ environ.insert("USERNAME",saveUsername); // Username
environ.insert("PATH",environ.value("PATH")+":"+homeDir+"/bin"); // Append the user's home dir to the path
environ.insert("LANG",langCode+"."+environ.value("MM_CHARSET")); //Set the proper localized language
- environ.insert("MAIL","/var/mail/"+username); //Set the mail variable
- environ.insert("GROUP",username); //Set the proper group id
+ environ.insert("MAIL","/var/mail/"+saveUsername); //Set the mail variable
+ environ.insert("GROUP",saveUsername); //Set the proper group id
environ.insert("SHLVL","1"); //Set the proper shell level
p->setProcessEnvironment(environ);
p->setWorkingDirectory(homeDir); //set the current directory to the user's home directory
@@ -126,30 +133,10 @@
p->start(cmd);
// Wait for the process to start before continuing
p->waitForStarted();
- Backend::log("Startup Environment: " + p->processEnvironment().toStringList().join(" ") );
- // Run any startup scripts as child processes
- QProcess ch(p);
- ch.setStandardOutputFile("/usr/local/share/PCDm/PCDM.log",QIODevice::Append);
- ch.setProcessEnvironment(environ);
- ch.start("/bin/sh",child);
- /*
- QList<QProcess*> childrenL;
- for(int i=0; i<child.length(); i++){
- childrenL.append( new QProcess(p) ); // "p" is the parent of "ch"
- childrenL[i]->setStandardOutputFile("/usr/local/share/PCDM/PCDM.log",QIODevice::Append); //log any output
- childrenL[i]->setProcessEnvironment(environ);
- Backend::log("Starting script: "+child[i]);
- Backend::log("Child Environment: "+childrenL[i]->processEnvironment().toStringList().join(" "));
- childrenL[i]->start(child[i]);
- }
- */
+ //Backend::log("Startup Environment: " + p->processEnvironment().toStringList().join(" ") );
// Now Wait for the process to finish
p->waitForFinished(-1); //do not time-out
//XSession stopped, now clean up
- /*for(int i=0; i<childrenL.length(); i++){
- childrenL[i]->terminate();
- }*/
- ch.terminate();
saveUsername.clear();
saveX.clear();
}
More information about the Commits
mailing list