Debian bug report logs - #1660
ping doesn't work with broadcast addresses

Package: netbase; Reported by: Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>; Done: "Peter Tobias" <tobias@server.et-inf.fho-emden.de>.

Message received at debian-bugs-done:


From server.et-inf.fho-emden.de!tobias Tue Oct 17 16:10:20 1995
Return-Path: <tobias@server.et-inf.fho-emden.de>
Received: from pixar.com by mongo.pixar.com with smtp
	(Smail3.1.28.1 #15) id m0t5L9D-0005zAC; Tue, 17 Oct 95 16:10 PDT
Received: from server.et-inf.fho-emden.de by pixar.com with SMTP id AA05050
  (5.67b/IDA-1.5 for debian-bugs-done-pipe@mongo.pixar.com); Tue, 17 Oct 1995 16:09:47 -0700
Received: by server.et-inf.fho-emden.de (5.65/DEC-Ultrix/4.3)
	id AA26940; Wed, 18 Oct 1995 00:00:29 +0100
Message-Id: <9510172300.AA26940@server.et-inf.fho-emden.de>
Subject: Re: Bug#1660: ping doesn't work with broadcast addresses
To: marekm@i17linuxb.ists.pwr.wroc.pl
Date: Wed, 18 Oct 1995 00:00:26 +0100 (MET)
From: "Peter Tobias" <tobias@server.et-inf.fho-emden.de>
Cc: debian-bugs-done@pixar.com
Reply-To: tobias@et-inf.fho-emden.de
In-Reply-To: <199510122057.VAA32259@i17linuxb.ists.pwr.wroc.pl> from "Marek Michalkiewicz" at Oct 12, 95 09:57:39 pm
X-Mailer: ELM [version 2.4 PL23]
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
Content-Length: 1140      

Marek Michalkiewicz wrote:
> Package: netbase
> Version: 1.17-1
> 
> On several other systems I can use ping with a broadcast address to see
> what machines on the local network are up and running.  This doesn't
> work on Linux - I get "sendto: Permission denied".  It is necessary to
> set the SO_BROADCAST socket option for this to work.  Similar change
> would probably be nice for fping too.
> 
> While we are at it, can we make ping, traceroute (and maybe some other
> setuid programs which can run for a long time and need root privileges
> only at startup), drop root privileges when no longer needed?  Just do
> setuid(getuid()) - the advantage is that ps shows who is running ping.

I'll close this bug report with this message. All bugs you mentioned
have been fixed.


Peter
 
PS: fping does not support broadcast pings at all. According to the
    author is this behavior intentional.

-- 
 Peter Tobias                                EMail:
 Fachhochschule Ostfriesland                 tobias@et-inf.fho-emden.de
 Fachbereich Elektrotechnik und Informatik   tobias@perseus.fho-emden.de
 Constantiaplatz 4, 26723 Emden, Germany

Notification sent to Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>:
Bug acknowledged by developer. Full text available.
Reply sent to tobias@et-inf.fho-emden.de:
You have taken responsibility. Full text available.

Message received at debian-bugs:


From i17linuxb.ists.pwr.wroc.pl!marekm Thu Oct 12 13:57:52 1995
Return-Path: <marekm@i17linuxb.ists.pwr.wroc.pl>
Received: from pixar.com by mongo.pixar.com with smtp
	(Smail3.1.28.1 #15) id m0t3UhM-000B6jC; Thu, 12 Oct 95 13:57 PDT
Received: from i17linuxb.ists.pwr.wroc.pl by pixar.com with SMTP id AA02247
  (5.67b/IDA-1.5 for debian-bugs-pipe@mongo.pixar.com); Thu, 12 Oct 1995 13:57:25 -0700
Received: (from marekm@localhost) by i17linuxb.ists.pwr.wroc.pl (8.6.12/8.6.9) id VAA32259 for debian-bugs@pixar.com; Thu, 12 Oct 1995 21:57:41 +0100
From: Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>
Message-Id: <199510122057.VAA32259@i17linuxb.ists.pwr.wroc.pl>
Subject: ping doesn't work with broadcast addresses
To: debian-bugs@pixar.com
Date: Thu, 12 Oct 1995 21:57:39 +0100 (MET)
X-Mailer: ELM [version 2.4 PL23]
Content-Type: text
Content-Length: 1389      

Package: netbase
Version: 1.17-1

On several other systems I can use ping with a broadcast address to see
what machines on the local network are up and running.  This doesn't
work on Linux - I get "sendto: Permission denied".  It is necessary to
set the SO_BROADCAST socket option for this to work.  Similar change
would probably be nice for fping too.

While we are at it, can we make ping, traceroute (and maybe some other
setuid programs which can run for a long time and need root privileges
only at startup), drop root privileges when no longer needed?  Just do
setuid(getuid()) - the advantage is that ps shows who is running ping.

The patch for ping, with both of the above changes, follows.

Marek

diff -urN ping-5.9.orig/ping.c ping-5.9/ping.c
--- ping-5.9.orig/ping.c	Sat Jan 14 01:24:01 1995
+++ ping-5.9/ping.c	Sat Oct  7 01:12:08 1995
@@ -333,6 +333,8 @@
 	if (options & F_SO_DONTROUTE)
 		(void)setsockopt(s, SOL_SOCKET, SO_DONTROUTE, (char *)&hold,
 		    sizeof(hold));
+	/* this is necessary for broadcast addresses to work */
+	setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&hold, sizeof(hold));
 
 	/* record route option */
 	if (options & F_RROUTE) {
@@ -385,6 +387,8 @@
 		}
 	}
 #endif
+	/* just in case, and to make ps show who is running ping */
+	setuid(getuid());
 
 	if (to->sin_family == AF_INET)
 		(void)printf("PING %s (%s): %d data bytes\n", hostname,

Acknowledgement sent to Marek Michalkiewicz <marekm@i17linuxb.ists.pwr.wroc.pl>:
New bug report received and forwarded. Full text available.
Report forwarded to debian-devel@pixar.com:
Bug#1660; Package netbase. Full text available.
Ian Jackson / iwj10@thor.cam.ac.uk, with the debian-bugs tracking mechanism
This page last modified 07:43:01 GMT Wed 01 Nov