summaryrefslogtreecommitdiff
authorwimpie <wimpie>2004-08-19 21:48:46 (UTC)
committer wimpie <wimpie>2004-08-19 21:48:46 (UTC)
commit45616f57d3871827a247c1962e7c88699d111002 (patch) (unidiff)
tree7ad9cbe10eb624cb08a7a41944e59f0371547517
parentf58fb0a08321b6d8a9ce1bac2ce4b7eb67c27347 (diff)
downloadopie-45616f57d3871827a247c1962e7c88699d111002.zip
opie-45616f57d3871827a247c1962e7c88699d111002.tar.gz
opie-45616f57d3871827a247c1962e7c88699d111002.tar.bz2
Network_NN.cpp : had to generate full path to networksettings since
ifup (when run from hotplug) does not know about QPEDIR ... main.cpp : a bit more logging nsdata.cpp resources : optimized user detection code, report error when user could not be detected (instead of gracefull crash)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/main.cpp4
-rw-r--r--noncore/settings/networksettings2/network/network_NN.cpp5
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.cpp83
-rw-r--r--noncore/settings/networksettings2/networksettings2/resources.h5
-rw-r--r--noncore/settings/networksettings2/nsdata.cpp12
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[] ) {
96 MyArgv[3] = NULL; 96 MyArgv[3] = NULL;
97 NSResources->system().execAsUser( S, MyArgv ); 97 NSResources->system().execAsUser( S, MyArgv );
98 Log(("FAILED %s-cNN-allowed\n", argv[1] ));
98 // if we come here , failed 99 // if we come here , failed
99 printf( "%s-cNN-disallowed", argv[1] ); 100 printf( "%s-cNN-disallowed", argv[1] );
@@ -110,6 +111,9 @@ int main( int argc, char * argv[] ) {
110 { ActivateProfile AP(argv[1]); 111 { ActivateProfile AP(argv[1]);
111 if( AP.exec() == QDialog::Accepted ) { 112 if( AP.exec() == QDialog::Accepted ) {
113 Log(("%s-c%ld-allowed\n",
114 argv[1], AP.selectedProfile() ));
112 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() ); 115 printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
113 } else { 116 } else {
117 Log(("%s-c%NN-disallowed\n", argv[1] ));
114 printf( "%s-cNN-disallowed", argv[1] ); 118 printf( "%s-cNN-disallowed", argv[1] );
115 } 119 }
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 @@
1#include <qpe/qpeapplication.h>
1#include <asdevice.h> 2#include <asdevice.h>
2#include "network_NN.h" 3#include "network_NN.h"
@@ -54,5 +55,7 @@ short NetworkNetNode::generateFile( const QString & ID,
54 << NIC 55 << NIC
55 << endl; 56 << endl;
56 TS << " script networksettings2-request" 57 TS << " script "
58 << QPEApplication::qpeDir()
59 << "/bin/networksettings2-request"
57 << endl 60 << endl
58 << endl; 61 << 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 {
295 295
296static EnvVar_t EV[] = { 296static EnvVar_t EV[] = {
297 // AnEV( "HOME=" ), -> SPECIAL 297 AnEV( "HOME" ),
298 // AnEV( "LOGNAME=" ), -> SPECIAL 298 AnEV( "LOGNAME" ),
299 AnEV( "USER=" ), 299 AnEV( "USER" ),
300 AnEV( "LD_LIBRARY_PATH=" ), 300 AnEV( "LD_LIBRARY_PATH" ),
301 AnEV( "PATH=" ), 301 AnEV( "PATH" ),
302 AnEV( "QTDIR=" ), 302 AnEV( "QTDIR" ),
303 AnEV( "OPIEDIR=" ), 303 AnEV( "OPIEDIR" ),
304 AnEV( "SHELL=" ), 304 AnEV( "SHELL" ),
305 { NULL, 0 } 305 { NULL, 0 }
306}; 306};
@@ -310,4 +310,7 @@ void TheNSResources::detectCurrentUser( void ) {
310 QString QPEEnvFile = ""; 310 QString QPEEnvFile = "";
311 311
312 CurrentUser.UserName = "";
313 CurrentUser.HomeDir = "";
314
312 if( getenv( "OPIEDIR" ) == 0 ) { 315 if( getenv( "OPIEDIR" ) == 0 ) {
313 // nothing known 316 // nothing known
@@ -368,25 +371,21 @@ void TheNSResources::detectCurrentUser( void ) {
368 // get env items out of list 371 // get env items out of list
369 while( Data < DataEnd ) { 372 while( Data < DataEnd ) {
370 if( strncmp( Data, "LOGNAME=", 8 ) == 0 ) { 373
371 CurrentUser.UserName = Data+8;
372 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
373 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
374 strdup( Data );
375 } else if( strncmp( Data, "HOME=", 5 ) == 0 ) {
376 CurrentUser.HomeDir = Data+5;
377 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
378 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
379 strdup( Data );
380 } else {
381 EnvVar_t * Run = EV; 374 EnvVar_t * Run = EV;
382 while( Run->Name ) { 375 while( Run->Name ) {
383 if( strncmp( Data, Run->Name, Run->Len ) == 0 ) { 376 if( strncmp( Data, Run->Name, Run->Len ) == 0 &&
377 Data[Run->Len] == '='
378 ) {
384 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 379 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
385 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = 380 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
386 strdup( Data ); 381 strdup( Data );
382
383 if( strcmp( Run->Name, "OPIEDIR" ) == 0 ) {
387 // put OPIEDIR in env 384 // put OPIEDIR in env
388 if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) {
389 putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); 385 putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] );
390 386 } else if( strcmp( Run->Name, "HOME" ) == 0 ) {
387 CurrentUser.HomeDir = Data+5;
388 } else if( strcmp( Run->Name, "LOGNAME" ) == 0 ) {
389 CurrentUser.UserName = Data+8;
391 } 390 }
392 break; 391 break;
@@ -394,5 +393,4 @@ void TheNSResources::detectCurrentUser( void ) {
394 Run ++; 393 Run ++;
395 } 394 }
396 }
397 395
398 Data += strlen( Data )+1; 396 Data += strlen( Data )+1;
@@ -422,29 +420,28 @@ void TheNSResources::detectCurrentUser( void ) {
422 420
423 } else { 421 } else {
424 CurrentUser.UserName = getenv( "LOGNAME" ); 422 char * X;
425 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 423 QString S;
426 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
427 strdup( CurrentUser.UserName );
428
429 CurrentUser.HomeDir = getenv( "HOME" );
430 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
431 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
432 strdup( CurrentUser.HomeDir );
433 424
434 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 425 EnvVar_t * Run = EV;
435 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER"); 426 while( Run->Name ) {
436 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
437 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH");
438 427
439 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 428 if( ( X = getenv( Run->Name ) ) ) {
440 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH"); 429 Log(( "Env : %s = %s\n", Run->Name, X ));
441 430
431 S.sprintf( "%s=%s", Run->Name, X );
442 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 432 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 );
443 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR"); 433 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] =
434 strdup( S.latin1() );
444 435
445 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 436 if( strcmp( Run->Name, "LOGNAME" ) == 0 ) {
446 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR"); 437 CurrentUser.UserName = X;
447 CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); 438 } else if( strcmp( Run->Name, "HOME" ) == 0 ) {
448 CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL"); 439 CurrentUser.HomeDir = X;
440 } // regulare env var
441 } else {
442 Log(("Could not determine %s\n", Run->Name ));
443 }
444 Run ++;
445 }
449 446
450 CurrentUser.Uid = getuid(); 447 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 :
28 CurrentQPEUser() : UserName(), HomeDir(), EnvList() {} 28 CurrentQPEUser() : UserName(), HomeDir(), EnvList() {}
29 29
30 inline bool known( void )
31 { return ! HomeDir.isEmpty() && ! UserName.isEmpty(); }
32
30 QString UserName; 33 QString UserName;
31 QString HomeDir; 34 QString HomeDir;
@@ -100,4 +103,6 @@ public :
100 { return ConnectionsMap; } 103 { return ConnectionsMap; }
101 104
105 inline bool userKnown( void )
106 { return CurrentUser.known(); }
102 CurrentQPEUser & currentUser( void ) 107 CurrentQPEUser & currentUser( void )
103 { return CurrentUser; } 108 { 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 ) {
16 new TheNSResources(); 16 new TheNSResources();
17 17
18 if( ! NSResources->userKnown() ) {
19 Log(( "Cannot detect qpe user HOME=\"%s\" USER=\"%s\"\n",
20 NSResources->currentUser().HomeDir.latin1(),
21 NSResources->currentUser().UserName.latin1() ));
22 return;
23 }
24
18 CfgFile.sprintf( "%s/Settings/NS2.conf", 25 CfgFile.sprintf( "%s/Settings/NS2.conf",
19 NSResources->currentUser().HomeDir.latin1() ); 26 NSResources->currentUser().HomeDir.latin1() );
@@ -540,5 +547,6 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
540 PossibleConnections = collectPossible( Interface ); 547 PossibleConnections = collectPossible( Interface );
541 548
542 Log( ( "Possiblilies %d\n", PossibleConnections.count() )); 549 Log( ( "for %s : Possiblilies %d\n",
550 Interface, PossibleConnections.count() ));
543 switch( PossibleConnections.count() ) { 551 switch( PossibleConnections.count() ) {
544 case 0 : // no connections 552 case 0 : // no connections
@@ -570,4 +578,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
570 case IsUp : // also called for 'ifdown' 578 case IsUp : // also called for 'ifdown'
571 // device is ready -> done 579 // device is ready -> done
580 Log(( "%s-c%d-allowed\n", Interface, NC->number() ));
572 printf( "%s-c%d-allowed\n", Interface, NC->number() ); 581 printf( "%s-c%d-allowed\n", Interface, NC->number() );
573 return 0; 582 return 0;
@@ -576,4 +585,5 @@ bool NetworkSettingsData::canStart( const char * Interface ) {
576 585
577 // if we come here no alternatives are possible 586 // if we come here no alternatives are possible
587 Log(( "%s-cnn-disallowed\n", Interface ));
578 printf( "%s-cnn-disallowed\n", Interface ); 588 printf( "%s-cnn-disallowed\n", Interface );
579 return 0; 589 return 0;