pkgsrc/net/ntop1/patches/patch-ab
2005-01-06 11:44:16 +00:00

108 lines
2.4 KiB
Text

$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 */