Since ntop isn't set?id anymore, make it work even if you're not root,

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.
This commit is contained in:
wiz 2001-03-10 18:00:51 +00:00
parent 2f40bddf6b
commit 61e6d7efaa
3 changed files with 75 additions and 20 deletions

View file

@ -1,5 +1,5 @@
$NetBSD: patch-sum,v 1.4 2001/01/07 02:25:35 wiz Exp $ $NetBSD: patch-sum,v 1.5 2001/03/10 18:00:51 wiz Exp $
MD5 (patch-aa) = bc35939bcacdbd55e8c5b6808b634cd3 SHA1 (patch-aa) = 1d9002e962061ddc174cb0f904f868ca91070465
MD5 (patch-ab) = 5f341d4a6d156c744269a62d433d1471 SHA1 (patch-ab) = f0d6be0bde866803f25da5ace473e244514e3d14
MD5 (patch-ac) = 5d31221bbf026ae27f9b408889082b78 SHA1 (patch-ac) = 1f32b536470e77bf6e029d0933bb375c1b08aee0

View file

@ -1,4 +1,4 @@
$NetBSD: patch-aa,v 1.5 2000/10/20 11:03:38 abs Exp $ $NetBSD: patch-aa,v 1.6 2001/03/10 18:00:51 wiz Exp $
--- Makefile.in.orig Mon May 3 09:03:10 1999 --- Makefile.in.orig Mon May 3 09:03:10 1999
+++ Makefile.in +++ Makefile.in
@ -16,7 +16,7 @@ $NetBSD: patch-aa,v 1.5 2000/10/20 11:03:38 abs Exp $
install: install:
- $(INSTALL) -m 6550 $(PROG) $(DESTDIR)$(BINDEST)/$(PROG) - $(INSTALL) -m 6550 $(PROG) $(DESTDIR)$(BINDEST)/$(PROG)
+ $(INSTALL) -m 550 $(PROG) $(DESTDIR)$(BINDEST)/$(PROG) + $(INSTALL) -m 555 $(PROG) $(DESTDIR)$(BINDEST)/$(PROG)
install-man: install-man:
$(INSTALL) -m 444 $(PROG).8 $(DESTDIR)$(MANDEST)/man8/$(PROG).8 $(INSTALL) -m 444 $(PROG).8 $(DESTDIR)$(MANDEST)/man8/$(PROG).8

View file

@ -1,6 +1,6 @@
$NetBSD: patch-ab,v 1.8 2000/10/20 11:03:38 abs Exp $ $NetBSD: patch-ab,v 1.9 2001/03/10 18:00:51 wiz Exp $
--- ntop.c.orig Wed Apr 28 18:49:00 1999 --- ntop.c.orig Wed Apr 28 19:49:00 1999
+++ ntop.c +++ ntop.c
@@ -254,7 +254,7 @@ @@ -254,7 +254,7 @@
initIPServices(); initIPServices();
@ -27,27 +27,82 @@ $NetBSD: patch-ab,v 1.8 2000/10/20 11:03:38 abs Exp $
default: default:
usage(0); usage(0);
@@ -392,7 +394,7 @@ @@ -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 #ifndef WIN32
/* Determine the device name if not specified */ /* Determine the device name if not specified */
if (device == NULL && (device = pcap_lookupdev(ebuf)) == NULL) { if (device == NULL && (device = pcap_lookupdev(ebuf)) == NULL) {
- printf(ebuf); - printf(ebuf);
+ printf("%s", ebuf); + printf("%s\n", ebuf);
return(-1); return(-1);
} }
@@ -426,12 +428,12 @@ getLocalHostAddress(&localHostAddress, device);
}
if (pcapPtr == NULL) { 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); - printf(ebuf);
+ printf("%s", ebuf); - return(-1);
return(-1); - }
} -
- if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
if (pcap_lookupnet(device, &localnet, &netmask, ebuf) < 0) {
- printf(ebuf); - printf(ebuf);
+ printf("%s", ebuf); - return(-1);
return(-1);
} }
#else /* WIN32 */ #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 */