Recent

Author Topic: [SOLVED] Ping a PC  (Read 14891 times)

braximo

  • Jr. Member
  • **
  • Posts: 79
[SOLVED] Ping a PC
« on: April 16, 2012, 02:43:54 am »
Hello community!

Googled it and i DIDN'T find it! I just want to know how to ping a PC using code.

Thanks and more power!
« Last Edit: June 04, 2012, 11:57:06 am by braximo »
Ubuntu 16.04 Lazarus 1.6

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Ping a PC
« Reply #1 on: April 16, 2012, 08:22:59 am »

braximo

  • Jr. Member
  • **
  • Posts: 79
Re: Ping a PC
« Reply #2 on: April 16, 2012, 08:27:24 am »
Thanks for the info! Never used it before and will try it. tnx
Ubuntu 16.04 Lazarus 1.6

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1946
Re: Ping a PC
« Reply #3 on: April 16, 2012, 01:18:02 pm »
You should be aware that Ping requires root privileges on Linux afaik.

Rails

  • Guest
Re: Ping a PC
« Reply #4 on: April 16, 2012, 02:46:11 pm »
You should be aware that Ping requires root privileges on Linux afaik.

Not on my Debian boxes. I'm not sure why not, though. It seems like it should require root privileges.

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Ping a PC
« Reply #5 on: April 16, 2012, 02:53:57 pm »
You should be aware that Ping requires root privileges on Linux afaik.

Not on my Debian boxes. I'm not sure why not, though. It seems like it should require root privileges.
You're probably talking about the ping command. Do ls -l /bin/ping and you probably see something like -rwsr-xr-x root root. The s means that a non root user executes ping with the setuid root (chmod +s).

Sending a ping from code does require root privileges, even on debian.

Rails

  • Guest
Re: Ping a PC
« Reply #6 on: April 16, 2012, 03:22:59 pm »
 
You're probably talking about the ping command. Do ls -l /bin/ping and you probably see something like -rwsr-xr-x root root. The s means that a non root user executes ping with the setuid root (chmod +s).

Sending a ping from code does require root privileges, even on debian.
 

Yep, it's setuid root.

Edit:  But I still don't understand the reasoning behind making the ping command available to ordinary users, even if only via setuid. Apparently, a number of distros come that way.  Google doesn't provide a ready answer as to why.

Anyway, this is a bit off topic, so I think I will drop the subject and just query a Linux sys admin I know.

« Last Edit: April 16, 2012, 06:03:49 pm by Rails »

jack616

  • Sr. Member
  • ****
  • Posts: 268
Re: Ping a PC
« Reply #7 on: May 22, 2012, 01:20:03 pm »
ISP's like to get people to ping when they have (sigh) issues.
Maybe someone somewhere thought it relatively safe to provide it
in response to that?



braximo

  • Jr. Member
  • **
  • Posts: 79
Re: Ping a PC
« Reply #8 on: June 04, 2012, 05:28:39 am »
any suggestions on how will i execute pinghost with root previlages? thanks
Ubuntu 16.04 Lazarus 1.6

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

braximo

  • Jr. Member
  • **
  • Posts: 79
Re: Ping a PC
« Reply #10 on: June 04, 2012, 10:37:05 am »
correct me if im wrong, will i create another app to execute pkexec <my app>?
Ubuntu 16.04 Lazarus 1.6

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Ping a PC
« Reply #11 on: June 04, 2012, 11:06:13 am »
correct me if im wrong, will i create another app to execute pkexec <my app>?
Sending ping from code requires root privileges on linux. So you run your complete app with root privileges (probably not a good idea unless your app does nothing else but pinging) or you launch an external program from your app to do the ping and request root privileges only for that program.

braximo

  • Jr. Member
  • **
  • Posts: 79
Re: Ping a PC
« Reply #12 on: June 04, 2012, 11:32:51 am »
ah OK thanks. Got it to work thanks ludob
« Last Edit: June 04, 2012, 11:50:08 am by braximo »
Ubuntu 16.04 Lazarus 1.6

 

TinyPortal © 2005-2018