]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add newline before parsing config on Windows
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Fri, 8 May 2020 12:28:28 +0000 (12:28 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 28 Oct 2020 09:55:20 +0000 (09:55 +0000)
On Windows, ceph will fail to parse config files that lack a
newline at the end.

To improve user experience, we're adding a newline ourselves before
parsing the content.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/common/ConfUtils.cc

index 2ee0848c1af199a90c848e47cb6c96b0e449dfc9..1ab84af80e9a0edf544bddeb1ca6c116a7bfd8de 100644 (file)
@@ -134,8 +134,13 @@ int ConfFile::parse_file(const std::string &fname,
     }
   }
   std::ifstream ifs{fname};
-  const std::string buffer{std::istreambuf_iterator<char>(ifs),
-                          std::istreambuf_iterator<char>()};
+  std::string buffer{std::istreambuf_iterator<char>(ifs),
+                                      std::istreambuf_iterator<char>()};
+  #ifdef _WIN32
+    // We'll need to ensure that there's a new line at the end of the file,
+    // otherwise the config parsing will fail.
+    buffer.append("\n");
+  #endif
   if (parse_buffer(buffer, warnings)) {
     return 0;
   } else {