summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp32
1 files changed, 4 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 702a7cc..d32b362 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -1,43 +1,38 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "mainwindow.h" 16#include "mainwindow.h"
17#ifdef QWS 17#ifdef QWS
18#include <opie2/oapplication.h> 18#include <opie2/oapplication.h>
19#include <opie2/oprocess.h>
19#else 20#else
20#include <qapplication.h> 21#include <qapplication.h>
21#endif 22#endif
22 23
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qstringlist.h> 25#include <qstringlist.h>
25 26
26// ==> OProcess
27#include <qdir.h>
28#include <qfileinfo.h>
29#include <qregexp.h>
30#include <qtextstream.h>
31
32#include <errno.h> 27#include <errno.h>
33#include <signal.h> 28#include <signal.h>
34#include <string.h> 29#include <string.h>
35#include <unistd.h> 30#include <unistd.h>
36 31
37int main( int argc, char **argv ) 32int main( int argc, char **argv )
38{ 33{
39 #ifdef QWS 34 #ifdef QWS
40 OApplication a( argc, argv, "Wellenreiter II" ); 35 OApplication a( argc, argv, "Wellenreiter II" );
41 #else 36 #else
42 QApplication a( argc, argv ); 37 QApplication a( argc, argv );
43 #endif 38 #endif
@@ -68,51 +63,32 @@ int main( int argc, char **argv )
68 if ( check ) 63 if ( check )
69 { 64 {
70 // root check 65 // root check
71 if ( getuid() ) 66 if ( getuid() )
72 { 67 {
73 qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); 68 qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) );
74 result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" 69 result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n"
75 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), 70 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ),
76 QMessageBox::Yes, QMessageBox::No ); 71 QMessageBox::Yes, QMessageBox::No );
77 if ( result == QMessageBox::No ) return -1; 72 if ( result == QMessageBox::No ) return -1;
78 } 73 }
79 74
80 // dhcp check - NOT HERE! This really belongs as a static member to OProcess 75 if ( OProcess::processPID( "dhcpc" ) )
81 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ...
82
83 QString line;
84 QDir d = QDir( "/proc" );
85 QStringList dirs = d.entryList( QDir::Dirs );
86 QStringList::Iterator it;
87 for ( it = dirs.begin(); it != dirs.end(); ++it )
88 {
89 //qDebug( "next entry: %s", (const char*) *it );
90 QFile file( "/proc/"+*it+"/cmdline" );
91 file.open( IO_ReadOnly );
92 if ( !file.isOpen() ) continue;
93 QTextStream t( &file );
94 line = t.readLine();
95 //qDebug( "cmdline = %s", (const char*) line );
96 if ( line.contains( "dhcp" ) ) break;
97 }
98 if ( line.contains( "dhcp" ) )
99 { 76 {
100 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
101 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" 77 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
102 "This can severly limit scanning!\nShould I kill it for you?" ), 78 "This can severly limit scanning!\nShould I kill it for you?" ),
103 QMessageBox::Yes, QMessageBox::No ); 79 QMessageBox::Yes, QMessageBox::No );
104 if ( result == QMessageBox::Yes ) 80 if ( result == QMessageBox::Yes )
105 { 81 {
106 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) 82 if ( -1 == ::kill( OProcess::processPID( "dhcpc" ), SIGTERM ) )
107 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); 83 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) );
108 else 84 else
109 killed = true; 85 killed = true;
110 } 86 }
111 } 87 }
112 } 88 }
113 89
114 a.exec(); 90 a.exec();
115 91
116 if ( check ) 92 if ( check )
117 { 93 {
118 94