summaryrefslogtreecommitdiffstats
path: root/user.hpp
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-09-06 11:40:45 +0530
committerVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-10-12 23:36:37 +0530
commit070a3e49fdd8a6ecd5c71f6ee018ebe89ccd7a1f (patch)
tree7de0f5d48d4e408472194e369395ef563053eab5 /user.hpp
parentbdb298f744cc71421f0c2e6f50254f933c6bb3cc (diff)
downloadphosphor-user-manager-070a3e49fdd8a6ecd5c71f6ee018ebe89ccd7a1f.tar.gz
phosphor-user-manager-070a3e49fdd8a6ecd5c71f6ee018ebe89ccd7a1f.zip
Update shadow password file with new password
Change-Id: Ida7c1aba6f17ac6f006f159d08e2638808f3a54c Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
Diffstat (limited to 'user.hpp')
-rw-r--r--user.hpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/user.hpp b/user.hpp
index aa40820..4c18c7a 100644
--- a/user.hpp
+++ b/user.hpp
@@ -65,6 +65,24 @@ class User : public Interface
/** @brief User id extracted from object path */
const std::string user;
+ /** @brief Returns a random string from set [A-Za-z0-9./]
+ * of length size
+ *
+ * @param[in] numChars - length of string
+ */
+ static const std::string randomString(int length);
+
+ /** @brief Returns password hash created with crypt algo,
+ * salt and password
+ *
+ * @param[in] spPwdp - sp_pwdp of struct spwd
+ * @param[in] password - clear text password
+ * @param[in] salt - Random salt
+ */
+ std::string hashPassword(char* spPwdp,
+ const std::string& password,
+ const std::string& salt);
+
/** @brief Extracts crypto number from the shadow entry for user
*
* @param[in] spPwdp - sp_pwdp of struct spwd
@@ -81,7 +99,7 @@ class User : public Interface
static std::string generateHash(const std::string& password,
const std::string& salt);
- /** @brief returns salt string with $ delimiter.
+ /** @brief Returns salt string with $ delimiter.
* Eg: If crypt is 1 and salt is HELLO, returns $1$HELLO$
*
* @param[in] crypt - Crypt number in string
@@ -89,6 +107,19 @@ class User : public Interface
*/
static std::string getSaltString(const std::string& crypt,
const std::string& salt);
+
+ /** @brief Applies the password for a given user.
+ * Writes shadow entries into a temp file
+ *
+ * @param[in] shadowFile - shadow password file
+ * @param[in] tempFile - Temporary file
+ * @param[in] password - clear text password
+ * @param[in] salt - salt
+ */
+ void applyPassword(const std::string& shadowFile,
+ const std::string& tempFile,
+ const std::string& password,
+ const std::string& salt);
};
} // namespace user
OpenPOWER on IntegriCloud