summaryrefslogtreecommitdiff
path: root/net/ntop1/patches/patch-ab
blob: 9766ba24a5082e3a45bb5583144d0667101f6186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
$NetBSD: patch-ab,v 1.1.1.1 2005/01/06 11:44:16 adam Exp $

--- ntop.c.orig	Wed Apr 28 19:49:00 1999
+++ ntop.c
@@ -254,7 +254,7 @@
   initIPServices();
 
 #ifndef WIN32
-  while ((op = getopt(argc, argv, "df:F:hr:i:p:l:nw:m:")) != EOF)
+  while ((op = getopt(argc, argv, "df:F:hr:i:p:l:nm:")) != EOF)
     switch (op) {
 
 #ifndef WIN32
@@ -324,6 +324,7 @@
       numericFlag++;
       break;
 
+#if 0
     case 'w':
       if(!isdigit(optarg[0])) {
 	printf("FATAL ERROR: flag -w expects a numeric argument.\n");
@@ -332,6 +333,7 @@
       webMode++;
       webPort = atoi(optarg);
       break;
+#endif
 
     default:
       usage(0);
@@ -348,11 +350,6 @@
 #endif
 
 #ifndef WIN32
-  if((rFileName == NULL) && (getuid () && geteuid ()) || setuid (0)) {
-    printf("Sorry, you must be superuser in order to run ntop.\n");
-    return(-1);
-  }
-  
   if(daemonMode && (!webMode)) {
     printf("WARNING: -d is incompatible with interactive mode.\n");
   } else if(daemonMode)
@@ -392,13 +389,30 @@
 #ifndef WIN32
   /* Determine the device name if not specified */
   if (device == NULL && (device = pcap_lookupdev(ebuf)) == NULL) {
-    printf(ebuf);
+    printf("%s\n", ebuf);
     return(-1);
   }
 
   getLocalHostAddress(&localHostAddress, device);
 
   if(rFileName == NULL) {
+    /* Fire up libpcap */
+    pcapPtr = pcap_open_live(device, DEFAULT_SNAPLEN, !pflag, 1000, ebuf);
+  } else {
+    pcapPtr = pcap_open_offline(rFileName, ebuf);
+  }
+
+  if (pcapPtr == NULL) {
+    printf("%s\n", ebuf);
+    return(-1);
+  }
+
+  if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
+    printf("%s\n", ebuf);
+    return(-1);
+  }
+
+  if(rFileName == NULL) {
     if(webMode) {
       (void)fprintf(stderr, "ntop v.%s %s [%s]"
 #ifndef WIN32
@@ -418,21 +432,6 @@
       init_curses();
     }
 #endif
-
-    /* Fire up libpcap */
-    pcapPtr = pcap_open_live(device, DEFAULT_SNAPLEN, !pflag, 1000, ebuf);
-  } else {
-    pcapPtr = pcap_open_offline(rFileName, ebuf);
-  }
-
-  if (pcapPtr == NULL) {
-    printf(ebuf);
-    return(-1);
-  }
-
-  if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
-    printf(ebuf);
-    return(-1);
   }
 #else /* WIN32 */
   printf("ntop v.%s %s [%s]"
@@ -458,12 +457,6 @@
     free(localAddresses);
     localAddresses = NULL;
   }
-
-#ifndef WIN32
-  /* Now that the socket is open, throw away potential setuid/setgid */
-  (void)setgid(getgid());
-  (void)setuid(getuid());
-#endif
 
 #ifndef WIN32
   /* get datalink type */