Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Nonroot ping with Net::Ping::External (was: Re: packet types & ports)

by blm (Hermit)
on Sep 23, 2002 at 17:34 UTC ( #200179=note: print w/ replies, xml ) Need Help??


in reply to packet types & ports
in thread Module Net-Ping

On CPan there is a Net::Ping::External that relies on the binary ping command that does not need root level permissions (I presume so long as your ping command doesn't)

It also works on a wide variety of systems

Check it out!

--blm--


Comment on Nonroot ping with Net::Ping::External (was: Re: packet types & ports)
Re: Nonroot ping with Net::Ping::External (was: Re: packet types & ports)
by Preceptor (Chaplain) on Sep 23, 2002 at 17:49 UTC
    Not to be too picky, but your ping command almost certainly _does_ require root permissions.
    It's because for ICMP 'echo replies' to get back to the program, it effectively has to snoop the interface - there's absolutely no state in ICMP, so it just has to listen to see if it gets something that matches.
    Of course, since it's a compiled binary that's _generally_ trusted, that's not a huge problem. Course, you could probably just do a system("ping -c 1 $host");(syntax dependant on OS) and grep for 'bytes from'.
    --
    It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
      Not to be too picky, but your ping command almost certainly _does_ require root permissions.

      Yes, ping needs root privileges and yes, blm's statement about the "binary ping command that does not need root level permissions" suggested otherwise. However, I think what he meant is that a user usually doesn't have to have root privs to execute ping. This is true because ping generally has its setuid bit on and is owned by root.

      -sauoq
      "My two cents aren't worth a dime.";
      
Re: Nonroot ping with Net::Ping::External (was: Re: packet types & ports)
by Kozz (Friar) on Sep 24, 2002 at 14:21 UTC
    blm: Thanks for the suggestion, btw!

    Originally I tried parsing the output directly from /bin/ping but the script spewed an error about execute permissions of ping from within the script. THAT's why I had pursued Net::Ping, though only the ICMP worked as root.

    I tried Net::Ping::External and it worked like a charm, no setuid bit or anything needed. Worked sweet. Thanks again.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://200179]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2015-07-03 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (48 votes), past polls