Operation not permitted,

dfu


Joined
Oct 15, 2012
Messages
3
Reaction score
0
Points
1
Hi All,

I'm trying to run portscaner as part of my work at school. When I run the code it shows an error msg "Operation not permitted". This msg is printed directly after the OS fails to create a socket.

Notes:
1. my system is Mac OS X 10.6.8
2. in this project I'm using row socket.
3. I've written a code before the creates TCP socket and runs perfectly.

I assume this error appear because row sockets require some kind of higher privilege that my system currently has. Does anyone know how to change the privilege in my system?
Any helps is highly appreciated :)

Thanks,
DFU
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Are you an Administrator on the machine? If so use sudo to run the comands..input your user password.
 
OP
D

dfu


Joined
Oct 15, 2012
Messages
3
Reaction score
0
Points
1
Thanks cradom.

Yest, I'm the admin on the machine. Would you please advice me where to type sudo?

here is where the code stops:
Code:
ss->sockfd = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
	//int s = socket (AF_INET, SOCK_RAW, IPPROTO_RAW); to  to specify the IP header
	if (ss->sockfd == -1)
	{
		perror("Unable to create socket"); //  here the following is printed out: Unable to create socket, operation not permitted  
		return -1;
	}
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
You use sudo to run the command as a higher level. For example:
sudo netstat
Password: (type your user password here. you wont see it so make sure you type it right)
Have no idea about the code. Maybe someone else can check that?
 
OP
D

dfu


Joined
Oct 15, 2012
Messages
3
Reaction score
0
Points
1
Thanks for your clarification.
I wrote the following in the command line and it works:
sudo ./myexecfile

Thanks again :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top