How can I bind() to a port number < 1024?



How can I bind() to a port number < 1024?..

Answer / chaitanya

The restriction on access to ports < 1024 is part of a (fairly weak) security scheme particular to UNIX. The intention is that servers (for example rlogind, rshd) can check the port number of the client, and if it is < 1024, assume the request has been properly authorised at the client end.

The practical upshot of this, is that binding a port number < 1024 is reserved to processes having an effective UID == root.

This can, occasionally, itself present a security problem, e.g. when a server process needs to bind a well-known port, but does not itself need root access (news servers, for example). This is often solved by creating a small program which simply binds the socket, then restores the real userid and exec()s the real server. This program can then be made setuid root.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Unix Socket Programming Interview Questions

How come select says there is data, but read returns zero?

1 Answers  


How do I use TCP_NODELAY?

0 Answers  


Can a socket have multiple ports?

0 Answers  


What is the function of socket?

0 Answers  


over the socket? Is there a way to have a dynamic buffer? What does one do when one does not know how much information is coming?

1 Answers  






Whats the difference between select() and poll()?

0 Answers  


What pieces of information make up a socket?

0 Answers  


How to find other end of unix socket connection?

0 Answers  


What is a socket connection?

0 Answers  


When should I use shutdown()?

1 Answers   Wipro,


What are the types of sockets?

0 Answers  


system choose one for me on the connect() call? Should I bind() a port number in my client program, or let the?

0 Answers  


Categories