Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-3-0]: src/sbin/ping Pull up following revision(s) (requested by g...



details:   https://anonhg.NetBSD.org/src/rev/d830ff99f942
branches:  netbsd-3-0
changeset: 579438:d830ff99f942
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Sun Aug 26 19:55:21 2007 +0000

description:
Pull up following revision(s) (requested by ghen in ticket #1818):
        sbin/ping/ping.c: revisions 1.83 - 1.85
PR/28741: Michael Santos: ping does [not] drop root privileges

diffstat:

 sbin/ping/ping.c |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (51 lines):

diff -r 67cb8e339080 -r d830ff99f942 sbin/ping/ping.c
--- a/sbin/ping/ping.c  Sun Aug 26 19:51:46 2007 +0000
+++ b/sbin/ping/ping.c  Sun Aug 26 19:55:21 2007 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ping.c,v 1.77 2004/05/13 20:27:38 kleink Exp $ */
+/*     $NetBSD: ping.c,v 1.77.4.1 2007/08/26 19:55:21 bouyer Exp $     */
 
 /*
  * Copyright (c) 1989, 1993
@@ -58,7 +58,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.77 2004/05/13 20:27:38 kleink Exp $");
+__RCSID("$NetBSD: ping.c,v 1.77.4.1 2007/08/26 19:55:21 bouyer Exp $");
 #endif
 
 #include <stdio.h>
@@ -262,6 +262,14 @@
 #endif
   
 
+       if ((s = cap_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
+               err(1, "Cannot create socket");
+       if ((sloop = cap_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
+               err(1, "Cannot create socket");
+
+       if (setuid(getuid()) == -1)
+               err(1, "setuid");
+
        setprogname(argv[0]);
 
 #ifndef IPSEC
@@ -461,8 +469,6 @@
 
        ident = arc4random() & 0xFFFF;
 
-       if ((s = cap_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
-               err(1, "Cannot create socket");
        if (options & SO_DEBUG) {
                if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
                               (char *)&on, sizeof(on)) == -1)
@@ -474,8 +480,6 @@
                        warn("SO_DONTROUTE");
        }
 
-       if ((sloop = cap_socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0)
-               err(1, "Cannot create socket");
        if (options & SO_DEBUG) {
                if (setsockopt(sloop, SOL_SOCKET, SO_DEBUG,
                               (char *)&on, sizeof(on)) == -1)



Home | Main Index | Thread Index | Old Index