Hi,
I'm getting the following error when running my plugin:
Traceback (most recent call last):
File "plugin.py", line 41, in sendTestConfig
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/socket.py", line 159, in __init__
<class 'socket.error'>: (1, 'Operation not permitted')
On the line:
current_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.getprotobyname("icmp"))
I gather this is because you need to be the ROOT user to create ICMP sockets - which I'm assuming the process that executes the plugin isn't - do you know a workaround to this?
Thanks in advance!
Creating ICMP socket from Python - need to be the ROOT user?
Forum rules
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo
-
HomeAutomationPlugins.com
- Posts: 41
- Joined: Sat Feb 18, 2012 12:38 pm
-
Perry The Cynic
- Posts: 857
- Joined: Mon Apr 07, 2008 9:46 pm
Re: Creating ICMP socket from Python - need to be the ROOT u
This is a general UNIX matter; it's got nothing to do with Indigo as such. ICMP is the control protocol for IP, and as such there is all kinds of serious mischief that can be made by sending wrong (if not malicious) ICMP packets onto the network. Therefore the ability to directly generate ICMP packets is reserved to the root account. There is no way around this; you have to be root to send (or receive) ICMP directly.I gather this is because you need to be the ROOT user to create ICMP sockets - which I'm assuming the process that executes the plugin isn't - do you know a workaround to this?
This is the point where we usually ask, "Why do you think you want or need to do this?" What are you trying to do?
CHeers
-- perry
-
HomeAutomationPlugins.com
- Posts: 41
- Joined: Sat Feb 18, 2012 12:38 pm
Re: Creating ICMP socket from Python - need to be the ROOT u
Thanks for your response Perry!
Yes - you're right this was a step-back-and-ask-yourself-why-your-actually-doing-it moment!
I basically wanted to ping a series of IP's (for some Samsung TV's) to find out if they were online or not. I got around it in the end by running the ping shell command, then parsing the command line response - inelegant but it seems to work!
I was running up against the root user issue you describe.
Thanks for your help!
Yes - you're right this was a step-back-and-ask-yourself-why-your-actually-doing-it moment!
I basically wanted to ping a series of IP's (for some Samsung TV's) to find out if they were online or not. I got around it in the end by running the ping shell command, then parsing the command line response - inelegant but it seems to work!
I was running up against the root user issue you describe.
Thanks for your help!
Re: Creating ICMP socket from Python - need to be the ROOT u
I am not sure if this would help in your specific case, but you could just look at the return code from ping and avoid any parsing. This command:reading123 wrote:...I got around it in the end by running the ping shell command, then parsing the command line response - inelegant but it seems to work!...
Code: Select all
ping -c4 -o -q 192.168.4.99 >/dev/null;echo $?The -c argument says to try 4 times, -o says quit after the first success, -q is quiet and the >/dev/null is because -q isn't very quiet at all.
Hope this helps.
-
HomeAutomationPlugins.com
- Posts: 41
- Joined: Sat Feb 18, 2012 12:38 pm
Re: Creating ICMP socket from Python - need to be the ROOT u
Superb - thanks Perry!