[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ICMP socket with Gambas
[Thread Prev] | [Thread Next]
- Subject: Re: ICMP socket with Gambas
- From: Linus <olivier.cruilles@xxxxxxxx>
- Date: Fri, 27 Jun 2025 14:03:45 -0400
- To: Lee <t.lee.davidson@xxxxxxxxx>
- Cc: Linus <olivier.cruilles@xxxxxxxx>, Gambas Mailing List <user@xxxxxxxxxxxxxxxxxxxxxx>
Hello Lee, Thank you for your comment and research and yes I knew about the need to be root to run the code. A lot a network command on Linux require the ‘root’ access but I was not aware about the SOCK_DGRAM option. Unfortunately, in the end, for now, no way to do an ICMP request in Gambas… I will wait the answer from Benoit, about if is possible to do something on this way. Olivier > Le 27 juin 2025 à 13:17, Lee <t.lee.davidson@xxxxxxxxx> a écrit : > > Apparently creating a raw socket requires root privileges, or at least the NET_CAP_RAW capability. > > I get an "Operation not permitted" error: when running the compiled 'ping_cmd.c', when creating a raw socket with Python, and when creating a raw socket by executing the libc:6 `socket` function from Gambas. > > The standard `ping` command gets around this by exploiting the kernel's support of non-raw ICMP sockets.[1] > > So, I edited 'ping_cmd.c' (and my Gambas test project) to open the socket with: > sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP); > instead of: > sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); > > 'ping_cmd' now works and I can create a socket from Gambas. > > > Olivier, I don't understand how you were able to successfully execute the compiled 'ping_cmd.c' without getting that error. Dit you run it as root? > > > [1] https://github.com/iputils/iputils/commit/87dbb3a5db657d5eae6934707beaf0507980a1c3#diff-3bbcff584f2ee1c8172d9e280209ebe4R702 > > > P.S. I had deleted the messages in this thread, and my last reply was somehow not saved in the Sent folder. I apologize for posting out-of-thread. > > > -- > Lee > > --- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ---- > --- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ---- > >
Re: ICMP socket with Gambas | Lee <t.lee.davidson@xxxxxxxxx> |
Re: ICMP socket with Gambas | Lee <t.lee.davidson@xxxxxxxxx> |