]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/version: strip trailing newline from vendor release file 68111/head
authorNaveen Naidu <naveennaidu479@gmail.com>
Mon, 30 Mar 2026 16:18:49 +0000 (21:48 +0530)
committerNaveen Naidu <naveennaidu479@gmail.com>
Mon, 30 Mar 2026 16:28:51 +0000 (21:58 +0530)
read_vendor_release_file() reads /etc/ceph_version which may have a
trailing newline, causing "ceph version" to produce invalid JSON output.
Strip trailing \n and \r characters before returning the content.

Signed-off-by: Naveen Naidu <naveen.naidu@ibm.com>
src/common/version.cc

index c45faba6491b2a5f736217651dd0d95637c4f66b..19aa44cc6dd77d90fc9d97ecb1df2338ad6a24ec 100644 (file)
@@ -64,6 +64,9 @@ static std::string read_vendor_release_file()
     return "";
   }
   if (!content.empty()) {
+    while (!content.empty() && (content.back() == '\n' || content.back() == '\r')) {
+      content.pop_back();
+    }
     return std::string(" release ") + content;
   }