]> granicus.if.org Git - pdns/commitdiff
Make includeDirectory work sorted
authorRobin Geuze <robing@transip.nl>
Tue, 14 Mar 2017 20:53:05 +0000 (21:53 +0100)
committerRobin Geuze <robing@transip.nl>
Tue, 14 Mar 2017 20:53:05 +0000 (21:53 +0100)
pdns/dnsdist-lua2.cc
regression-tests.dnsdist/test-include-dir/Test.conf [new file with mode: 0644]
regression-tests.dnsdist/test-include-dir/test.conf
regression-tests.dnsdist/test_Advanced.py

index abf3deec55764b729820ef29a75f4801c313e6f0..0c3ebc919f1f16a5173f59cef51cb2ad8e3d2ad7 100644 (file)
@@ -1168,6 +1168,7 @@ void moreLua(bool client)
 
         DIR *dirp;
         struct dirent *ent;
+        std::list<std::string> files;
         if (!(dirp = opendir(dirname.c_str()))) {
           errlog("Error opening the included directory %s!", dirname.c_str());
           g_outputBuffer="Error opening the included directory " + dirname + "!";
@@ -1187,17 +1188,23 @@ void moreLua(bool client)
               continue;
             }
 
-            std::ifstream ifs(namebuf.str());
-            if (!ifs) {
-              warnlog("Unable to read configuration from '%s'", namebuf.str());
-            } else {
-              vinfolog("Read configuration from '%s'", namebuf.str());
-            }
-
-            g_lua.executeCode(ifs);
+            files.push_back(namebuf.str());
           }
         }
+
         closedir(dirp);
+        files.sort();
+
+        for (auto file = files.begin(); file != files.end(); ++file) {
+          std::ifstream ifs(*file);
+          if (!ifs) {
+            warnlog("Unable to read configuration from '%s'", *file);
+          } else {
+            vinfolog("Read configuration from '%s'", *file);
+          }
+
+          g_lua.executeCode(ifs);
+        }
 
         g_included = false;
     });
diff --git a/regression-tests.dnsdist/test-include-dir/Test.conf b/regression-tests.dnsdist/test-include-dir/Test.conf
new file mode 100644 (file)
index 0000000..b0926f6
--- /dev/null
@@ -0,0 +1 @@
+addAction(makeRule("includedir.advanced.tests.powerdns.com."), AllowAction())
index b0926f676644bc99d1c9415bd01fd0e6789f6d2a..0b358ca7e64bc9ba41229156c4bf1c6f614803e0 100644 (file)
@@ -1 +1 @@
-addAction(makeRule("includedir.advanced.tests.powerdns.com."), AllowAction())
+addAction(AllRule(), RCodeAction(dnsdist.REFUSED))
index a32e96df6d0b7c79cd990b34345e103c5cc82f8e..952301ec6287720dd88878eaed8d040be775b7f6 100644 (file)
@@ -1144,7 +1144,6 @@ class TestAdvancedIncludeDir(DNSDistTest):
     _config_template = """
     -- this directory contains a file allowing includedir.advanced.tests.powerdns.com.
     includeDirectory('test-include-dir')
-    addAction(AllRule(), RCodeAction(dnsdist.REFUSED))
     newServer{address="127.0.0.1:%s"}
     """