]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#4012] Aligned C++ and python code
authorFrancis Dupont <fdupont@isc.org>
Tue, 23 Sep 2025 08:53:58 +0000 (10:53 +0200)
committerThomas Markwalder <tmark@isc.org>
Wed, 22 Oct 2025 16:36:55 +0000 (16:36 +0000)
doc/sphinx/arm/hooks-ha.rst
src/bin/shell/kea-shell.in
src/lib/util/filesystem.cc
src/lib/util/filesystem.h
src/lib/util/tests/filesystem_unittests.cc

index 070f1be8bcf97ceff77120101ceb71fad115bbd4..6d412ad6f2e43e6799a769347f5b44cc063edff1 100644 (file)
@@ -917,7 +917,7 @@ list:
 
 -  ``basic-auth-user-file`` - is an alternative to ``basic-auth-user``:
    instead of presenting the user ID in the configuration file it is specified
-   in the file indicated by this parameter.
+   in the first line of the file indicated by this parameter.
 
 -  ``basic-auth-password`` - specifies the password for basic HTTP
    authentication. This parameter is ignored when the user ID is not specified
@@ -926,7 +926,7 @@ list:
 
 -  ``basic-auth-password-file`` - is an alternative to ``basic-auth-password``:
    instead of presenting the password in the configuration file it is specified
-   in the file indicated by this parameter.
+   in the first line of the file indicated by this parameter.
 
 -  ``role`` - denotes the role of the server in the HA setup. The following
    roles are supported in the ``load-balancing`` configuration: ``primary``,
index 20ef78a04947c65712b965c314330bc4e21360f0..445ed56838c53a66f94bef1e823037d97b30ba53 100755 (executable)
@@ -128,6 +128,8 @@ def shell_body():
             try:
                 file = open(cmd_args.auth_password_file, 'r')
                 password = file.readline()
+                if len(password) > 0 and password[-1] == '\n':
+                    password = password[:-1]
                 file.close()
             except Exception as exc:
                 print("Failed to run: " + str(exc))
index d2ab9f576190002393f3d251bac90e69b092a3d0..d250b75b7b5334dfc76a6097968e3b1f6958a977 100644 (file)
@@ -42,7 +42,7 @@ getContent(string const& file_name) {
         isc_throw(BadValue, "Cannot open '" << file_name);
     }
     string content;
-    file >> content;
+    getline(file, content);
     return (content);
 }
 
index 9ce6c94a9081dd0de9478e6402692f057dea7c6d..7a331cf68d1e2eea6ebd0ef5d2ee8fed4c6e686b 100644 (file)
@@ -34,6 +34,9 @@ public:
 
 /// @brief Get the content of a regular file.
 ///
+/// @note Here the content is the first line not including the final
+/// line feed character if there is one.
+///
 /// @param file_name The file name.
 ///
 /// @return The content of the file.
index 8164aed026f79d9810e17c1d67406f8b9eab2605..8184971bef5774388c2e43349c5d4537ea50eee0 100644 (file)
@@ -58,6 +58,18 @@ TEST_F(FileUtilTest, getContent) {
     EXPECT_EQ("abdc", content);
 }
 
+/// @brief Check getContent with embedded spaces.
+TEST_F(FileUtilTest, getContentSpaces) {
+    string file_name(TEST_DATA_BUILDDIR "/fu.test");
+    ofstream fs(file_name.c_str(), ofstream::out | ofstream::trunc);
+    ASSERT_TRUE(fs.is_open());
+    fs << "ab\tc d\nxxx";
+    fs.close();
+    string content;
+    EXPECT_NO_THROW_LOG(content = getContent(file_name));
+    EXPECT_EQ("ab\tc d", content);
+}
+
 /// @brief Check isDir.
 TEST_F(FileUtilTest, isDir) {
     EXPECT_TRUE(isDir("/dev"));