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

svn at pcbsd.org svn at pcbsd.org
Wed Apr 3 09:25:44 PDT 2013


Author: kenmoore
Date: 2013-04-03 16:25:44 +0000 (Wed, 03 Apr 2013)
New Revision: 22040

Modified:
   pcbsd-projects/PCDM/main.cpp
   pcbsd-projects/PCDM/pcdm-backend.cpp
   pcbsd-projects/PCDM/pcdm-backend.h
   pcbsd-projects/PCDM/pcdm-gui.cpp
   pcbsd-projects/PCDM/pcdm-gui.h
   pcbsd-projects/PCDM/pcdm-xprocess.h
Log:
Remove a bunch of the old commented out code. The new PAM usage works great now.



Modified: pcbsd-projects/PCDM/main.cpp
===================================================================
--- pcbsd-projects/PCDM/main.cpp	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/main.cpp	2013-04-03 16:25:44 UTC (rev 22040)
@@ -63,10 +63,6 @@
     if( user.isEmpty() || dcmd.isEmpty() ){
 	 goodAL=FALSE;   
     }else{
-	/*desktop.setXUsername(user);
-	desktop.setXCommand(dcmd);
-	desktop.setXHomeDir( Backend::getUserHomeDir(user) );
-	desktop.startXSession();*/
 	desktop.loginToXSession(user,pwd, Backend::getUserHomeDir(user), dcmd);
 	splash.close();
 	if(desktop.isRunning()){

Modified: pcbsd-projects/PCDM/pcdm-backend.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.cpp	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/pcdm-backend.cpp	2013-04-03 16:25:44 UTC (rev 22040)
@@ -4,8 +4,6 @@
 *  Available under the 3-clause BSD license
 */
 
-//#include <sys/types.h>
-//#include <security/pam_appl.h>
 #include <QProcess>
 #include <QProcessEnvironment>
 
@@ -51,20 +49,6 @@
   return displaynameList;
 }
 
-/*bool Backend::startUserLogin(QString username, QString password, QString xBinary){
-  bool allowed = verifyUsernamePassword(username, password);
-  if(allowed){
-    Backend::log("Username/Password Authorized");
-    saveX=xBinary;
-    saveUsername=username;
-  }else{
-    Backend::log("Username/Password not authorized");
-    saveX.clear();
-    saveUsername.clear();
-  }
-  return allowed;
-}
-*/
 QString Backend::getALUsername(){
   //Make sure the requested user is valid
   readSystemUsers(); //first read the available users on this system
@@ -110,105 +94,6 @@
   return rpassword;
 }
 
-/*void Backend::startAutoLogin(){
-  //Make sure the requested user is valid
-  readSystemUsers(); //first read the available users on this system
-  QString ruser = Config::autoLoginUsername();
-  int index = usernameList.indexOf(ruser);
-  if(index == -1){ //invalid username
-    //Check if a display name was given instead
-    index = displaynameList.indexOf(ruser);
-    if(index == -1){ //invalid display name
-      log("Invalid Auto-Login user requested - skipping....");
-      return;
-    }else{
-      //use the valid username for the given display name
-      ruser = usernameList[index]; 
-    }
-  }
-  // Make sure the desired desktop is valid
-  QString rdesktop = Config::autoLoginDesktop();
-  if(!QFile::exists(rdesktop)){ //requested file does not exist
-    log("Invalid Auto-Login desktop requested - skipping....");
-    return;
-  }
-  QStringList result = readXSessionsFile(rdesktop,"");
-  if(result.isEmpty()){  //requested file is not a valid xsessions file
-    log("Invalid Auto-Login desktop requested - skipping....");
-    return;  	  
-  }
-  if(!result[0].startsWith("/")){ result[0] = "/usr/local/bin/"+result[0]; }
-  rdesktop = result[0]; //(absolute path) executable
-  if(!QFile::exists(rdesktop)){  //requested desktop is not currently installed
-    log("Invalid Auto-Login desktop requested - skipping....");
-    return;    	  
-  }
-  
-  //Save the appropriate variables to start the login process
-  saveX = rdesktop;
-  saveUsername = ruser;
-  log("Valid Auto-Login information found");
-}
-
-void Backend::startXSession(){
-  // WARNING!! This function should *never* be called within the GUI
-  // It should only be called as part of the main event loop
-  
-  //Check that there is a username/session that needs to be started
-  if( saveX.isEmpty() || saveUsername.isEmpty() ){
-    Backend::log("No information to start XSession - skipping");
-    return;
-  }
-  Backend::log("Starting up Desktop environment ("+saveX+") as user ("+saveUsername+")");
-
-  // Get the user's home directory
-  QString homeDir = getUserHomeDir(saveUsername);  
-  // Use the saved information
-  QString cmd = "su "+saveUsername+" -c \""; //switch user command to start process properly
-  // Setup to run the user's <home-dir>/.xprofile startup script
-  if(QFile::exists(homeDir+"/.xprofile")){
-    cmd.append("(/bin/sh "+homeDir+"/.xprofile) &; ");  //make sure to start it in parallel
-  }
-  //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 current locale code
-  QLocale mylocale;
-  QString langCode = mylocale.name();
-  // 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(" ") );
-  // Setup any specialized environment variables
-  // USER, HOME, and SHELL are set by the "su" login
-  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
-  if( !environ.value("MM_CHARSET").isEmpty() ){ langCode.append("."+environ.value("MM_CHARSET")); }
-  environ.insert("LANG",langCode); //Set the proper localized language
-  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
-  //Log the DE startup outputs as well
-  p->setStandardOutputFile("/usr/local/share/PCDM/PCDM.log",QIODevice::Append);
-  // Startup the process
-  p->start(cmd);
-  // Wait for the process to start before continuing
-  p->waitForStarted();
-  //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
-  p->close();
-  saveUsername.clear(); 
-  saveX.clear();
-}
-*/
 QString Backend::getUsernameFromDisplayname(QString dspname){
   int i = displaynameList.indexOf(dspname);
   return usernameList[i];
@@ -446,84 +331,7 @@
   return output;
 
 }
-/*
-pam_handle_t *pamh;  //handle for the PAM process structure
-static struct pam_conv pamc = { openpam_nullconv, NULL }; //null conversation function for PAM
 
-bool Backend::verifyUsernamePassword(QString username, QString password){
-  //Convert the inputs to C character arrays for use in PAM
-  QByteArray tmp = username.toUtf8();
-  char* cUser = tmp.data();
-  QByteArray tmp2 = password.toUtf8();
-  char* cPassword = tmp2.data();
-  //initialize variables
-  bool result = FALSE;
-  int ret;
-  //Initialize PAM
-  ret = pam_start("login", cUser, &pamc, &pamh);
-  if( ret == PAM_SUCCESS ){
-    //Place the user-supplied password into the structure 
-    ret = pam_set_item(pamh, PAM_AUTHTOK, cPassword);
-    //Set the TTY 
-    //ret = pam_set_item(pamh, PAM_TTY, "pcdm-terminal");
-    //Authenticate with PAM
-    ret = pam_authenticate(pamh,0);
-    if( ret == PAM_SUCCESS ){
-      //Check for valid, unexpired account and verify access restrictions
-      ret = pam_acct_mgmt(pamh,0);
-      if( ret == PAM_SUCCESS ){ result = TRUE; }
-    
-    }else{
-    	    Backend::log("PAM Authentication Failed with error: " + QString::number(ret));
-      switch( ret ){
-      case PAM_ABORT:
-      	      Backend::log(" - PAM abort error");
-      	  break;
-      case PAM_AUTHINFO_UNAVAIL:
-      	      Backend::log(" - Authentication info unavailable");
-      	      break;
-      case PAM_AUTH_ERR:
-      	      Backend::log(" - Authentication error");
-      	      break;
-      case PAM_BUF_ERR:
-      	      Backend::log(" - Buffer error");
-      	      break;
-      case PAM_CONV_ERR:
-      	      Backend::log(" - Conversion error");
-      	      break;
-      case PAM_CRED_INSUFFICIENT:
-      	      Backend::log(" - Credentials insufficient");
-      	      break;
-      case PAM_MAXTRIES:
-      	      Backend::log(" - Maximum number of tries exceeded");
-      	      break;
-      case PAM_PERM_DENIED:
-      	      Backend::log(" - Permission denied");
-      	      break;
-      case PAM_SERVICE_ERR:
-      	      Backend::log(" - Service error");
-      	      break;
-      case PAM_SYMBOL_ERR:
-      	      Backend::log(" - Symbol error");
-      	      break;
-      case PAM_SYSTEM_ERR:
-      	      Backend::log(" - System error");
-      	      break;
-      case PAM_USER_UNKNOWN:
-      	      Backend::log(" - Unknown user");
-      	      break;
-      default:
-      	      Backend::log(" - Unrecognized authentication error");
-      }
-    }
-    //Stop PAM   
-    pam_end(pamh,ret);  
-  }
-  //return verification result
-  return result;	
-}
-*/
-
 void Backend::readSystemUsers(){
   //make sure the lists are empty
   usernameList.clear(); displaynameList.clear(); homedirList.clear();

Modified: pcbsd-projects/PCDM/pcdm-backend.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-backend.h	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/pcdm-backend.h	2013-04-03 16:25:44 UTC (rev 22040)
@@ -13,10 +13,6 @@
 #include <QDir>
 #include <QProcess>
 
-//#include <sys/types.h>
-//#include <security/pam_appl.h>
-//#include <security/openpam.h>
-
 #include "pcdm-config.h"
 #include "pcbsd-utils.h"
 
@@ -37,8 +33,6 @@
     static QString getDesktopIcon(QString);
     static QString getDesktopBinary(QString);
     static QStringList getSystemUsers();
-    //static bool startUserLogin(QString, QString, QString);
-    //static void startAutoLogin();
     static QString getUsernameFromDisplayname(QString);
     static QStringList keyModels();
     static QStringList keyLayouts();
@@ -46,8 +40,7 @@
     static void changeKbMap(QString model, QString layout, QString variant);
     static QStringList languages();
     static void openLogFile(QString);
-    static void log(QString);
-    //static void startXSession();  
+    static void log(QString); 
     static QString getUserHomeDir(QString);
     static void checkLocalDirs();
 
@@ -58,7 +51,6 @@
 private:	
     static void loadXSessionsData();
     static QStringList readXSessionsFile(QString, QString);
-    //static bool verifyUsernamePassword(QString, QString);
     static void readSystemUsers();
  
     

Modified: pcbsd-projects/PCDM/pcdm-gui.cpp
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.cpp	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/pcdm-gui.cpp	2013-04-03 16:25:44 UTC (rev 22040)
@@ -239,19 +239,6 @@
   emit xLoginAttempt(username, password, homedir, binary);
   //Return signals are connected to the slotLogin[Success/Failure] functions
   
-  /*
-  bool success = Backend::startUserLogin(username, password, binary); 
-  if(success){
-    emit xUserFound(username);
-    emit xCmdFound(binary);
-    emit xHomeFound( Backend::getUserHomeDir(username) );
-    emit xSessionStart(); //start the desktop environment
-    saveLastLogin( displayname, deSwitcher->currentItem() );
-    slotClosePCDM(); //now start to close down the PCDM GUI
-  }else{
-   
-  }
-  */
 }
 
 void PCDMgui::slotLoginSuccess(){
@@ -311,8 +298,6 @@
   if(ret == QMessageBox::Yes){
     Backend::log("PCDM: Shutting down computer");
     system("shutdown -p now");
-    //QCoreApplication::exit(2);
-    //close();
   }
 }
 
@@ -328,8 +313,6 @@
   if(ret == QMessageBox::Yes){
     Backend::log("PCDM: Restarting computer");
     system("shutdown -r now");
-    //QCoreApplication::exit(1);
-    //close();
   }
 }
 

Modified: pcbsd-projects/PCDM/pcdm-gui.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-gui.h	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/pcdm-gui.h	2013-04-03 16:25:44 UTC (rev 22040)
@@ -84,10 +84,7 @@
 
 signals:
     void xLoginAttempt(QString, QString, QString, QString);
-    /*void xUserFound(QString);
-    void xCmdFound(QString);
-    void xHomeFound(QString);
-    void xSessionStart(); */
+
 };
 
 #endif // PCDMGUI_H

Modified: pcbsd-projects/PCDM/pcdm-xprocess.h
===================================================================
--- pcbsd-projects/PCDM/pcdm-xprocess.h	2013-04-03 16:06:46 UTC (rev 22039)
+++ pcbsd-projects/PCDM/pcdm-xprocess.h	2013-04-03 16:25:44 UTC (rev 22040)
@@ -41,7 +41,6 @@
 	
 	// PAM stuff and simplification functions
 	pam_handle_t *pamh;  //handle for the PAM process structure
-	//static struct pam_conv pamc;// = { openpam_nullconv, NULL }; //null conversation function for PAM
 	bool pam_started, pam_session_open;
 	bool pam_checkPW();
 	bool pam_startSession();



More information about the Commits mailing list