Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/resources.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/resources.cpp | 109 |
1 files changed, 53 insertions, 56 deletions
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 | |||
@@ -294,14 +294,14 @@ typedef struct EnvVars { | |||
294 | #define AnEV(x) x, sizeof(x)-1 | 294 | #define AnEV(x) x, sizeof(x)-1 |
295 | 295 | ||
296 | static EnvVar_t EV[] = { | 296 | static 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 | }; |
307 | 307 | ||
@@ -309,6 +309,9 @@ void TheNSResources::detectCurrentUser( void ) { | |||
309 | // find current running qpe | 309 | // find current running qpe |
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 |
314 | { // open proc dir and find all dirs in it | 317 | { // open proc dir and find all dirs in it |
@@ -367,32 +370,27 @@ void TheNSResources::detectCurrentUser( void ) { | |||
367 | 370 | ||
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 ) { | ||
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; | ||
382 | while( Run->Name ) { | ||
383 | if( strncmp( Data, Run->Name, Run->Len ) == 0 ) { | ||
384 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
385 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | ||
386 | strdup( Data ); | ||
387 | // put OPIEDIR in env | ||
388 | if( strcmp( Run->Name, "OPIEDIR=" ) == 0 ) { | ||
389 | putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); | ||
390 | 373 | ||
391 | } | 374 | EnvVar_t * Run = EV; |
392 | break; | 375 | while( Run->Name ) { |
376 | if( strncmp( Data, Run->Name, Run->Len ) == 0 && | ||
377 | Data[Run->Len] == '=' | ||
378 | ) { | ||
379 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | ||
380 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | ||
381 | strdup( Data ); | ||
382 | |||
383 | if( strcmp( Run->Name, "OPIEDIR" ) == 0 ) { | ||
384 | // put OPIEDIR in env | ||
385 | putenv( CurrentUser.EnvList[CurrentUser.EnvList.size()-1] ); | ||
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; | ||
393 | } | 390 | } |
394 | Run ++; | 391 | break; |
395 | } | 392 | } |
393 | Run ++; | ||
396 | } | 394 | } |
397 | 395 | ||
398 | Data += strlen( Data )+1; | 396 | Data += strlen( Data )+1; |
@@ -421,31 +419,30 @@ void TheNSResources::detectCurrentUser( void ) { | |||
421 | } | 419 | } |
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] = | 424 | |
427 | strdup( CurrentUser.UserName ); | 425 | EnvVar_t * Run = EV; |
428 | 426 | while( Run->Name ) { | |
429 | CurrentUser.HomeDir = getenv( "HOME" ); | 427 | |
430 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 428 | if( ( X = getenv( Run->Name ) ) ) { |
431 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = | 429 | Log(( "Env : %s = %s\n", Run->Name, X )); |
432 | strdup( CurrentUser.HomeDir ); | 430 | |
433 | 431 | S.sprintf( "%s=%s", Run->Name, X ); | |
434 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 432 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); |
435 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("USER"); | 433 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = |
436 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 434 | strdup( S.latin1() ); |
437 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("LD_LIBRARY_PATH"); | 435 | |
438 | 436 | if( strcmp( Run->Name, "LOGNAME" ) == 0 ) { | |
439 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 437 | CurrentUser.UserName = X; |
440 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("PATH"); | 438 | } else if( strcmp( Run->Name, "HOME" ) == 0 ) { |
441 | 439 | CurrentUser.HomeDir = X; | |
442 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 440 | } // regulare env var |
443 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("QTDIR"); | 441 | } else { |
444 | 442 | Log(("Could not determine %s\n", Run->Name )); | |
445 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 443 | } |
446 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("OPIEDIR"); | 444 | Run ++; |
447 | CurrentUser.EnvList.resize( CurrentUser.EnvList.size()+1 ); | 445 | } |
448 | CurrentUser.EnvList[CurrentUser.EnvList.size()-1] = getenv("SHELL"); | ||
449 | 446 | ||
450 | CurrentUser.Uid = getuid(); | 447 | CurrentUser.Uid = getuid(); |
451 | CurrentUser.Gid = getgid(); | 448 | CurrentUser.Gid = getgid(); |