[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ICMP socket with Gambas


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] ----


Follow-Ups:
Re: ICMP socket with GambasLinus <olivier.cruilles@xxxxxxxx>