From: Francis Dupont Date: Tue, 23 Sep 2025 08:53:58 +0000 (+0200) Subject: [#4012] Aligned C++ and python code X-Git-Tag: Kea-3.1.3~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e20101fdaee790f56ec6c97e3bcca2dd61d0ef93;p=thirdparty%2Fkea.git [#4012] Aligned C++ and python code --- diff --git a/doc/sphinx/arm/hooks-ha.rst b/doc/sphinx/arm/hooks-ha.rst index 070f1be8bc..6d412ad6f2 100644 --- a/doc/sphinx/arm/hooks-ha.rst +++ b/doc/sphinx/arm/hooks-ha.rst @@ -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``, diff --git a/src/bin/shell/kea-shell.in b/src/bin/shell/kea-shell.in index 20ef78a049..445ed56838 100755 --- a/src/bin/shell/kea-shell.in +++ b/src/bin/shell/kea-shell.in @@ -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)) diff --git a/src/lib/util/filesystem.cc b/src/lib/util/filesystem.cc index d2ab9f5761..d250b75b7b 100644 --- a/src/lib/util/filesystem.cc +++ b/src/lib/util/filesystem.cc @@ -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); } diff --git a/src/lib/util/filesystem.h b/src/lib/util/filesystem.h index 9ce6c94a90..7a331cf68d 100644 --- a/src/lib/util/filesystem.h +++ b/src/lib/util/filesystem.h @@ -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. diff --git a/src/lib/util/tests/filesystem_unittests.cc b/src/lib/util/tests/filesystem_unittests.cc index 8164aed026..8184971bef 100644 --- a/src/lib/util/tests/filesystem_unittests.cc +++ b/src/lib/util/tests/filesystem_unittests.cc @@ -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"));