summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/system.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/system.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/system.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/system.cpp b/noncore/settings/networksettings2/networksettings2/system.cpp
index 9512579..e642c08 100644
--- a/noncore/settings/networksettings2/networksettings2/system.cpp
+++ b/noncore/settings/networksettings2/networksettings2/system.cpp
@@ -35,24 +35,25 @@ static char Dig2Hex[] = {
35 '0', '1', '2', '3', 35 '0', '1', '2', '3',
36 '4', '5', '6', '7', 36 '4', '5', '6', '7',
37 '8', '9', 'A', 'B', 37 '8', '9', 'A', 'B',
38 'C', 'D', 'E', 'F' 38 'C', 'D', 'E', 'F'
39}; 39};
40 40
41// get HIGH nibble of byte 41// get HIGH nibble of byte
42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)] 42#define HN(x) Dig2Hex[(((x)&0xf0)>>4)]
43// get LOW nibble of byte 43// get LOW nibble of byte
44#define LN(x) Dig2Hex[((x)&0x0f)] 44#define LN(x) Dig2Hex[((x)&0x0f)]
45 45
46System::System( void ) : QObject(), ProbedInterfaces() { 46System::System( void ) : QObject(), ProbedInterfaces() {
47 ProcDevNet = 0;
47} 48}
48 49
49System::~System( void ) { 50System::~System( void ) {
50 if( ProcDevNet ) 51 if( ProcDevNet )
51 delete ProcDevNet; 52 delete ProcDevNet;
52} 53}
53 54
54QDict<InterfaceInfo> & System::interfaces( void ) { 55QDict<InterfaceInfo> & System::interfaces( void ) {
55 if( ProbedInterfaces.count() == 0 ) { 56 if( ProbedInterfaces.count() == 0 ) {
56 probeInterfaces(); 57 probeInterfaces();
57 } 58 }
58 return ProbedInterfaces; 59 return ProbedInterfaces;
@@ -100,31 +101,31 @@ int System::runAsRoot( QStringList & S, MyProcess * Prc ) {
100 } 101 }
101 102
102 P->process() << S; 103 P->process() << S;
103 104
104 Log(("Executing %s\n", S.join( " " ).latin1() )); 105 Log(("Executing %s\n", S.join( " " ).latin1() ));
105 106
106 if( ! P->process().start( OProcess::DontCare, 107 if( ! P->process().start( OProcess::DontCare,
107 OProcess::AllOutput ) ) { 108 OProcess::AllOutput ) ) {
108 owarn << "Error starting " << S << oendl; 109 owarn << "Error starting " << S << oendl;
109 if( ! Prc ) 110 if( ! Prc )
110 delete P; 111 delete P;
111 // error starting app 112 // error starting app
112 return 1; 113 return 0;
113 } 114 }
114 owarn << "Started " << S << oendl; 115 owarn << "Started " << S << oendl;
115 } 116 }
116 117
117 // all is fine 118 // all is fine
118 return 0; 119 return 1;
119} 120}
120 121
121int System::execAsUser( QStringList & SL ) { 122int System::execAsUser( QStringList & SL ) {
122 MyProcess * P = new MyProcess(); 123 MyProcess * P = new MyProcess();
123 CurrentQPEUser CU = NSResources->currentUser(); 124 CurrentQPEUser CU = NSResources->currentUser();
124 char * usr = getenv("USER"); 125 char * usr = getenv("USER");
125 126
126 if( strcmp( usr, "root" ) == 0 ) { 127 if( strcmp( usr, "root" ) == 0 ) {
127 // find user running qpe 128 // find user running qpe
128 if( CU.UserName.isEmpty() ) { 129 if( CU.UserName.isEmpty() ) {
129 // if we come here, the exec was not successfull 130 // if we come here, the exec was not successfull
130 Log(("User not known \n" )); 131 Log(("User not known \n" ));
@@ -152,25 +153,25 @@ int System::execAsUser( QStringList & SL ) {
152 CU.UserName.latin1(), 153 CU.UserName.latin1(),
153 SL.join( " " ).latin1() )); 154 SL.join( " " ).latin1() ));
154 155
155 int rv = ( P->process().start( OProcess::DontCare, 156 int rv = ( P->process().start( OProcess::DontCare,
156 OProcess::NoCommunication ) ); 157 OProcess::NoCommunication ) );
157 delete P; 158 delete P;
158 159
159 if( rv ) { 160 if( rv ) {
160 // if we come here, the exec was not successfull 161 // if we come here, the exec was not successfull
161 Log(("Could not exec : %d\n", errno )); 162 Log(("Could not exec : %d\n", errno ));
162 } 163 }
163 164
164 return rv; 165 return ! rv;
165} 166}
166 167
167void System::SLOT_ProcessExited( MyProcess * P ) { 168void System::SLOT_ProcessExited( MyProcess * P ) {
168 QString R; 169 QString R;
169 170
170 for( QValueListConstIterator<QCString> it = P->process().args().begin(); 171 for( QValueListConstIterator<QCString> it = P->process().args().begin();
171 it != P->process().args().end(); 172 it != P->process().args().end();
172 ++it ) { 173 ++it ) {
173 R += (*it); 174 R += (*it);
174 R += " "; 175 R += " ";
175 } 176 }
176 177