Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://github.com/pcbsd/pcbsd
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshDW19 committed Mar 15, 2014
2 parents a710b3b + 556d790 commit e595526
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 35 deletions.
1 change: 1 addition & 0 deletions build-files/conf/port-make.conf
Expand Up @@ -79,6 +79,7 @@ jasperserver_SET=XLS
k3b_SET=SOX NORMALIZE TRANSCODE
kmymoney-kde4_SET=KBANKING OFX
kopete_SET=WEBCAM
krdc_SET=FREERDP
libreoffice_SET=SYSTRAY
libxine_SET=LIBBLURAY VAAPI WAVPACK SMB XVMC
libxul_UNSET=ALSA
Expand Down
15 changes: 4 additions & 11 deletions src-qt4/PCDM/src/main.cpp
Expand Up @@ -144,11 +144,8 @@ int runSingleSession(int argc, char *argv[]){
w.setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
w.setWindowState(Qt::WindowMaximized); //Qt::WindowFullScreen);

//Setup the signals/slots to startup the desktop session
//if(USECLIBS){ QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString)), &desktop,SLOT(setupDesktop(QString,QString,QString))); }
//else{
QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );
//}
//Setup the signals/slots to startup the desktop session
QObject::connect( &w,SIGNAL(xLoginAttempt(QString,QString,QString,QString)), &desktop,SLOT(loginToXSession(QString,QString,QString,QString)) );
//Setup the signals/slots for return information for the GUI
QObject::connect( &desktop, SIGNAL(InvalidLogin()), &w, SLOT(slotLoginFailure()) );
QObject::connect( &desktop, SIGNAL(started()), &w, SLOT(slotLoginSuccess()) );
Expand All @@ -159,10 +156,7 @@ int runSingleSession(int argc, char *argv[]){
retCode = a.exec();
} // end of PCDM GUI running
//Wait for the desktop session to finish before exiting
//if(USECLIBS){ desktop.startDesktop(); }
//else{
desktop.waitForSessionClosed();
//}
splash.show(); //show the splash screen again
//Now wait a couple seconds for things to settle
QTime wTime = QTime::currentTime().addSecs(2);
Expand All @@ -179,8 +173,6 @@ int runSingleSession(int argc, char *argv[]){
//Keep processing events during the wait (for splashscreen)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
//set the return code for a shutdown
retCode = -1; //make sure it does not start a new session
}

//Clean up Code
Expand Down Expand Up @@ -213,7 +205,8 @@ int main(int argc, char *argv[])
int retCode = runSingleSession(argc,argv);
qDebug() << "-- PCDM Session Ended --";
//check for special exit code
if(retCode != 0){ neverquit=FALSE; }
if(retCode == -1){ neverquit=true; } //make sure we go around again at least once
else if(retCode != 0){ neverquit=FALSE; }
//Now kill the shild process (whole session)
qDebug() << "Exiting child process";
exit(3);
Expand Down
29 changes: 17 additions & 12 deletions src-qt4/PCDM/src/pcdm-backend.cpp
Expand Up @@ -91,7 +91,11 @@ QString Backend::getUsernameFromDisplayname(QString dspname){

QString Backend::getDisplayNameFromUsername(QString username){
int i = usernameList.indexOf(username);
return displaynameList[i];
if(i==-1){ i = displaynameList.indexOf(username); } //make sure it was not a display name passed in
if(i==-1){ return ""; }
else{
return displaynameList[i];
}
}

QString Backend::getUserHomeDir(QString username){
Expand Down Expand Up @@ -249,8 +253,8 @@ void Backend::checkLocalDirs(){
//Check for sample files
if(!mainDir.exists("pcdm.conf.sample")){ QFile::copy(":samples/pcdm.conf",base+"/pcdm.conf.sample"); }
//Check for the PCDM runtime directory
mainDir.cd("/var/db/pcdm");
if(!mainDir.exists()){ mainDir.mkdir("/var/db/pcdm"); }
mainDir.cd(DBDIR);
if(!mainDir.exists()){ mainDir.mkpath(DBDIR); }
}

QString Backend::getLastUser(){
Expand All @@ -259,7 +263,8 @@ QString Backend::getLastUser(){
readSystemLastLogin();
}
//return the value
return lastUser;
QString user = getDisplayNameFromUsername(lastUser);
return user;
}

QString Backend::getLastDE(QString user){
Expand All @@ -273,7 +278,7 @@ QString Backend::getLastDE(QString user){
}

void Backend::saveLoginInfo(QString user, QString desktop){
writeSystemLastLogin(user,desktop); //save the system file (/usr/local/share/PCDM/.lastlogin)
writeSystemLastLogin(user,desktop); //save the system file (DBDIR/lastlogin)
writeUserLastDesktop(user,desktop); //save the user file (~/.lastlogin)
}

Expand All @@ -284,7 +289,7 @@ void Backend::readDefaultSysEnvironment(QString &lang, QString &keymodel, QStrin
keylayout = "us";
keyvariant = "";
//Read the current inputs file and overwrite default values
QFile file("/var/db/pcdm/defaultInputs");
QFile file(DBDIR+"defaultInputs");
bool goodFile=false;
if(file.exists()){
if(file.open(QIODevice::ReadOnly | QIODevice::Text) ){
Expand All @@ -308,11 +313,11 @@ void Backend::readDefaultSysEnvironment(QString &lang, QString &keymodel, QStrin
}

void Backend::saveDefaultSysEnvironment(QString lang, QString keymodel, QString keylayout, QString keyvariant){
QFile file("/var/db/pcdm/defaultInputs");
QFile file(DBDIR+"defaultInputs");
//Make sure the containing directory exists
if(!QFile::exists("/var/db/pcdm")){
if(!QFile::exists(DBDIR)){
QDir dir;
dir.mkpath("/var/db/pcdm");
dir.mkpath(DBDIR);
}
//Now save the file
if(file.open(QIODevice::WriteOnly | QIODevice::Text) ){
Expand Down Expand Up @@ -540,12 +545,12 @@ void Backend::readSystemUsers(){
}

void Backend::readSystemLastLogin(){
if(!QFile::exists("/usr/local/share/PCDM/.lastlogin")){
if(!QFile::exists(DBDIR+"lastlogin")){
lastUser.clear();
Backend::log("PCDM: No previous login data found");
}else{
//Load the previous login data
QFile file("/usr/local/share/PCDM/.lastlogin");
QFile file(DBDIR+"lastlogin");
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
Backend::log("PCDM: Unable to open previous login data file");
}else{
Expand All @@ -558,7 +563,7 @@ void Backend::readSystemLastLogin(){
}

void Backend::writeSystemLastLogin(QString user, QString desktop){
QFile file1("/usr/local/share/PCDM/.lastlogin");
QFile file1(DBDIR+"lastlogin");
if(!file1.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){
Backend::log("PCDM: Unable to save last login data to system directory");
}else{
Expand Down
1 change: 1 addition & 0 deletions src-qt4/PCDM/src/pcdm-backend.h
Expand Up @@ -19,6 +19,7 @@
#include "pcbsd-utils.h"

#define PCSYSINSTALL QString("/usr/sbin/pc-sysinstall")
#define DBDIR QString("/var/db/pcdm/")

class Process : public QProcess {
public:
Expand Down
18 changes: 9 additions & 9 deletions src-qt4/PCDM/src/pcdm-xprocess.cpp
Expand Up @@ -48,7 +48,10 @@ void XProcess::loginToXSession(QString username, QString password, QString deskt
xde = desktop;
xlang = lang;
//Now start the login process
startXSession();
if( !startXSession() ){
//Could not continue after session changed significantly - close down the session to restart
QCoreApplication::exit(-1); //special code to make sure we are just restarting the PCDM session (not the full X session)
}
}

bool XProcess::isRunning(){
Expand All @@ -68,20 +71,21 @@ void XProcess::waitForSessionClosed(){
*/

bool XProcess::startXSession(){
//disconnect(SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotCleanup()) );
//Returns TRUE if the session can continue, or FALSE if it needs to be closed down

//Check that the necessary info to start the session is available
if( xuser.isEmpty() || xcmd.isEmpty() || xhome.isEmpty() || xde.isEmpty() ){
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
return true;
}
//Backend::log("Starting up Desktop environment ("+xcmd+") as user ("+xuser+")");

//Check for PAM username/password validity
if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return FALSE; }
if( !pam_checkPW() ){ emit InvalidLogin(); pam_shutdown(); return true; }


//Save the current user/desktop as the last login
Backend::saveLoginInfo(Backend::getDisplayNameFromUsername(xuser),xde);
Backend::saveLoginInfo(xuser,xde);

// Get the users uid/gid information
struct passwd *pw;
Expand All @@ -91,7 +95,6 @@ bool XProcess::startXSession(){
if (!(pw = getpwnam(xuser.toLatin1()))) {
uid = strtol(xuser.toLatin1(), &ok, 10);
if (!(pw = getpwuid(uid))) {
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}
}
Expand All @@ -109,22 +112,19 @@ bool XProcess::startXSession(){
//QWidget *wid = new QWidget();
if (setgid(pw->pw_gid) < 0) {
qDebug() << "setgid() failed!";
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}

// Setup our other groups
if (initgroups(xuser.toLatin1(), pw->pw_gid) < 0) {
qDebug() << "initgroups() failed!";
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
setgid(0);
return FALSE;
}

// Lets drop to user privs
if (setuid(pw->pw_uid) < 0) {
qDebug() << "setuid() failed!";
emit InvalidLogin(); //Make sure the GUI knows that it was a failure
return FALSE;
}
//Startup the PAM session
Expand Down
4 changes: 3 additions & 1 deletion src-qt4/libpcbsd/utils/netif.cpp
Expand Up @@ -536,7 +536,9 @@ void NetworkInterface::wifiQuickConnect(QString SSID, QString netKey, QString De
} else if ( SecType.contains("WEP") ) {
//Set WEP Defaults
int WEPIndex = 0;
bool WEPHex = true; //Use Hex WEP key
// Default to plain-text WEP keys..
// This needs to be fixed to figure it out automatically
bool WEPHex = false;

streamout << " key_mgmt=NONE\n";
streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex) + "\n";
Expand Down
4 changes: 2 additions & 2 deletions src-qt4/pc-netmanager/src/wificonfig/wificonfigwidgetbase.cpp
Expand Up @@ -164,9 +164,9 @@ void wificonfigwidgetbase::updateWPASupp()
streamout << " wep_tx_keyidx=" + tmp.setNum(WEPIndex[curItem]) + "\n";
// Check if we are using a plaintext WEP or not
if ( WEPHex[curItem] )
streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=\"" + WEPKey[curItem] + "\"\n";
else
streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=" + WEPKey[curItem] + "\n";
else
streamout << " wep_key" + tmp.setNum(WEPIndex[curItem]) + "=\"" + WEPKey[curItem] + "\"\n";

} else if (SSIDEncType[curItem] == WPA_ENCRYPTION ) {

Expand Down

0 comments on commit e595526

Please sign in to comment.