aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>1997-03-02 20:01:13 +0000
committerWarner Losh <imp@FreeBSD.org>1997-03-02 20:01:13 +0000
commitee2bf73496dc0e978e40fc12781b84fbd30e9282 (patch)
treeaa631cca7ae15ad3f7ffaf8b8f389e4c84f80402
parent984e3edbe26353d6089317904707e08426e906ec (diff)
downloadsrc-ee2bf73496dc0e978e40fc12781b84fbd30e9282.tar.gz
src-ee2bf73496dc0e978e40fc12781b84fbd30e9282.zip
1) Minor nits in the usage message from bde. I took out the hard tabs and
used spaces to align the second line under the program name. 2) Cache uid after call to setuid(getuid()) so we don't waste a system call for each packet with a call to getuid for the -v case. 3) Update manual to reflect new restriction on -l from last delta. Suggested by: bde, Bill Fenner
Notes
Notes: svn path=/head/; revision=23295
-rw-r--r--sbin/ping/ping.83
-rw-r--r--sbin/ping/ping.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8
index 11199b574f42..8478cb946414 100644
--- a/sbin/ping/ping.8
+++ b/sbin/ping/ping.8
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ping.8 8.2 (Berkeley) 12/11/93
-.\" $Id: ping.8,v 1.8 1997/03/01 20:19:18 wollman Exp $
+.\" $Id: ping.8,v 1.9 1997/03/02 06:32:42 imp Exp $
.\"
.Dd March 1, 1997
.Dt PING 8
@@ -120,6 +120,7 @@ is specified,
.Nm ping
sends that many packets as fast as possible before falling into its normal
mode of behavior.
+Only the super-user may use this option.
.It Fl L
Suppress loopback of multicast packets.
This flag only applies if the ping destination is a multicast address.
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index afb34abcb8d2..491cf2eb7afd 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
*/
static const char rcsid[] =
- "$Id: ping.c,v 1.17 1997/03/01 20:19:18 wollman Exp $";
+ "$Id: ping.c,v 1.18 1997/03/02 06:32:40 imp Exp $";
#endif /* not lint */
/*
@@ -138,6 +138,7 @@ char BSPACE = '\b'; /* characters written for flood */
char DOT = '.';
char *hostname;
int ident; /* process id to identify our packets */
+int uid; /* cached uid for micro-optimization */
/* counters */
long npackets; /* max packets to transmit */
@@ -201,6 +202,7 @@ main(argc, argv)
sockerrno = errno;
setuid(getuid());
+ uid = getuid();
preload = 0;
@@ -671,7 +673,7 @@ pr_pack(buf, cc, from)
#endif
struct icmp *oicmp = (struct icmp *)(oip + 1);
- if (((options & F_VERBOSE) && getuid() == 0) ||
+ if (((options & F_VERBOSE) && uid == 0) ||
(!(options & F_QUIET2) &&
(oip->ip_dst.s_addr ==
((struct sockaddr_in *)&whereto)->sin_addr.s_addr) &&
@@ -1171,7 +1173,7 @@ usage(argv0)
argv0 = strrchr(argv0,'/') + 1;
fprintf(stderr,
"usage: %s [-QRadfnqrv] [-c count] [-i wait] [-l preload] "
- "[-p pattern]\n\t\t[-s packetsize] "
+ "[-p pattern]\n [-s packetsize] "
"[host | [-L] [-I iface] [-T ttl] mcast-group]\n",
argv0);
exit(EX_USAGE);