61e6d7efaa
but have sufficient permissions on /dev/bpf. Shuffle lines around so that error output in case of insufficient permissions happens before curses are initialized. Install it mode 555 instead of 550. Closes pkg/6761.
108 lines
2.4 KiB
Text
108 lines
2.4 KiB
Text
$NetBSD: patch-ab,v 1.9 2001/03/10 18:00:51 wiz 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 */
|