Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/system.cpp') (more/less context) (ignore 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 | |||
@@ -64,5 +64,5 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
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 | } |
@@ -120,10 +120,11 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) { | |||
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() ) { |
@@ -154,14 +155,19 @@ int System::execAsUser( QStringList & SL ) { | |||
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 | ||
@@ -542,4 +548,9 @@ MyProcess::~MyProcess() { | |||
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 ); |
@@ -563,4 +574,9 @@ void MyProcess::SLOT_Stdout( Opie::Core::OProcess * , char * Buf, int len ) { | |||
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 ); |