Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/system.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/system.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp index f027d35..a290f08 100644 --- a/noncore/settings/networksettings2/networksettings2/system.cpp +++ b/noncore/settings/networksettings2/networksettings2/system.cpp | |||
@@ -63,7 +63,7 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
63 | char * usr = getenv("USER"); | 63 | char * usr = getenv("USER"); |
64 | 64 | ||
65 | if( S.count() == 0 ) { | 65 | if( S.count() == 0 ) { |
66 | // loophole to start shell | 66 | // close loophole to start shell |
67 | return 8888; | 67 | return 8888; |
68 | } | 68 | } |
69 | if( usr == 0 || strcmp( usr, "root" ) ) { | 69 | if( usr == 0 || strcmp( usr, "root" ) ) { |
@@ -119,12 +119,13 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
119 | return 1; | 119 | return 1; |
120 | } | 120 | } |
121 | 121 | ||
122 | int System::execAsUser( QStringList & SL ) { | 122 | int System::execAsUser( QStringList & SL, bool Synchronous ) { |
123 | MyProcess * P = new MyProcess(); | 123 | MyProcess * P = new MyProcess(); |
124 | CurrentQPEUser CU = NSResources->currentUser(); | 124 | CurrentQPEUser CU = NSResources->currentUser(); |
125 | char * usr = getenv("USER"); | 125 | char * usr = getenv("USER"); |
126 | 126 | ||
127 | if( strcmp( usr, "root" ) == 0 ) { | 127 | if( usr == 0 || |
128 | strcmp( usr, "root" ) == 0 ) { | ||
128 | // find user running qpe | 129 | // find user running qpe |
129 | if( CU.UserName.isEmpty() ) { | 130 | if( CU.UserName.isEmpty() ) { |
130 | // if we come here, the exec was not successfull | 131 | // if we come here, the exec was not successfull |
@@ -153,16 +154,21 @@ int System::execAsUser( QStringList & SL ) { | |||
153 | CU.UserName.latin1(), | 154 | CU.UserName.latin1(), |
154 | SL.join( " " ).latin1() )); | 155 | SL.join( " " ).latin1() )); |
155 | 156 | ||
156 | int rv = ( P->process().start( OProcess::DontCare, | 157 | P->setEchoMode( Synchronous ); |
157 | OProcess::NoCommunication ) ); | 158 | |
159 | bool rv = P->process().start( | ||
160 | (Synchronous) ? OProcess::Block : | ||
161 | OProcess::DontCare, | ||
162 | (Synchronous) ? OProcess::AllOutput : | ||
163 | OProcess::NoCommunication ); | ||
158 | delete P; | 164 | delete P; |
159 | 165 | ||
160 | if( rv ) { | 166 | if( ! rv ) { |
161 | // if we come here, the exec was not successfull | 167 | // if we come here, the exec was not successfull |
162 | Log(("Could not exec : %d\n", errno )); | 168 | Log(("Could not exec : %d\n", errno )); |
163 | } | 169 | } |
164 | 170 | ||
165 | return ! rv; | 171 | return rv; |
166 | } | 172 | } |
167 | 173 | ||
168 | void System::SLOT_ProcessExited( MyProcess * P ) { | 174 | void System::SLOT_ProcessExited( MyProcess * P ) { |
@@ -541,6 +547,11 @@ MyProcess::~MyProcess() { | |||
541 | } | 547 | } |
542 | 548 | ||
543 | void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { | 549 | void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { |
550 | if( EchoMode ) { | ||
551 | write( 1, Buf, len ); | ||
552 | return; | ||
553 | } | ||
554 | |||
544 | char * LB = (char *)alloca( len + 1 ); | 555 | char * LB = (char *)alloca( len + 1 ); |
545 | memcpy( LB, Buf, len ); | 556 | memcpy( LB, Buf, len ); |
546 | LB[len] = '\0'; | 557 | LB[len] = '\0'; |
@@ -562,6 +573,11 @@ void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { | |||
562 | } | 573 | } |
563 | 574 | ||
564 | void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { | 575 | void MyProcess::SLOT_Stderr( Opie::Core::OProcess * , char * Buf, int len ) { |
576 | if( EchoMode ) { | ||
577 | write( 2, Buf, len ); | ||
578 | return; | ||
579 | } | ||
580 | |||
565 | char * LB = (char *)alloca( len + 1 ); | 581 | char * LB = (char *)alloca( len + 1 ); |
566 | memcpy( LB, Buf, len ); | 582 | memcpy( LB, Buf, len ); |
567 | LB[len] = '\0'; | 583 | LB[len] = '\0'; |