summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-05 23:37:19 (UTC)
committer mickeyl <mickeyl>2004-01-05 23:37:19 (UTC)
commit4b272b07b86e4dce14ab71054a3741fa9ad33572 (patch) (unidiff)
tree381bf51d8e3258cbd15d36815b13dcfcac33845c
parentfa6a2e24a70be69724387355970814c0fb63701d (diff)
downloadopie-4b272b07b86e4dce14ab71054a3741fa9ad33572.zip
opie-4b272b07b86e4dce14ab71054a3741fa9ad33572.tar.gz
opie-4b272b07b86e4dce14ab71054a3741fa9ad33572.tar.bz2
add -nocheck command line option
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/ChangeLog1
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp101
2 files changed, 60 insertions, 42 deletions
diff --git a/noncore/net/wellenreiter/ChangeLog b/noncore/net/wellenreiter/ChangeLog
index 55e13fc..755ed76 100644
--- a/noncore/net/wellenreiter/ChangeLog
+++ b/noncore/net/wellenreiter/ChangeLog
@@ -1,5 +1,6 @@
1 2004-??-?? Michael Lauer <mickey@Vanille.de> 1 2004-??-?? Michael Lauer <mickey@Vanille.de>
2 2
3 * Added command line option "-nocheck" to skip non-root and dhcp tests
3 * Improved the speed reading the manufacturer list 4 * Improved the speed reading the manufacturer list
4 * GPS coordinates are now presented in the DMS (as opposed to decimal) format 5 * GPS coordinates are now presented in the DMS (as opposed to decimal) format
5 6
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 55a5260..dd757b5 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -52,63 +52,80 @@ int main( int argc, char **argv )
52 52
53 a.processEvents(); // show the window before doing the safety checks 53 a.processEvents(); // show the window before doing the safety checks
54 int result = -1; 54 int result = -1;
55 static int killed = false;
55 56
56 // root check 57 bool check = true;
57 if ( getuid() ) 58 for ( int i = 1; i < argc; ++i )
58 { 59 {
59 qWarning( QObject::tr( "Wellenreiter: trying to run as non-root!" ) ); 60 if ( !strcmp( "-nocheck", argv[i] ) )
60 result = QMessageBox::warning( w, " - Wellenreiter II - (non-root)", QObject::tr( "You have started Wellenreiter II\n" 61 {
61 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ), 62 qDebug( "-nocheck found" );
62 QMessageBox::Yes, QMessageBox::No ); 63 check = false;
63 if ( result == QMessageBox::No ) return -1; 64 break;
65 }
64 } 66 }
65 67
66 // dhcp check - NOT HERE! This really belongs as a static member to OProcess 68 if ( check )
67 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ... 69 {
70 // root check
71 if ( getuid() )
72 {
73 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"
75 "as non-root. You will have\nonly limited functionality.\nProceed anyway?" ),
76 QMessageBox::Yes, QMessageBox::No );
77 if ( result == QMessageBox::No ) return -1;
78 }
68 79
69 static int killed = false; 80 // dhcp check - NOT HERE! This really belongs as a static member to OProcess
81 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ...
70 82
71 QString line; 83 QString line;
72 QDir d = QDir( "/proc" ); 84 QDir d = QDir( "/proc" );
73 QStringList dirs = d.entryList( QDir::Dirs ); 85 QStringList dirs = d.entryList( QDir::Dirs );
74 QStringList::Iterator it; 86 QStringList::Iterator it;
75 for ( it = dirs.begin(); it != dirs.end(); ++it ) 87 for ( it = dirs.begin(); it != dirs.end(); ++it )
76 { 88 {
77 //qDebug( "next entry: %s", (const char*) *it ); 89 //qDebug( "next entry: %s", (const char*) *it );
78 QFile file( "/proc/"+*it+"/cmdline" ); 90 QFile file( "/proc/"+*it+"/cmdline" );
79 file.open( IO_ReadOnly ); 91 file.open( IO_ReadOnly );
80 if ( !file.isOpen() ) continue; 92 if ( !file.isOpen() ) continue;
81 QTextStream t( &file ); 93 QTextStream t( &file );
82 line = t.readLine(); 94 line = t.readLine();
83 //qDebug( "cmdline = %s", (const char*) line ); 95 //qDebug( "cmdline = %s", (const char*) line );
84 if ( line.contains( "dhcp" ) ) break; 96 if ( line.contains( "dhcp" ) ) break;
85 } 97 }
86 if ( line.contains( "dhcp" ) ) 98 if ( line.contains( "dhcp" ) )
87 {
88 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
89 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
90 "This can severly limit scanning!\nShould I kill it for you?" ),
91 QMessageBox::Yes, QMessageBox::No );
92 if ( result == QMessageBox::Yes )
93 { 99 {
94 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) 100 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
95 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); 101 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
96 else 102 "This can severly limit scanning!\nShould I kill it for you?" ),
97 killed = true; 103 QMessageBox::Yes, QMessageBox::No );
104 if ( result == QMessageBox::Yes )
105 {
106 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) )
107 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) );
108 else
109 killed = true;
110 }
98 } 111 }
99 } 112 }
100 113
101 a.exec(); 114 a.exec();
102 115
103 if ( killed ) 116 if ( check )
104 { 117 {
105 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No ); 118
106 if ( result == QMessageBox::Yes ) 119 if ( killed )
107 { 120 {
108 system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) ); 121 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "Restart your dhcp client?" ), QMessageBox::Yes, QMessageBox::No );
122 if ( result == QMessageBox::Yes )
123 {
124 system( QString().sprintf( "dhclient &; udhcpcd &; dhcpcd &" ) );
125 }
109 } 126 }
110 }
111 127
112 delete w; 128 delete w;
129 }
113 return 0; 130 return 0;
114} 131}