Basic support for User manager service

Basic support for User Manager service methods
are implemented.

Change-Id: Id42432ec6dd421b99971268add931dcd70876f7c
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/user.cpp b/user.cpp
index 447bfcd..6999a98 100644
--- a/user.cpp
+++ b/user.cpp
@@ -40,10 +40,10 @@
 constexpr int SALT_LENGTH = 16;
 
 using namespace phosphor::logging;
-using InsufficientPermission = sdbusplus::xyz::openbmc_project::Common::
-                                    Error::InsufficientPermission;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
-                                    Error::InternalFailure;
+using InsufficientPermission =
+    sdbusplus::xyz::openbmc_project::Common::Error::InsufficientPermission;
+using InternalFailure =
+    sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 // Sets or updates the password
 void User::setPassword(std::string newPassword)
 {
@@ -68,15 +68,14 @@
 }
 
 void User::applyPassword(const std::string& shadowFile,
-                         const std::string& password,
-                         const std::string& salt)
+                         const std::string& password, const std::string& salt)
 {
     // Needed by getspnam_r
     struct spwd shdp;
     struct spwd* pshdp;
 
     // This should be fine even if SHA512 is used.
-    std::array<char,1024> buffer{};
+    std::array<char, 1024> buffer{};
 
     // Open the shadow file for reading
     phosphor::user::File shadow(shadowFile, "r");
@@ -87,10 +86,10 @@
 
     // open temp shadow file, by suffixing random name in shadow file name.
     std::vector<char> tempFileName(shadowFile.begin(), shadowFile.end());
-    std::vector<char> fileTemplate = {
-                             '_', '_', 'X', 'X', 'X', 'X', 'X', 'X', '\0' };
-    tempFileName.insert(
-              tempFileName.end(), fileTemplate.begin(), fileTemplate.end());
+    std::vector<char> fileTemplate = {'_', '_', 'X', 'X', 'X',
+                                      'X', 'X', 'X', '\0'};
+    tempFileName.insert(tempFileName.end(), fileTemplate.begin(),
+                        fileTemplate.end());
 
     int fd = mkstemp(tempFileName.data());
     if (fd == -1)
@@ -112,7 +111,9 @@
 
     // Change the permission of this new temp file
     // to be same as shadow so that it's secure
-    struct stat st{};
+    struct stat st
+    {
+    };
     auto r = fstat(fileno((shadow)()), &st);
     if (r < 0)
     {
@@ -184,15 +185,13 @@
     }
     else
     {
-        log<level::ERR>(errMsg.c_str(),
-                entry("USER=%s",user.c_str()),
-                    entry("ERRNO=%d", errNo));
+        log<level::ERR>(errMsg.c_str(), entry("USER=%s", user.c_str()),
+                        entry("ERRNO=%d", errNo));
         elog<InternalFailure>();
     }
 }
 
-std::string User::hashPassword(char* spPwdp,
-                               const std::string& password,
+std::string User::hashPassword(char* spPwdp, const std::string& password,
                                const std::string& salt)
 {
     // Parse and get crypt algo
@@ -200,7 +199,7 @@
     if (cryptAlgo.empty())
     {
         log<level::ERR>("Error finding crypt algo",
-                entry("USER=%s",user.c_str()));
+                        entry("USER=%s", user.c_str()));
         elog<InternalFailure>();
     }
 
@@ -226,7 +225,7 @@
     // Standard mersenne_twister_engine seeded with rd()
     std::mt19937 gen(rd());
 
-    std::uniform_int_distribution<> dis(0, set.size()-1);
+    std::uniform_int_distribution<> dis(0, set.size() - 1);
     for (int count = 0; count < length; count++)
     {
         // Use dis to transform the random unsigned int generated by