Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming
conventions for variables, classes, and functions, as well as imposes
the latest clang-format file.
This changeset was mostly built automatically by the included
.clang-tidy file, which has the ability to autoformat and auto rename
variables. At some point in the future I would like to see this in
greater use, but for now, we will impose it on bmcweb, and see how it
goes.
Tested: Code still compiles, and appears to run, although other issues
are possible and likely.
Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/include/pam_authenticate.hpp b/include/pam_authenticate.hpp
index a66d16b..65e4740 100644
--- a/include/pam_authenticate.hpp
+++ b/include/pam_authenticate.hpp
@@ -6,21 +6,20 @@
#include <boost/utility/string_view.hpp>
// function used to get user input
-inline int pam_function_conversation(int num_msg,
- const struct pam_message** msg,
- struct pam_response** resp,
- void* appdata_ptr) {
- if (appdata_ptr == nullptr) {
+inline int pamFunctionConversation(int numMsg, const struct pam_message** msg,
+ struct pam_response** resp,
+ void* appdataPtr) {
+ if (appdataPtr == nullptr) {
return PAM_AUTH_ERR;
}
auto* pass = reinterpret_cast<char*>(
- malloc(std::strlen(reinterpret_cast<char*>(appdata_ptr)) + 1));
- std::strcpy(pass, reinterpret_cast<char*>(appdata_ptr));
+ malloc(std::strlen(reinterpret_cast<char*>(appdataPtr)) + 1));
+ std::strcpy(pass, reinterpret_cast<char*>(appdataPtr));
*resp = reinterpret_cast<pam_response*>(
- calloc(num_msg, sizeof(struct pam_response)));
+ calloc(numMsg, sizeof(struct pam_response)));
- for (int i = 0; i < num_msg; ++i) {
+ for (int i = 0; i < numMsg; ++i) {
/* Ignore all PAM messages except prompting for hidden input */
if (msg[i]->msg_style != PAM_PROMPT_ECHO_OFF) {
continue;
@@ -33,20 +32,20 @@
return PAM_SUCCESS;
}
-inline bool pam_authenticate_user(const boost::string_view username,
- const boost::string_view password) {
- std::string user_str(username);
- std::string pass_str(password);
- const struct pam_conv local_conversation = {
- pam_function_conversation, const_cast<char*>(pass_str.c_str())};
- pam_handle_t* local_auth_handle = NULL; // this gets set by pam_start
+inline bool pamAuthenticateUser(const boost::string_view username,
+ const boost::string_view password) {
+ std::string userStr(username);
+ std::string passStr(password);
+ const struct pam_conv localConversation = {
+ pamFunctionConversation, const_cast<char*>(passStr.c_str())};
+ pam_handle_t* localAuthHandle = NULL; // this gets set by pam_start
- if (pam_start("webserver", user_str.c_str(), &local_conversation,
- &local_auth_handle) != PAM_SUCCESS) {
+ if (pam_start("webserver", userStr.c_str(), &localConversation,
+ &localAuthHandle) != PAM_SUCCESS) {
return false;
}
- int retval = pam_authenticate(local_auth_handle,
- PAM_SILENT | PAM_DISALLOW_NULL_AUTHTOK);
+ int retval =
+ pam_authenticate(localAuthHandle, PAM_SILENT | PAM_DISALLOW_NULL_AUTHTOK);
if (retval != PAM_SUCCESS) {
if (retval == PAM_AUTH_ERR) {
@@ -54,18 +53,18 @@
} else {
// printf("pam_authenticate returned %d\n", retval);
}
- pam_end(local_auth_handle, PAM_SUCCESS);
+ pam_end(localAuthHandle, PAM_SUCCESS);
return false;
}
/* check that the account is healthy */
- if (pam_acct_mgmt(local_auth_handle, PAM_DISALLOW_NULL_AUTHTOK) !=
+ if (pam_acct_mgmt(localAuthHandle, PAM_DISALLOW_NULL_AUTHTOK) !=
PAM_SUCCESS) {
- pam_end(local_auth_handle, PAM_SUCCESS);
+ pam_end(localAuthHandle, PAM_SUCCESS);
return false;
}
- if (pam_end(local_auth_handle, PAM_SUCCESS) != PAM_SUCCESS) {
+ if (pam_end(localAuthHandle, PAM_SUCCESS) != PAM_SUCCESS) {
return false;
}