5 files changed, 64 insertions, 45 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp index 200e31b..9004d19 100644 --- a/noncore/settings/networksettings2/main.cpp +++ b/noncore/settings/networksettings2/main.cpp @@ -96,4 +96,5 @@ int main( int argc, char * argv[] ) { MyArgv[3] = NULL; NSResources->system().execAsUser( S, MyArgv ); + Log(("FAILED %s-cNN-allowed\n", argv[1] )); // if we come here , failed printf( "%s-cNN-disallowed", argv[1] ); @@ -110,6 +111,9 @@ int main( int argc, char * argv[] ) { { ActivateProfile AP(argv[1]); if( AP.exec() == QDialog::Accepted ) { + Log(("%s-c%ld-allowed\n", + argv[1], AP.selectedProfile() )); printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); } else { + Log(("%s-c%NN-disallowed\n", argv[1] )); printf( "%s-cNN-disallowed", argv[1] ); } diff --git a/noncore/settings/networksettings2/network/network_NN.cpp b/noncore/settings/networksettings2/network/network_NN.cpp index 1feffdb..b5c41bf 100644 --- a/noncore/settings/networksettings2/network/network_NN.cpp +++ b/noncore/settings/networksettings2/network/network_NN.cpp @@ -1,2 +1,3 @@ +#include <qpe/qpeapplication.h> #include <asdevice.h> #include "network_NN.h" @@ -54,5 +55,7 @@ short NetworkNetNode::generateFile( const QString & ID, << NIC << endl; - TS << " script networksettings2-request" + TS << " script " + << QPEApplication::qpeDir() + << "/bin/networksettings2-request" << endl << endl; diff --git a/noncore/settings/networksettings2/networksettings2/resources.cpp b/noncore/settings/networksettings2/networksettings2/resources.cpp index 7ece817..2f17693 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.cpp +++ b/noncore/settings/networksettings2/networksettings2/resources.cpp @@ -295,12 +295,12 @@ typedef struct EnvVars { static EnvVar_t EV[] = { - // AnEV( "HOME=" ), -> SPECIAL - // AnEV( "LOGNAME=" ), -> SPECIAL - AnEV( "USER=" ), - AnEV( "LD_LIBRARY_PATH=" ), - AnEV( "PATH=" ), - AnEV( "QTDIR=" ), - AnEV( "OPIEDIR=" ), - AnEV( "SHELL=" ), + AnEV( "HOME" ), + AnEV( "LOGNAME" ), + AnEV( "USER" ), + AnEV( "LD_LIBRARY_PATH" ), + AnEV( "PATH" ), + AnEV( "QTDIR" ), + AnEV( "OPIEDIR" ), + AnEV( "SHELL" ), { NULL, 0 } }; @@ -310,4 +310,7 @@ void TheNSResources::detectCurrentUser( void ) { QString QPEEnvFile = ""; + CurrentUser.UserName = ""; + CurrentUser.HomeDir = ""; + if( getenv( "OPIEDIR" ) == 0 ) { // nothing known @@ -368,25 +371,21 @@ void TheNSResources::detectCurrentUser( void ) { // get env items out of list while( Data < DataEnd ) { - if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) { - CurrentUser.UserName = Data+8; - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = - strdup( Data ); - } else if( strncmp( Data, "HOME=", 5 ) == 0 ) { - CurrentUser.HomeDir = Data+5; - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = - strdup( Data ); - } else { + EnvVar_t * Run = EV; while( Run->Name ) { - if( strncmp( Data, Run->Name, Run->Len ) == 0 ) { + if( strncmp( Data, Run->Name, Run->Len ) == 0 && + Data[Run->Len] == '=' + ) { CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = strdup( Data ); + + if( strcmp( Run->Name, "OPIEDIR" ) == 0 ) { // put OPIEDIR in env - if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) { putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); - + } else if( strcmp( Run->Name, "HOME" ) == 0 ) { + CurrentUser.HomeDir = Data+5; + } else if( strcmp( Run->Name, "LOGNAME" ) == 0 ) { + CurrentUser.UserName = Data+8; } break; @@ -394,5 +393,4 @@ void TheNSResources::detectCurrentUser( void ) { Run ++; } - } Data += strlen( Data )+1; @@ -422,29 +420,28 @@ void TheNSResources::detectCurrentUser( void ) { } else { - CurrentUser.UserName = getenv( "LOGNAME" ); - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = - strdup( CurrentUser.UserName ); - - CurrentUser.HomeDir = getenv( "HOME" ); - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = - strdup( CurrentUser.HomeDir ); + char * X; + QString S; - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER"); - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH"); + EnvVar_t * Run = EV; + while( Run->Name ) { - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH"); + if( ( X = getenv( Run->Name ) ) ) { + Log(( "Env : %s = %s\n", Run->Name, X )); + S.sprintf( "%s=%s", Run->Name, X ); CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR"); + CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = + strdup( S.latin1() ); - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR"); - CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); - CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL"); + if( strcmp( Run->Name, "LOGNAME" ) == 0 ) { + CurrentUser.UserName = X; + } else if( strcmp( Run->Name, "HOME" ) == 0 ) { + CurrentUser.HomeDir = X; + } // regulare env var + } else { + Log(("Could not determine %s\n", Run->Name )); + } + Run ++; + } CurrentUser.Uid = getuid(); diff --git a/noncore/settings/networksettings2/networksettings2/resources.h b/noncore/settings/networksettings2/networksettings2/resources.h index 16355ba..23b120e 100644 --- a/noncore/settings/networksettings2/networksettings2/resources.h +++ b/noncore/settings/networksettings2/networksettings2/resources.h @@ -28,4 +28,7 @@ public : CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} + inline bool known( void ) + { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); } + QString UserName; QString HomeDir; @@ -100,4 +103,6 @@ public : { return ConnectionsMap; } + inline bool userKnown( void ) + { return CurrentUser.known(); } CurrentQPEUser & currentUser( void ) { return CurrentUser; } diff --git a/noncore/settings/networksettings2/nsdata.cpp b/noncore/settings/networksettings2/nsdata.cpp index d709c0a..e2dd5b5 100644 --- a/noncore/settings/networksettings2/nsdata.cpp +++ b/noncore/settings/networksettings2/nsdata.cpp @@ -16,4 +16,11 @@ NetworkSettingsData::NetworkSettingsData( void ) { new TheNSResources(); + if( ! NSResources->userKnown() ) { + Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n", + NSResources->currentUser().HomeDir.latin1(), + NSResources->currentUser().UserName.latin1() )); + return; + } + CfgFile.sprintf( "%s/Settings/NS2.conf", NSResources->currentUser().HomeDir.latin1() ); @@ -540,5 +547,6 @@ bool NetworkSettingsData::canStart( const char * Interface ) { PossibleConnections = collectPossible( Interface ); - Log( ( "Possiblilies %d\n", PossibleConnections.count() )); + Log( ( "for %s : Possiblilies %d\n", + Interface, PossibleConnections.count() )); switch( PossibleConnections.count() ) { case 0 : // no connections @@ -570,4 +578,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) { case IsUp : // also called for 'ifdown' // device is ready -> done + Log(( "%s-c%d-allowed\n", Interface, NC->number() )); printf( "%s-c%d-allowed\n", Interface, NC->number() ); return 0; @@ -576,4 +585,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) { // if we come here no alternatives are possible + Log(( "%s-cnn-disallowed\n", Interface )); printf( "%s-cnn-disallowed\n", Interface ); return 0; |