Temporarily drop permissions
authorAlan T. DeKok <aland@freeradius.org>
Sun, 28 Sep 2008 07:07:22 +0000 (09:07 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 15 Oct 2008 13:22:40 +0000 (15:22 +0200)
commit9cf468a4719ecf94adde27ada2c282e13f56e8a1
tree975ac87d7b22f25e66be56c9bcfc58a9234fffe7
parentf16943011f0f381767be1972d5e01fdbf378e2b7
Temporarily drop permissions

See "suid demystified" paper.  We drop permissions, but keep a
saved UID.  Then we restore permissions while binding to sockets.
This lets us run as an unprivileged user, but still bind to privileged
ports.

TO DO: add '-u user -g group -R chroot' to command-line options,
and switch UIDs *immediately* on start.  This minimizes the amount
of code that runs as root.

TO DO: move suidup/down calls to wrap the bind() calls, and the BINDTODEVICE
calls, to even further minimize the code.
src/main/event.c
src/main/mainconfig.c