Diffstat (limited to 'noncore/net/wellenreiter/gui/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/gui/main.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp index 8d4ef57..03da135 100644 --- a/noncore/net/wellenreiter/gui/main.cpp +++ b/noncore/net/wellenreiter/gui/main.cpp | |||
@@ -22,2 +22,16 @@ | |||
22 | 22 | ||
23 | #include <qmessagebox.h> | ||
24 | #include <qstringlist.h> | ||
25 | |||
26 | // ==> OProcess | ||
27 | #include <qdir.h> | ||
28 | #include <qfileinfo.h> | ||
29 | #include <qregexp.h> | ||
30 | #include <qtextstream.h> | ||
31 | |||
32 | #include <errno.h> | ||
33 | #include <signal.h> | ||
34 | #include <string.h> | ||
35 | #include <unistd.h> | ||
36 | |||
23 | int main( int argc, char **argv ) | 37 | int main( int argc, char **argv ) |
@@ -36,2 +50,47 @@ int main( int argc, char **argv ) | |||
36 | #endif | 50 | #endif |
51 | |||
52 | a.processEvents(); // show the window before doing the safety checks | ||
53 | int result = -1; | ||
54 | |||
55 | // root check | ||
56 | if ( getuid() ) | ||
57 | { | ||
58 | qWarning( "Wellenreiter: trying to run as non-root!" ); | ||
59 | result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", "You have started Wellenreiter II\n" | ||
60 | "as non-root. You will have\nonly limited functionality.\nProceed anyway?", | ||
61 | QMessageBox::Yes, QMessageBox::No ); | ||
62 | if ( result == QMessageBox::No ) return -1; | ||
63 | } | ||
64 | |||
65 | // dhcp check - NOT HERE! This really belongs as a static member to OProcess | ||
66 | // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... | ||
67 | |||
68 | QString line; | ||
69 | QDir d = QDir( "/proc" ); | ||
70 | QStringList dirs = d.entryList( QDir::Dirs ); | ||
71 | QStringList::Iterator it; | ||
72 | for ( it = dirs.begin(); it != dirs.end(); ++it ) | ||
73 | { | ||
74 | //qDebug( "next entry: %s", (const char*) *it ); | ||
75 | QFile file( "/proc/"+*it+"/cmdline" ); | ||
76 | file.open( IO_ReadOnly ); | ||
77 | if ( !file.isOpen() ) continue; | ||
78 | QTextStream t( &file ); | ||
79 | line = t.readLine(); | ||
80 | //qDebug( "cmdline = %s", (const char*) line ); | ||
81 | if ( line.contains( "dhcp" ) ) break; | ||
82 | } | ||
83 | if ( line.contains( "dhcp" ) ) | ||
84 | { | ||
85 | qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() ); | ||
86 | result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", "You have a dhcp client running.\n" | ||
87 | "This can severly limit scanning!\nShould I kill it for you?", | ||
88 | QMessageBox::Yes, QMessageBox::No ); | ||
89 | if ( result == QMessageBox::Yes ) | ||
90 | { | ||
91 | if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) | ||
92 | qWarning( "Wellenreiter: can't kill process (%s)", result, strerror( errno ) ); | ||
93 | } | ||
94 | } | ||
95 | |||
37 | a.exec(); | 96 | a.exec(); |