clang-format-11: reformat

The .clang-format file here is an old version of the common one.
Upgrade to the latest and reformat.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I0d532aa88d650e9c7664e07abfc8c4fdf0dd3df4
diff --git a/user_mgr.cpp b/user_mgr.cpp
index 0447fe7..c65a822 100644
--- a/user_mgr.cpp
+++ b/user_mgr.cpp
@@ -14,67 +14,72 @@
 // limitations under the License.
 */
 
+#include "config.h"
+
+#include "user_mgr.hpp"
+
+#include "file.hpp"
+#include "shadowlock.hpp"
+#include "users.hpp"
+
+#include <grp.h>
+#include <pwd.h>
 #include <shadow.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <time.h>
-#include <fstream>
-#include <grp.h>
-#include <pwd.h>
-#include <regex>
-#include <algorithm>
-#include <numeric>
+#include <unistd.h>
+
+#include <boost/algorithm/string/split.hpp>
 #include <boost/process/child.hpp>
 #include <boost/process/io.hpp>
-#include <boost/algorithm/string/split.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
 #include <xyz/openbmc_project/User/Common/error.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include "shadowlock.hpp"
-#include "file.hpp"
-#include "user_mgr.hpp"
-#include "users.hpp"
-#include "config.h"
+
+#include <algorithm>
+#include <fstream>
+#include <numeric>
+#include <regex>
 
 namespace phosphor
 {
 namespace user
 {
 
-static constexpr const char *passwdFileName = "/etc/passwd";
+static constexpr const char* passwdFileName = "/etc/passwd";
 static constexpr size_t ipmiMaxUsers = 15;
 static constexpr size_t ipmiMaxUserNameLen = 16;
 static constexpr size_t systemMaxUserNameLen = 30;
 static constexpr size_t maxSystemUsers = 30;
-static constexpr const char *grpSsh = "ssh";
+static constexpr const char* grpSsh = "ssh";
 static constexpr uint8_t minPasswdLength = 8;
 static constexpr int success = 0;
 static constexpr int failure = -1;
 
 // pam modules related
-static constexpr const char *pamTally2 = "pam_tally2.so";
-static constexpr const char *pamCrackLib = "pam_cracklib.so";
-static constexpr const char *pamPWHistory = "pam_pwhistory.so";
-static constexpr const char *minPasswdLenProp = "minlen";
-static constexpr const char *remOldPasswdCount = "remember";
-static constexpr const char *maxFailedAttempt = "deny";
-static constexpr const char *unlockTimeout = "unlock_time";
-static constexpr const char *pamPasswdConfigFile = "/etc/pam.d/common-password";
-static constexpr const char *pamAuthConfigFile = "/etc/pam.d/common-auth";
+static constexpr const char* pamTally2 = "pam_tally2.so";
+static constexpr const char* pamCrackLib = "pam_cracklib.so";
+static constexpr const char* pamPWHistory = "pam_pwhistory.so";
+static constexpr const char* minPasswdLenProp = "minlen";
+static constexpr const char* remOldPasswdCount = "remember";
+static constexpr const char* maxFailedAttempt = "deny";
+static constexpr const char* unlockTimeout = "unlock_time";
+static constexpr const char* pamPasswdConfigFile = "/etc/pam.d/common-password";
+static constexpr const char* pamAuthConfigFile = "/etc/pam.d/common-auth";
 
 // Object Manager related
-static constexpr const char *ldapMgrObjBasePath =
+static constexpr const char* ldapMgrObjBasePath =
     "/xyz/openbmc_project/user/ldap";
 
 // Object Mapper related
-static constexpr const char *objMapperService =
+static constexpr const char* objMapperService =
     "xyz.openbmc_project.ObjectMapper";
-static constexpr const char *objMapperPath =
+static constexpr const char* objMapperPath =
     "/xyz/openbmc_project/object_mapper";
-static constexpr const char *objMapperInterface =
+static constexpr const char* objMapperInterface =
     "xyz.openbmc_project.ObjectMapper";
 
 using namespace phosphor::logging;
@@ -96,12 +101,12 @@
 using Argument = xyz::openbmc_project::Common::InvalidArgument;
 
 template <typename... ArgTypes>
-static std::vector<std::string> executeCmd(const char *path,
-                                           ArgTypes &&... tArgs)
+static std::vector<std::string> executeCmd(const char* path,
+                                           ArgTypes&&... tArgs)
 {
     std::vector<std::string> stdOutput;
     boost::process::ipstream stdOutStream;
-    boost::process::child execProg(path, const_cast<char *>(tArgs)...,
+    boost::process::child execProg(path, const_cast<char*>(tArgs)...,
                                    boost::process::std_out > stdOutStream);
     std::string stdOutLine;
 
@@ -149,7 +154,7 @@
     }
 }
 
-static bool removeStringFromCSV(std::string &csvStr, const std::string &delStr)
+static bool removeStringFromCSV(std::string& csvStr, const std::string& delStr)
 {
     std::string::size_type delStrPos = csvStr.find(delStr);
     if (delStrPos != std::string::npos)
@@ -168,7 +173,7 @@
     return false;
 }
 
-bool UserMgr::isUserExist(const std::string &userName)
+bool UserMgr::isUserExist(const std::string& userName)
 {
     if (userName.empty())
     {
@@ -183,7 +188,7 @@
     return true;
 }
 
-void UserMgr::throwForUserDoesNotExist(const std::string &userName)
+void UserMgr::throwForUserDoesNotExist(const std::string& userName)
 {
     if (isUserExist(userName) == false)
     {
@@ -193,7 +198,7 @@
     }
 }
 
-void UserMgr::throwForUserExists(const std::string &userName)
+void UserMgr::throwForUserExists(const std::string& userName)
 {
     if (isUserExist(userName) == true)
     {
@@ -204,7 +209,7 @@
 }
 
 void UserMgr::throwForUserNameConstraints(
-    const std::string &userName, const std::vector<std::string> &groupNames)
+    const std::string& userName, const std::vector<std::string>& groupNames)
 {
     if (std::find(groupNames.begin(), groupNames.end(), "ipmi") !=
         groupNames.end())
@@ -236,7 +241,7 @@
 }
 
 void UserMgr::throwForMaxGrpUserCount(
-    const std::vector<std::string> &groupNames)
+    const std::vector<std::string>& groupNames)
 {
     if (std::find(groupNames.begin(), groupNames.end(), "ipmi") !=
         groupNames.end())
@@ -263,7 +268,7 @@
     return;
 }
 
-void UserMgr::throwForInvalidPrivilege(const std::string &priv)
+void UserMgr::throwForInvalidPrivilege(const std::string& priv)
 {
     if (!priv.empty() &&
         (std::find(privMgr.begin(), privMgr.end(), priv) == privMgr.end()))
@@ -274,9 +279,9 @@
     }
 }
 
-void UserMgr::throwForInvalidGroups(const std::vector<std::string> &groupNames)
+void UserMgr::throwForInvalidGroups(const std::vector<std::string>& groupNames)
 {
-    for (auto &group : groupNames)
+    for (auto& group : groupNames)
     {
         if (std::find(groupsMgr.begin(), groupsMgr.end(), group) ==
             groupsMgr.end())
@@ -320,7 +325,7 @@
                    (sshRequested ? "/bin/sh" : "/bin/nologin"), "-e",
                    (enabled ? "" : "1970-01-02"));
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Unable to create new user");
         elog<InternalFailure>();
@@ -347,7 +352,7 @@
     {
         executeCmd("/usr/sbin/userdel", userName.c_str(), "-r");
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("User delete failed",
                         entry("USER_NAME=%s", userName.c_str()));
@@ -375,13 +380,13 @@
         executeCmd("/usr/sbin/usermod", "-l", newUserName.c_str(),
                    userName.c_str(), "-d", newHomeDir.c_str(), "-m");
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("User rename failed",
                         entry("USER_NAME=%s", userName.c_str()));
         elog<InternalFailure>();
     }
-    const auto &user = usersList[userName];
+    const auto& user = usersList[userName];
     std::string priv = user.get()->userPrivilege();
     std::vector<std::string> groupNames = user.get()->userGroups();
     bool enabled = user.get()->userEnabled();
@@ -398,16 +403,16 @@
     return;
 }
 
-void UserMgr::updateGroupsAndPriv(const std::string &userName,
-                                  const std::vector<std::string> &groupNames,
-                                  const std::string &priv)
+void UserMgr::updateGroupsAndPriv(const std::string& userName,
+                                  const std::vector<std::string>& groupNames,
+                                  const std::string& priv)
 {
     throwForInvalidPrivilege(priv);
     throwForInvalidGroups(groupNames);
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
     throwForUserDoesNotExist(userName);
-    const std::vector<std::string> &oldGroupNames =
+    const std::vector<std::string>& oldGroupNames =
         usersList[userName].get()->userGroups();
     std::vector<std::string> groupDiff;
     // Note: already dealing with sorted group lists.
@@ -439,7 +444,7 @@
         executeCmd("/usr/sbin/usermod", userName.c_str(), "-G", groups.c_str(),
                    "-s", (sshRequested ? "/bin/sh" : "/bin/nologin"));
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Unable to modify user privilege / groups");
         elog<InternalFailure>();
@@ -514,9 +519,9 @@
     return AccountPolicyIface::accountUnlockTimeout(value);
 }
 
-int UserMgr::getPamModuleArgValue(const std::string &moduleName,
-                                  const std::string &argName,
-                                  std::string &argValue)
+int UserMgr::getPamModuleArgValue(const std::string& moduleName,
+                                  const std::string& argName,
+                                  std::string& argValue)
 {
     std::string fileName;
     if (moduleName == pamTally2)
@@ -567,9 +572,9 @@
     return failure;
 }
 
-int UserMgr::setPamModuleArgValue(const std::string &moduleName,
-                                  const std::string &argName,
-                                  const std::string &argValue)
+int UserMgr::setPamModuleArgValue(const std::string& moduleName,
+                                  const std::string& argName,
+                                  const std::string& argValue)
 {
     std::string fileName;
     if (moduleName == pamTally2)
@@ -637,7 +642,7 @@
     return failure;
 }
 
-void UserMgr::userEnable(const std::string &userName, bool enabled)
+void UserMgr::userEnable(const std::string& userName, bool enabled)
 {
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
@@ -647,7 +652,7 @@
         executeCmd("/usr/sbin/usermod", userName.c_str(), "-e",
                    (enabled ? "" : "1970-01-02"));
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Unable to modify user enabled state");
         elog<InternalFailure>();
@@ -670,7 +675,7 @@
 static constexpr size_t t2FailCntIdx = 1;
 static constexpr size_t t2OutputIndex = 1;
 
-bool UserMgr::userLockedForFailedAttempt(const std::string &userName)
+bool UserMgr::userLockedForFailedAttempt(const std::string& userName)
 {
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
@@ -699,7 +704,7 @@
         }
         return false; // User account is un-locked
     }
-    catch (const std::exception &e)
+    catch (const std::exception& e)
     {
         log<level::ERR>("Exception for userLockedForFailedAttempt",
                         entry("WHAT=%s", e.what()));
@@ -707,8 +712,8 @@
     }
 }
 
-bool UserMgr::userLockedForFailedAttempt(const std::string &userName,
-                                         const bool &value)
+bool UserMgr::userLockedForFailedAttempt(const std::string& userName,
+                                         const bool& value)
 {
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
@@ -727,15 +732,14 @@
     return userLockedForFailedAttempt(userName);
 }
 
-bool UserMgr::userPasswordExpired(const std::string &userName)
+bool UserMgr::userPasswordExpired(const std::string& userName)
 {
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
 
     struct spwd spwd
-    {
-    };
-    struct spwd *spwdPtr = nullptr;
+    {};
+    struct spwd* spwdPtr = nullptr;
     auto buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     if (buflen < -1)
     {
@@ -831,13 +835,13 @@
     return userList.size();
 }
 
-bool UserMgr::isUserEnabled(const std::string &userName)
+bool UserMgr::isUserEnabled(const std::string& userName)
 {
     // All user management lock has to be based on /etc/shadow
     phosphor::user::shadow::Lock lock();
     std::array<char, 4096> buffer{};
     struct spwd spwd;
-    struct spwd *resultPtr = nullptr;
+    struct spwd* resultPtr = nullptr;
     int status = getspnam_r(userName.c_str(), &spwd, buffer.data(),
                             buffer.max_size(), &resultPtr);
     if (!status && (&spwd == resultPtr))
@@ -851,13 +855,13 @@
     return false; // assume user is disabled for any error.
 }
 
-std::vector<std::string> UserMgr::getUsersInGroup(const std::string &groupName)
+std::vector<std::string> UserMgr::getUsersInGroup(const std::string& groupName)
 {
     std::vector<std::string> usersInGroup;
     // Should be more than enough to get the pwd structure.
     std::array<char, 4096> buffer{};
     struct group grp;
-    struct group *resultPtr = nullptr;
+    struct group* resultPtr = nullptr;
 
     int status = getgrnam_r(groupName.c_str(), &grp, buffer.data(),
                             buffer.max_size(), &resultPtr);
@@ -895,13 +899,13 @@
         auto reply = bus.call(method);
         reply.read(objects);
     }
-    catch (const InternalFailure &e)
+    catch (const InternalFailure& e)
     {
         log<level::ERR>("Unable to get the User Service",
                         entry("WHAT=%s", e.what()));
         throw;
     }
-    catch (const sdbusplus::exception::SdBusError &e)
+    catch (const sdbusplus::exception::SdBusError& e)
     {
         log<level::ERR>(
             "Failed to excute method", entry("METHOD=%s", "GetManagedObjects"),
@@ -911,12 +915,11 @@
     return objects;
 }
 
-std::string UserMgr::getLdapGroupName(const std::string &userName)
+std::string UserMgr::getLdapGroupName(const std::string& userName)
 {
     struct passwd pwd
-    {
-    };
-    struct passwd *pwdPtr = nullptr;
+    {};
+    struct passwd* pwdPtr = nullptr;
     auto buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
     if (buflen < -1)
     {
@@ -942,7 +945,7 @@
         elog<UserNameDoesNotExist>();
     }
 
-    struct group *groups = nullptr;
+    struct group* groups = nullptr;
     std::string ldapGroupName;
 
     while ((groups = getgrent()) != NULL)
@@ -959,7 +962,7 @@
     return ldapGroupName;
 }
 
-std::string UserMgr::getServiceName(std::string &&path, std::string &&intf)
+std::string UserMgr::getServiceName(std::string&& path, std::string&& intf)
 {
     auto mapperCall = bus.new_method_call(objMapperService, objMapperPath,
                                           objMapperInterface, "GetObject");
@@ -993,7 +996,7 @@
     // Check whether the given user is local user or not.
     if (isUserExist(userName) == true)
     {
-        const auto &user = usersList[userName];
+        const auto& user = usersList[userName];
         userInfo.emplace("UserPrivilege", user.get()->userPrivilege());
         userInfo.emplace("UserGroups", user.get()->userGroups());
         userInfo.emplace("UserEnabled", user.get()->userEnabled());
@@ -1021,14 +1024,14 @@
 
         try
         {
-            for (const auto &obj : objects)
+            for (const auto& obj : objects)
             {
-                for (const auto &interface : obj.second)
+                for (const auto& interface : obj.second)
                 {
                     if ((interface.first ==
                          "xyz.openbmc_project.Object.Enable"))
                     {
-                        for (const auto &property : interface.second)
+                        for (const auto& property : interface.second)
                         {
                             auto value = std::get<bool>(property.second);
                             if ((property.first == "Enabled") &&
@@ -1051,9 +1054,9 @@
                 return userInfo;
             }
 
-            for (const auto &obj : objects)
+            for (const auto& obj : objects)
             {
-                for (const auto &interface : obj.second)
+                for (const auto& interface : obj.second)
                 {
                     if ((interface.first ==
                          "xyz.openbmc_project.User.PrivilegeMapperEntry") &&
@@ -1061,7 +1064,7 @@
                          std::string::npos))
                     {
 
-                        for (const auto &property : interface.second)
+                        for (const auto& property : interface.second)
                         {
                             auto value = std::get<std::string>(property.second);
                             if (property.first == "GroupName")
@@ -1087,7 +1090,7 @@
                 log<level::ERR>("LDAP group privilege mapping does not exist");
             }
         }
-        catch (const std::bad_variant_access &e)
+        catch (const std::bad_variant_access& e)
         {
             log<level::ERR>("Error while accessing variant",
                             entry("WHAT=%s", e.what()));
@@ -1112,7 +1115,7 @@
     if (!userNameList.empty())
     {
         std::map<std::string, std::vector<std::string>> groupLists;
-        for (auto &grp : groupsMgr)
+        for (auto& grp : groupsMgr)
         {
             if (grp == grpSsh)
             {
@@ -1124,17 +1127,17 @@
                 groupLists.emplace(grp, grpUsersList);
             }
         }
-        for (auto &grp : privMgr)
+        for (auto& grp : privMgr)
         {
             std::vector<std::string> grpUsersList = getUsersInGroup(grp);
             groupLists.emplace(grp, grpUsersList);
         }
 
-        for (auto &user : userNameList)
+        for (auto& user : userNameList)
         {
             std::vector<std::string> userGroups;
             std::string userPriv;
-            for (const auto &grp : groupLists)
+            for (const auto& grp : groupLists)
             {
                 std::vector<std::string> tempGrp = grp.second;
                 if (std::find(tempGrp.begin(), tempGrp.end(), user) !=
@@ -1162,7 +1165,7 @@
     }
 }
 
-UserMgr::UserMgr(sdbusplus::bus::bus &bus, const char *path) :
+UserMgr::UserMgr(sdbusplus::bus::bus& bus, const char* path) :
     Ifaces(bus, path, true), bus(bus), path(path)
 {
     UserMgrIface::allPrivileges(privMgr);
@@ -1187,7 +1190,7 @@
             }
             value = static_cast<decltype(value)>(tmp);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("Exception for MinPasswordLength",
                             entry("WHAT=%s", e.what()));
@@ -1213,7 +1216,7 @@
             }
             value = static_cast<decltype(value)>(tmp);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("Exception for RememberOldPasswordTimes",
                             entry("WHAT=%s", e.what()));
@@ -1238,7 +1241,7 @@
             }
             value16 = static_cast<decltype(value16)>(tmp);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("Exception for MaxLoginAttemptBeforLockout",
                             entry("WHAT=%s", e.what()));
@@ -1263,7 +1266,7 @@
             }
             value32 = static_cast<decltype(value32)>(tmp);
         }
-        catch (const std::exception &e)
+        catch (const std::exception& e)
         {
             log<level::ERR>("Exception for AccountUnlockTimeout",
                             entry("WHAT=%s", e.what()));