* Re: allow binding privileged port
2003-03-13 3:04 allow binding privileged port ChoongHwan Lee
@ 2003-03-13 9:23 ` Timo Felbinger
0 siblings, 0 replies; 2+ messages in thread
From: Timo Felbinger @ 2003-03-13 9:23 UTC (permalink / raw)
On 12 Mar 2003, ChoongHwan Lee wrote:
> Hello.
>
> I'd like to run my own e-mail server in privileged port 25.
> Though I can get privileged access on my system, I don't want to run
> my program as 'root' account since my program is specified, and it is
> dangerous to do so.
>
> How can I configure to allow non-root user to bind and listen privileged port?
> I've searched documents and articles in Tru64 website and newsgroup,
> but I can't find anything related to this. Is it impossible?
>
Standard method (and portable, too) would be to start the program as
root, bind the port, then use setuid() to drop the root privileges.
Alternatively, you might consider whether you could run your
server via inetd. That might be even simpler, as inetd can do
a lot of work for you: it will bind the port, listen to it, accept
connections, and launch one instance of your program, with a user
id of your choice, for every incoming connection.
(qmail runs in this mode, so you could look into qmail's sources
for more details).
Cheers,
Timo Felbinger
^ permalink raw reply [flat|nested] 2+ messages in thread