]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1308] support systems that lack fork().
authorDave Hart <hart@ntp.org>
Wed, 18 Nov 2009 04:29:17 +0000 (04:29 +0000)
committerDave Hart <hart@ntp.org>
Wed, 18 Nov 2009 04:29:17 +0000 (04:29 +0000)
bk: 4b03781d_pmutIlSHGFuour5hep2dw

ChangeLog
configure.ac
include/ntp_config.h
include/ntp_machine.h
ntpd/ntp_config.c
ntpd/ntp_intres.c

index c6a7f7432f2ce48fc1256d49b0c257b2ee602c11..24b50fd0283c31e20f2f962df4124d55cc8a2a16 100644 (file)
--- 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 <stenn@ntp.org>
 * Upgrade to autogen-5.10
index efcb4eb46fe6de3ccae1fda5529750f0c78ec9a2..69be62c486eac2640d00611acaff93701b81bd51 100644 (file)
@@ -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,
index 9d1087e6f64617ac932b6721ce45e4a37ebf5921..4a9be31a45e3bb4fa4f9c8f58713d33b8488fcab 100644 (file)
@@ -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
 #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
 
index cfe5258384ff5047ae5151d16fd1ea79a9615a37..73fd172a2ef628d8b4fd0b93d8e298fe77e37a61 100644 (file)
@@ -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 <config.h>
@@ -532,4 +532,4 @@ extern time_t       timegm          (struct tm *);
        BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
 #endif
 
-#endif /* __ntp_machine */
+#endif /* NTP_MACHINE_H */
index bcbf6c500302360315ed4ba10b56213f41454415..f6e53cdaf8efe6b481266099a2e9e957d68b6caa 100644 (file)
@@ -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
 }
index 85f93e3c76168acb272aa91d8d91890720ec9c31..7015fa1a1596eaa33a4e52cb7f8ce1c81c9fc593 100644 (file)
@@ -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 <stdio.h>
 #include <ctype.h>
@@ -1233,3 +1236,7 @@ doconfigure(
                ce = ce->ce_next;
        }
 }
+
+#else  /* NO_INTRES follows */
+int ntp_intres_nonempty_compilation_unit;
+#endif