]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 1642] ntpdsim can't find simulate block in config file.
authorDave Hart <hart@ntp.org>
Sat, 25 Sep 2010 07:44:52 +0000 (07:44 +0000)
committerDave Hart <hart@ntp.org>
Sat, 25 Sep 2010 07:44:52 +0000 (07:44 +0000)
bk: 4c9da874b_IWtWcqDafxA_BRpISDCA

ChangeLog
ntpd/ntp_config.c
ntpd/ntp_scanner.c
ntpd/ntpd.c

index 6bdaf158e0245e383764c08165a7b3c54ff48493..a779a9411a4d405a708cf21ce44908a3183bc23c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,4 @@
+* [Bug 1642] ntpdsim can't find simulate block in config file.
 (4.2.7p55) 2010/09/22 Released by Harlan Stenn <stenn@ntp.org>
 * Documentation updates from Dave Mills.
 * [Bug 1636] from 4.2.6p3-RC2: segfault after denied remote config.
index f524ef1aa76fcc86471e5f062a3505b7efcf84bf..625e2fa7ec13d0505a52366ccd4d2e19a9e4627b 100644 (file)
@@ -1559,9 +1559,9 @@ create_sim_script_info(
        queue *script_queue
        )
 {
-#ifdef SIM
+#ifndef SIM
        return NULL;
-#else
+#else  /* SIM follows */
        script_info *my_info;
        struct attr_val *my_attr_val;
 
@@ -1576,8 +1576,11 @@ create_sim_script_info(
        my_info->proc_delay = PROC_DLY;
 
        /* Traverse the script_queue and fill out non-default values */
-       my_attr_val = queue_head(script_queue);
-       while (my_attr_val != NULL) {
+       
+       for (my_attr_val = queue_head(script_queue);
+            my_attr_val != NULL;
+            my_attr_val = next_node(my_attr_val)) {
+
                /* Set the desired value */
                switch (my_attr_val->attr) {
 
@@ -1608,14 +1611,11 @@ create_sim_script_info(
                }
        }
        return (my_info);
-#endif
+#endif /* SIM */
 }
 
 
-#if !defined(SIM)
-
-#define ADDR_LENGTH 16 + 1
-
+#ifdef SIM
 static sockaddr_u *
 get_next_address(
        struct address_node *addr
@@ -1623,6 +1623,7 @@ get_next_address(
 {
        const char addr_prefix[] = "192.168.0.";
        static int curr_addr_no = 1;
+#define ADDR_LENGTH 16 + 1     /* room for 192.168.1.255 */
        char addr_string[ADDR_LENGTH];
        sockaddr_u *final_addr;
        struct addrinfo *ptr;
@@ -1648,7 +1649,7 @@ get_next_address(
        freeaddrinfo(ptr);
        return final_addr;
 }
-#endif /* !SIM */
+#endif /* SIM */
 
 
 server_info *
@@ -1658,9 +1659,9 @@ create_sim_server(
        queue *script
        )
 {
-#ifdef SIM
+#ifndef SIM
        return NULL;
-#else
+#else  /* SIM follows */
        server_info *my_info;
 
        my_info = get_node(sizeof *my_info);
@@ -1670,7 +1671,7 @@ create_sim_server(
        my_info->script = script;
        my_info->curr_script = dequeue(my_info->script);
        return my_info;
-#endif /* SIM */
+#endif /* SIM */
 }
 
 struct sim_node *
index 5a882788625e6cc91679bb9483e245bd6d626b45..4f6f13a815998c38d92b9593e34d0ba92dd7d9cc 100644 (file)
@@ -470,13 +470,11 @@ yylex(
                        /* special chars are their own token values */
                        token = ch;
                        /*
-                        * '=' implies a single string following as in:
+                        * '=' outside simulator configuration implies
+                        * a single string following as in:
                         * setvar Owner = "The Boss" default
-                        * This could alternatively be handled by
-                        * removing '=' from special_chars and adding
-                        * it to the keyword table.
                         */
-                       if ('=' == ch)
+                       if ('=' == ch && old_config_style)
                                followedby = FOLLBY_STRING;
                        yytext[0] = (char)ch;
                        yytext[1] = '\0';
@@ -558,8 +556,19 @@ yylex(
        
        if (followedby == FOLLBY_TOKEN && !instring) {
                token = is_keyword(yytext, &followedby);
-               if (token)
+               if (token) {
+                       /*
+                        * T_Server is exceptional as it forces the
+                        * following token to be a string in the
+                        * non-simulator parts of the configuration,
+                        * but in the simulator configuration section,
+                        * "server" is followed by "=" which must be
+                        * recognized as a token not a string.
+                        */
+                       if (T_Server == token && !old_config_style)
+                               followedby = FOLLBY_TOKEN;
                        goto normal_return;
+               }
                else if (is_integer(yytext)) {
                        yylval_was_set = 1;
                        errno = 0;
index 39cb3c4ed891020cc65c56bf53fd6d37b764cc8a..09c5fce37b255423de11ea0301ad7ad8b7e96523 100644 (file)
@@ -478,6 +478,10 @@ main(
        )
 {
        parse_cmdline_opts(&argc, &argv);
+#ifdef DEBUG
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+       DPRINTF(1, ("%s\n", Version));
+#endif
 
        return ntpsim(argc, argv);
 }
@@ -694,7 +698,7 @@ ntpdmain(
        }
 # endif
 
-#ifdef DEBUG
+# ifdef DEBUG
        debug = DESC(DEBUG_LEVEL).optOccCt;
        DPRINTF(1, ("%s\n", Version));
 # endif