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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What's better 6pt or 12pt sockets?

479


How can I set the timeout for the connect() system call?

1108


How does a socket work?

491


What is socket programming in java?

492


Is a socket a file?

475






Why do we need socket programming?

497


What is a socket set used for?

504


What is the function of socket?

513


How is a socket created?

507


How to find other end of unix socket connection?

512


How are unix domain sockets implemented?

494


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

1210


Can a single socket port be used for multiple applications?

455


What is a sae socket?

513


What is the difference between read() and recv()?

1593