Operating System - HP-UX
1836973 Members
2562 Online
110111 Solutions
New Discussion

Re: Can any user bind port <1024

 
KapilRaj
Honored Contributor

Can any user bind port <1024

Chaps,

I hv a doubt & it goes as follows,

-- Can any user bind port number less than 1024
-- If i start an application (tomcat-servelett engine) to listen on port 80 by a normal user, Is that going to fail ?

Kapil Raj
Nothing is impossible
8 REPLIES 8
Jordan Bean
Honored Contributor

Re: Can any user bind port <1024

Only superuser can bind port < 1024.
KapilRaj
Honored Contributor

Re: Can any user bind port <1024

Are you sure on that ?. I hv an application called OAS (Oracle application Server) listening on port 80. It is started by a normal user.

Kapil
Nothing is impossible
Jordan Bean
Honored Contributor

Re: Can any user bind port <1024


Yes. Only superuser can bind port < 1024.

OAS is either invoked by root to bind the port before it changes to another user, or the application uses setuid execution.

James R. Ferguson
Acclaimed Contributor

Re: Can any user bind port <1024

Hi:

The so-called "well-known-ports" fall into the range below 1024 and cannot be bound unless the *effective* uid of the process is root's.

Regards!

...JRF...

KapilRaj
Honored Contributor

Re: Can any user bind port <1024

ok guys,

if u masters are so confident on it . I still hv to convince myself & the only way to accomplish that is to check up how OAS is started in my environment.

kaps
Nothing is impossible
Christopher Caldwell
Honored Contributor

Re: Can any user bind port <1024

Yup. He's right.

From /usr/include/netinet/in.h


/*
* Ports < IPPORT_RESERVED are reserved for
* privileged processes (e.g. root).
* Ports > IPPORT_USERRESERVED are reserved
* for servers, not necessarily privileged.
*/
#define IPPORT_RESERVED 1024

Make sure your effective UID isn't really root (e.g. is the program setuid?).
Anil C. Sedha
Trusted Contributor

Re: Can any user bind port <1024

Kapil

Only superuser binds ports less than 1024.

Now, do you have any entry for OAS in your /etc/inetd.conf file for a lower port number.

I believe your OAS application is executed using super user rights while startup if it doesn't start using inetd.

Regards,
Anil
If you need to learn, now is the best opportunity
Sean OB_1
Honored Contributor

Re: Can any user bind port <1024

All ports below 1024 are reserved for root processes.

No user can bind to a port below that unless they use setuid.