summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/runtests.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/runtests.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/runtests.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/noncore/settings/networksettings/ppp/runtests.cpp b/noncore/settings/networksettings/ppp/runtests.cpp
index 83ef2ea..5548601 100644
--- a/noncore/settings/networksettings/ppp/runtests.cpp
+++ b/noncore/settings/networksettings/ppp/runtests.cpp
@@ -23,50 +23,48 @@
23 * License along with this program; if not, write to the Free 23 * License along with this program; if not, write to the Free
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include <qdir.h> 27#include <qdir.h>
28#include "runtests.h" 28#include "runtests.h"
29#include <ctype.h> 29#include <ctype.h>
30#include <unistd.h> 30#include <unistd.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33#include <stdlib.h> 33#include <stdlib.h>
34#include <sys/types.h> 34#include <sys/types.h>
35#include <pwd.h> 35#include <pwd.h>
36#include <netinet/in.h> 36#include <netinet/in.h>
37 37
38#ifdef HAVE_RESOLV_H 38#ifdef HAVE_RESOLV_H
39#include <arpa/nameser.h> 39#include <arpa/nameser.h>
40#include <resolv.h> 40#include <resolv.h>
41#endif 41#endif
42 42
43#ifndef _PATH_RESCONF 43#ifndef _PATH_RESCONF
44#define _PATH_RESCONF "/etc/resolv.conf" 44#define _PATH_RESCONF "/etc/resolv.conf"
45#endif 45#endif
46 46
47//#include <klocale.h>
48#define i18n QObject::tr
49#include "pppdata.h" 47#include "pppdata.h"
50 48
51// initial effective uid (main.cpp) 49// initial effective uid (main.cpp)
52extern uid_t euid; 50extern uid_t euid;
53 51
54// secure pppd location (opener.cpp) 52// secure pppd location (opener.cpp)
55extern const char* pppdPath(); 53extern const char* pppdPath();
56 54
57// shamelessly stolen from pppd-2.3.5 55// shamelessly stolen from pppd-2.3.5
58/******************************************************************** 56/********************************************************************
59 * 57 *
60 * Internal routine to decode the version.modification.patch level 58 * Internal routine to decode the version.modification.patch level
61 */ 59 */
62 60
63static void decode_version (const char *_buf, int *version, 61static void decode_version (const char *_buf, int *version,
64 int *modification, int *patch) 62 int *modification, int *patch)
65 { 63 {
66 char *buffer = qstrdup(_buf); 64 char *buffer = qstrdup(_buf);
67 char *buf = buffer; 65 char *buf = buffer;
68 *version = (int) strtoul (buf, &buf, 10); 66 *version = (int) strtoul (buf, &buf, 10);
69 *modification = 0; 67 *modification = 0;
70 *patch = 0; 68 *patch = 0;
71 69
72 if (*buf == '.') 70 if (*buf == '.')
@@ -196,84 +194,84 @@ int runTests() {
196 FILE *f; 194 FILE *f;
197 if((f = fopen("/etc/kppp.allow", "r")) != NULL) { 195 if((f = fopen("/etc/kppp.allow", "r")) != NULL) {
198 char buf[2048]; // safe 196 char buf[2048]; // safe
199 while(f != NULL && !feof(f)) { 197 while(f != NULL && !feof(f)) {
200 if(fgets(buf, sizeof(buf), f) != NULL) { 198 if(fgets(buf, sizeof(buf), f) != NULL) {
201 QString s(buf); 199 QString s(buf);
202 200
203 s = s.stripWhiteSpace(); 201 s = s.stripWhiteSpace();
204 if(s[0] == '#' || s.length() == 0) 202 if(s[0] == '#' || s.length() == 0)
205 continue; 203 continue;
206 204
207 if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) { 205 if((uid_t)uidFromName(QFile::encodeName(s)) == getuid()) {
208 access = TRUE; 206 access = TRUE;
209 fclose(f); 207 fclose(f);
210 f = NULL; 208 f = NULL;
211 } 209 }
212 } 210 }
213 } 211 }
214 if(f) 212 if(f)
215 fclose(f); 213 fclose(f);
216 } 214 }
217 215
218 if(!access) { 216 if(!access) {
219 QMessageBox::warning(0,"error", 217 QMessageBox::warning(0,"error",
220 i18n("You're not allowed to dial out with " 218 QObject::tr("You're not allowed to dial out with "
221 "kppp.\nContact your system administrator.")); 219 "kppp.\nContact your system administrator."));
222 return TEST_CRITICAL; 220 return TEST_CRITICAL;
223 } 221 }
224 } 222 }
225 223
226 // Test 1: search the pppd binary 224 // Test 1: search the pppd binary
227 const char *f = pppdPath(); 225 const char *f = pppdPath();
228 226
229 if(!f) { 227 if(!f) {
230 QMessageBox::warning(0,"error", 228 QMessageBox::warning(0,"error",
231 i18n("Cannot find the PPP daemon!\n" 229 QObject::tr("Cannot find the PPP daemon!\n"
232 "Make sure that pppd is installed.")); 230 "Make sure that pppd is installed."));
233 warning++; 231 warning++;
234 } 232 }
235 233
236 // Test 2: check access to the pppd binary 234 // Test 2: check access to the pppd binary
237 if(f) { 235 if(f) {
238#if 0 236#if 0
239 if(access(f, X_OK) != 0 /* && geteuid() != 0 */) { 237 if(access(f, X_OK) != 0 /* && geteuid() != 0 */) {
240 KMessageBox::warning(0, 238 KMessageBox::warning(0,
241 i18n("You do not have the permission " 239 QObject::tr("You do not have the permission "
242 "to start pppd!\n" 240 "to start pppd!\n"
243 "Contact your system administrator " 241 "Contact your system administrator "
244 "and ask to get access to pppd.")); 242 "and ask to get access to pppd."));
245 return TEST_CRITICAL; 243 return TEST_CRITICAL;
246 } 244 }
247#endif 245#endif
248 246
249 if(geteuid() != 0) { 247 if(geteuid() != 0) {
250 struct stat st; 248 struct stat st;
251 stat(f, &st); 249 stat(f, &st);
252 if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) { 250 if(st.st_uid != 0 || (st.st_mode & S_ISUID) == 0) {
253 QMessageBox::warning(0,"error", 251 QMessageBox::warning(0,"error",
254 i18n("You don't have sufficient permission to run\n" 252 QObject::tr("You don't have sufficient permission to run\n"
255 "%1\n" 253 "%1\n"
256 "Please make sure that kppp is owned by root " 254 "Please make sure that kppp is owned by root "
257 "and has the SUID bit set.").arg(f)); 255 "and has the SUID bit set.").arg(f));
258 warning++; 256 warning++;
259 } 257 }
260 } 258 }
261 } 259 }
262 260
263 // Test 5: check for existence of /etc/resolv.conf 261 // Test 5: check for existence of /etc/resolv.conf
264 if (access(_PATH_RESCONF, R_OK) != 0) { 262 if (access(_PATH_RESCONF, R_OK) != 0) {
265 QString file = _PATH_RESCONF" "; 263 QString file = _PATH_RESCONF" ";
266 QString msgstr = i18n("%1 is missing or can't be read!\n" 264 QString msgstr = QObject::tr("%1 is missing or can't be read!\n"
267 "Ask your system administrator to create " 265 "Ask your system administrator to create "
268 "this file (can be empty) with appropriate " 266 "this file (can be empty) with appropriate "
269 "read and write permissions.").arg(file); 267 "read and write permissions.").arg(file);
270 QMessageBox::warning(0, "errror", msgstr); 268 QMessageBox::warning(0, "errror", msgstr);
271 warning ++; 269 warning ++;
272 } 270 }
273 271
274 if(warning == 0) 272 if(warning == 0)
275 return TEST_OK; 273 return TEST_OK;
276 else 274 else
277 return TEST_WARNING; 275 return TEST_WARNING;
278} 276}
279 277