use daemon(3).

git-svn-id: file:///svn/unbound/trunk@1455 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2009-02-05 14:23:24 +00:00
parent 6e0d34659b
commit b22145d504
6 changed files with 13 additions and 3 deletions

View file

@ -28,6 +28,9 @@
/* Define to 1 if you have the `chroot' function. */ /* Define to 1 if you have the `chroot' function. */
#undef HAVE_CHROOT #undef HAVE_CHROOT
/* Define to 1 if you have the `daemon' function. */
#undef HAVE_DAEMON
/* Define to 1 if you have the <dlfcn.h> header file. */ /* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H #undef HAVE_DLFCN_H

3
configure vendored
View file

@ -25283,7 +25283,8 @@ fi
for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups
for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups daemon
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
{ echo "$as_me:$LINENO: checking for $ac_func" >&5 { echo "$as_me:$LINENO: checking for $ac_func" >&5

View file

@ -854,7 +854,7 @@ AC_CHECK_GETADDRINFO_WITH_INCLUDES
if test $ac_cv_func_getaddrinfo = no; then if test $ac_cv_func_getaddrinfo = no; then
AC_LIBOBJ([fake-rfc2553]) AC_LIBOBJ([fake-rfc2553])
fi fi
AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups]) AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev setresuid setreuid setresgid setregid glob initgroups daemon])
# check if setreuid en setregid fail, on MacOSX10.4(darwin8). # check if setreuid en setregid fail, on MacOSX10.4(darwin8).
if echo $build_os | grep darwin8 > /dev/null; then if echo $build_os | grep darwin8 > /dev/null; then

View file

@ -294,6 +294,11 @@ checkoldpid(char* pidfile, int inchroot)
static void static void
detach(void) detach(void)
{ {
#ifdef HAVE_DAEMON
/* use POSIX daemon(3) function */
if(daemon(1, 0) != 0)
fatal_exit("daemon failed: %s", strerror(errno));
#else /* no HAVE_DAEMON */
#ifdef HAVE_WORKING_FORK #ifdef HAVE_WORKING_FORK
int fd; int fd;
/* Take off... */ /* Take off... */
@ -319,6 +324,7 @@ detach(void)
(void)close(fd); (void)close(fd);
} }
#endif /* HAVE_WORKING_FORK */ #endif /* HAVE_WORKING_FORK */
#endif /* HAVE_DAEMON */
} }
/** daemonize, drop user priviliges and chroot if needed */ /** daemonize, drop user priviliges and chroot if needed */

View file

@ -15,6 +15,7 @@
inluded ldns package with the unbound source. The -I include inluded ldns package with the unbound source. The -I include
is put before the others, so it avoids bad include files from is put before the others, so it avoids bad include files from
an older ldns install. an older ldns install.
- daemon(3) posix call is used when available.
4 February 2009: Wouter 4 February 2009: Wouter
- tag for release 1.2.1. - tag for release 1.2.1.

View file

@ -69,7 +69,6 @@ o unbound_control forward [addr {addr}] | [off]
o #231: unbound_checkconf options to output config file data. o #231: unbound_checkconf options to output config file data.
o config entry to denote that a zone is to be treated as unsigned (even if o config entry to denote that a zone is to be treated as unsigned (even if
a DS exists to higher trust anchor). a DS exists to higher trust anchor).
o see if we can use daemon(3), cleaner posix usage.
o see if we can include the python bindings (contrib). o see if we can include the python bindings (contrib).
o see if we can suport var:value (nospace) by parser. o see if we can suport var:value (nospace) by parser.
o remote control read ssl information while priviledged. o remote control read ssl information while priviledged.