Binding a Daemon Process to a lower port without root?

Steve smorrey at gmail.com
Sat Sep 15 16:15:31 MDT 2007


Hello everyone,
I've been experimenting with creating a roll your own media center / NAS

The interface is browser based but doesn't need all of the fancy
features of Apache or even the lighter httpd programs out there.

I've currently got it mostly operational, except I'm having a small problem.

As you well know ports below 1024 are reserved and no programs can
bind to them unless they are running as root.
So presently to access my Media Center control panel, I have to go to
http://myhost.localdomain:1234/ or some such thing.

I would like to bind my process to port 80, so that the browser will
default to there, but I'm really not wanting to have this thing run as
root.  So my question is this.

Programs like Apache don't typically run as root, they either run as
the Apache user, or as user nobody or some such thing.  And yet they
are able to bind to these lower ports.  How is this achieved.
My best guess thus far is that something is cheating, by launching the
process as root and then changing the user to Apache or whatever,
after the bind to port 80 has taken place.  If that is true how is
that accomplished?  Also is this something that I should code my
program to do, or is it something that is handled by an init script?
My money is on the init script at this time, but I'm wondering if
anyone else has any ideas, or if I'm possibly missing something here.

Thanks in advance for the replies!
Sincerely,
Steve

p.s. Distro I'm working with is a very stripped down Ubuntu



More information about the PLUG mailing list