diff options
author | kris <kris@FreeBSD.org> | 2003-06-15 01:25:08 +0000 |
---|---|---|
committer | kris <kris@FreeBSD.org> | 2003-06-15 01:25:08 +0000 |
commit | a091a0b9aebe50564ea4929c92da5fcc8c2fb1d5 (patch) | |
tree | 2d43ccaea7d3ea78ef2ee7ee58105e4ca2e7cb76 /net/bing | |
parent | 4d824830c48c2b760e763585545a194571e07446 (diff) | |
download | FreeBSD-ports-a091a0b9aebe50564ea4929c92da5fcc8c2fb1d5.zip FreeBSD-ports-a091a0b9aebe50564ea4929c92da5fcc8c2fb1d5.tar.gz |
Open the raw socket early and then drop setuid root privileges. Bump
PORTREVISION.
Obtained from: OpenBSD
Diffstat (limited to 'net/bing')
-rw-r--r-- | net/bing/Makefile | 1 | ||||
-rw-r--r-- | net/bing/files/patch-bing_c | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/net/bing/Makefile b/net/bing/Makefile index 1e04652..7d71cdf 100644 --- a/net/bing/Makefile +++ b/net/bing/Makefile @@ -7,6 +7,7 @@ PORTNAME= bing PORTVERSION= 1.0.4 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= ftp://netsw.org/net/ip/audit/load/bing/ diff --git a/net/bing/files/patch-bing_c b/net/bing/files/patch-bing_c new file mode 100644 index 0000000..cbdbe8d --- /dev/null +++ b/net/bing/files/patch-bing_c @@ -0,0 +1,52 @@ +$OpenBSD: patch-bing_c,v 1.1 2002/09/17 09:06:23 pvalchev Exp $ +--- bing.c.orig Thu Jul 20 17:45:32 1995 ++++ bing.c Tue Sep 17 02:56:49 2002 +@@ -1228,17 +1228,30 @@ int main(argc, argv) + struct hoststats *hs1, *hs2; + int ntrans, nloops, bits; + int i; +- int ch, hold, recv_packlen, preload; ++ int ch, hold = 1, recv_packlen, preload; + u_char *datap, *recv_packet; + char *target1, *target2, *malloc(); + u_char ttl, loop; + #ifdef IP_OPTIONS + char rspace[3 + 4 * NROUTES + 1]; /* record route space */ + #endif +- + hs1 = &hoststats1; + hs2 = &hoststats2; + ++ if (!(proto = getprotobyname("icmp"))) { ++ (void)fprintf(stderr, "bing: unknown protocol icmp.\n"); ++ exit(1); ++ } ++ if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) { ++ perror("bing: socket"); ++ exit(1); ++ } ++ /* Revoke privileges */ ++ if (seteuid(getuid()) == -1 || setuid(getuid()) == -1) { ++ err(1, "unable to drop permissions"); ++ exit(1); ++ } ++ + preload = 0; + datap = &outpack[8 + sizeof(struct timeval)]; + while ((ch = getopt(argc, argv, "I:LRc:dDe:fh:i:l:nPp:rS:s:t:vVwz")) != EOF) +@@ -1395,15 +1408,6 @@ int main(argc, argv) + + ident = getpid() & 0xFFFF; + +- if (!(proto = getprotobyname("icmp"))) { +- (void)fprintf(stderr, "bing: unknown protocol icmp.\n"); +- exit(1); +- } +- if ((s = socket(AF_INET, SOCK_RAW, proto->p_proto)) < 0) { +- perror("bing: socket"); +- exit(1); +- } +- hold = 1; + if (options & F_SO_DEBUG) + (void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&hold, + sizeof(hold)); |