summaryrefslogtreecommitdiff
path: root/include/pam_authenticate.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-01-07 20:36:26 +0300
committerEd Tanous <ed@tanous.net>2022-01-12 22:00:37 +0300
commit4ecc618ff610fd9044d6067b764570135b243c4b (patch)
tree571086aaa0be8d392daf6d634d9a6d3066a21725 /include/pam_authenticate.hpp
parent9b6ffca5c1cafcc5406cf835390153a370dec4f6 (diff)
downloadbmcweb-4ecc618ff610fd9044d6067b764570135b243c4b.tar.xz
Enable const_cast checks
const_cast is an anti pattern. There are a few places we need to do it for interacting with C APIs, so enable the checks, and ignore the existing uses. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If1748213992b97f5e3e04cf9b86a6fcafbb7cf06
Diffstat (limited to 'include/pam_authenticate.hpp')
-rw-r--r--include/pam_authenticate.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index 1459ea6112..10d9116156 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -86,8 +86,11 @@ inline int pamAuthenticateUser(const std::string_view username,
{
std::string userStr(username);
std::string passStr(password);
- const struct pam_conv localConversation = {
- pamFunctionConversation, const_cast<char*>(passStr.c_str())};
+
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
+ char* passStrNoConst = const_cast<char*>(passStr.c_str());
+ const struct pam_conv localConversation = {pamFunctionConversation,
+ passStrNoConst};
pam_handle_t* localAuthHandle = nullptr; // this gets set by pam_start
int retval = pam_start("webserver", userStr.c_str(), &localConversation,
@@ -119,8 +122,10 @@ inline int pamAuthenticateUser(const std::string_view username,
inline int pamUpdatePassword(const std::string& username,
const std::string& password)
{
- const struct pam_conv localConversation = {
- pamFunctionConversation, const_cast<char*>(password.c_str())};
+ // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast)
+ char* passStrNoConst = const_cast<char*>(password.c_str());
+ const struct pam_conv localConversation = {pamFunctionConversation,
+ passStrNoConst};
pam_handle_t* localAuthHandle = nullptr; // this gets set by pam_start
int retval = pam_start("webserver", username.c_str(), &localConversation,