From: Dave Hart Date: Wed, 18 Nov 2009 04:29:17 +0000 (+0000) Subject: [Bug 1308] support systems that lack fork(). X-Git-Tag: NTP_4_2_5P247_RC~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f493e93a107063d749f41f76fd4d35723dc7b2d2;p=thirdparty%2Fntp.git [Bug 1308] support systems that lack fork(). bk: 4b03781d_pmutIlSHGFuour5hep2dw --- diff --git a/ChangeLog b/ChangeLog index c6a7f7432..24b50fd02 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ * [Bug 1142] nodebug builds shed no light on -d, -D option failure. * [Bug 1179] point out the problem with -i/--jaildir and -u/--user when they are disabled by configure. +* [Bug 1308] support systems that lack fork(). * [Bug 1343] sntp doesn't link on Solaris 7, needs -lresolv. (4.2.5p246-RC) 2009/11/17 Released by Harlan Stenn * Upgrade to autogen-5.10 diff --git a/configure.ac b/configure.ac index efcb4eb46..69be62c48 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,8 @@ case "${enable_libopts_install+set}" in esac LIBOPTS_CHECK(libopts) +AC_FUNC_FORK + AC_CACHE_CHECK( [if $CC can handle @%:@warning], ac_cv_cpp_warning, diff --git a/include/ntp_config.h b/include/ntp_config.h index 9d1087e6f..4a9be31a4 100644 --- a/include/ntp_config.h +++ b/include/ntp_config.h @@ -1,6 +1,7 @@ #ifndef NTP_CONFIG_H #define NTP_CONFIG_H +#include "ntp_machine.h" #include "ntp_data_structures.h" #include "ntpsim.h" @@ -24,7 +25,7 @@ */ #define CONF_QOS_LOWDELAY 1 #define CONF_QOS_THROUGHPUT 2 -#define CONF_QOS_RELIABILITY 3 +#define CONF_QOS_RELIABILITY 3 #define CONF_QOS_MINCOST 4 #ifdef IPTOS_PREC_INTERNETCONTROL @@ -52,6 +53,16 @@ #define FREE_CFG_T #endif +/* + * Some systems do not support fork() and don't have an alternate + * threads implementation of ntp_intres. Such systems are limited + * to using numeric IP addresses. + */ +#if defined(VMS) || defined (SYS_VXWORKS) || \ + (!defined(HAVE_FORK) && !defined(SYS_WINNT)) +#define NO_INTRES +#endif + /* Limits */ #define MAXLINE 1024 diff --git a/include/ntp_machine.h b/include/ntp_machine.h index cfe525838..73fd172a2 100644 --- a/include/ntp_machine.h +++ b/include/ntp_machine.h @@ -2,8 +2,8 @@ * Collect all machine dependent idiosyncrasies in one place. */ -#ifndef __ntp_machine -#define __ntp_machine +#ifndef NTP_MACHINE_H +#define NTP_MACHINE_H #ifdef HAVE_CONFIG_H # include @@ -532,4 +532,4 @@ extern time_t timegm (struct tm *); BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION #endif -#endif /* __ntp_machine */ +#endif /* NTP_MACHINE_H */ diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index bcbf6c500..f6e53cdaf 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -1709,9 +1709,11 @@ config_auth( { extern int cache_type; /* authkeys.c */ #ifdef OPENSSL +#ifndef NO_INTRES u_char digest[EVP_MAX_MD_SIZE]; u_int digest_len; EVP_MD_CTX ctx; +#endif struct attr_val *my_val; int item; #endif @@ -1807,7 +1809,7 @@ config_auth( sys_revoke = ptree->auth.revoke; #endif /* OPENSSL */ -#if !defined(VMS) && !defined(SYS_VXWORKS) +#ifndef NO_INTRES /* find a keyid */ if (info_auth_keyid == 0) req_keyid = 65535; @@ -1837,7 +1839,7 @@ config_auth( /* save keyid so we will accept config requests with it */ info_auth_keyid = req_keyid; -#endif /* !defined(VMS) && !defined(SYS_VXWORKS) */ +#endif /* !NO_INTRES */ } @@ -4486,9 +4488,9 @@ abort_resolve(void) /* * do_resolve_internal - start up the resolver function (not program) - */ -/* - * On VMS, this routine will simply refuse to resolve anything. + * + * On VMS, VxWorks, and Unix-like systems lacking fork(), this routine + * will simply refuse to resolve anything. * * Possible implementation: keep `res_file' in memory, do async * name resolution via QIO, update from within completion AST. @@ -4512,12 +4514,11 @@ do_resolve_internal(void) (void) fclose(res_fp); res_fp = NULL; -#if !defined(VMS) && !defined (SYS_VXWORKS) +#ifndef NO_INTRES req_file = res_file; /* set up pointer to res file */ #ifndef SYS_WINNT (void) signal_no_reset(SIGCHLD, catchchild); -#ifndef SYS_VXWORKS /* the parent process will write to the pipe * in order to wake up to child process * which may be waiting in a select() call @@ -4576,11 +4577,6 @@ do_resolve_internal(void) (void) signal_no_reset(SIGCHLD, SIG_DFL); -#ifdef DEBUG - if (0) - debug = 2; -#endif - init_logging("ntpd_intres", 0); setup_logfile(); /* @@ -4597,21 +4593,14 @@ do_resolve_internal(void) abort_resolve(); exit(1); } -#else - /* vxWorks spawns a thread... -casey */ - i = sp (ntp_intres); - /*i = taskSpawn("ntp_intres",100,VX_FP_TASK,20000,ntp_intres);*/ -#endif if (i == -1) { msyslog(LOG_ERR, "fork() failed, can't start ntp_intres: %m"); (void) signal_no_reset(SIGCHLD, SIG_DFL); abort_resolve(); - } - else { + } else /* This is the parent process who will write to the pipe, * so we close the read fd */ close(resolver_pipe_fd[0]); - } #else /* SYS_WINNT */ { /* NT's equivalent of fork() is _spawn(), but the start point @@ -4642,9 +4631,9 @@ do_resolve_internal(void) } } #endif /* SYS_WINNT */ -#else /* VMS VX_WORKS */ +#else /* NO_INTRES follows */ msyslog(LOG_ERR, - "Name resolution not implemented for VMS - use numeric addresses"); + "Deferred DNS not implemented - use numeric addresses"); abort_resolve(); -#endif /* VMS VX_WORKS */ +#endif } diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index 85f93e3c7..7015fa1a1 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -26,6 +26,9 @@ #include "ntp_request.h" #include "ntp_stdlib.h" #include "ntp_syslog.h" +#include "ntp_config.h" + +#ifndef NO_INTRES /* from ntp_config.h */ #include #include @@ -1233,3 +1236,7 @@ doconfigure( ce = ce->ce_next; } } + +#else /* NO_INTRES follows */ +int ntp_intres_nonempty_compilation_unit; +#endif