low level ethernet device access in linux

T

Tom Brown

Hi,

I have a windows application, written in delphi, that communicates to our
devices using raw ethernet frames. I am trying to port this application to
linux using python. However, when I try to open a socket, I get this error:

File "/home/tbrown/projects/discovery/trunk/comm.py", line 9, in __init__
self.s = socket(AF_PACKET, SOCK_RAW, proto)
File "/usr/local/lib/python2.5/socket.py", line 156, in __init__
_sock = _realsocket(family, type, proto)
socket.error: (1, 'Operation not permitted')

I understand that I am getting this error because I am running the application
as a user and not as root. I would like to be able to run this app. as a
user. Is there a way to create a socket without running the app. as root or
sudo? When I run the app. as root I get this error:

discovery.py: cannot connect to X server

Thanks,
Tom
 
G

Grant Edwards

I understand that I am getting this error because I am running
the application as a user and not as root. I would like to be
able to run this app. as a user. Is there a way to create a
socket without running the app. as root or sudo?

Yes.

According to the raw(7) man page:

ERRORS

EPERM The user doesn't have permission to open raw
sockets. Only pro- cesses with a effective user
ID of 0 or the CAP_NET_RAW attribute may do that.

Anticipating your next question:

$ man capabilities
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top