2015-05-20 34 views
1

我需要调试一个我在Eclipse中用PyDev插件编写的程序。但是我无法调试它,因为Eclipse显然没有权限这么做。 调试到达send()函数时,我总是得到以下错误。用PyDev作为root运行Eclipse

socket.error: [Errno 1] Operation not permitted

使用gksudo运行Eclipse也不起作用。它打开,但它说编辑找不到。

Could not open the editor: No editor descriptor for id org.python.pydev.editor.PythonEditor

我该如何解决这个问题?

我无法发布完整的代码,它太长了。这是一种导致相同错误的故障。 Eclipse不允许执行send()函数。在命令行工具中使用sudo执行它。

from scapy.all import * 
from scapy.layers.inet import IP, UDP 

class SomeIP(Packet): 
    name = "SomeIP Packet" 
    fields_desc=[XShortField("X", 0x1000), 
       XShortField("Y", 0x1000)] 

SIP = SomeIP() 

packet = IP(src="129.168.101.164",dst="192.168.101.143")/UDP(sport=1000, dport=1000)/SIP 

send(packet, verbose=False) 

这是我得到的错误 - 第一行可以忽略。

WARNING: No route found for IPv6 destination :: (no default route?) 
Traceback (most recent call last): 
    File "scapy_test.py", line 19, in <module> 
    send(packet, verbose=False) 
    File "/usr/lib/python2.7/dist-packages/scapy/sendrecv.py", line 251, in send 
    __gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime) 
    File "/usr/lib/python2.7/dist-packages/scapy/arch/linux.py", line 307, in __init__ 
    self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type)) 
    File "/usr/lib/python2.7/socket.py", line 187, in __init__ 
    _sock = _realsocket(family, type, proto) 
socket.error: [Errno 1] Operation not permitted 
+0

你确定这是关于权限吗?我怀疑你需要以root身份运行IDE来调试任何东西。也许这个端口很忙?看看这个问题:http://stackoverflow.com/questions/11145463/ – konart

+0

是的,我。要在命令shell中运行程序,我需要将它作为sudo执行。我试图在答案中应用该解决方案,但我不使用“serversocket”。那么我如何应用这个解决方案呢? – vicco

+0

你的代码在这里可能非常有帮助! –

回答

0

您可以使用其他端口号吗?如果我正确理解你的代码,你可以尝试打开一个数字1000的端口。由于端口号最大为1024只能被root使用,所以将端口号设置为大于1024的值可能可以解决问题。

+0

不幸的是,使用更高的端口号也不起作用。 – vicco

相关问题