From 070a3e49fdd8a6ecd5c71f6ee018ebe89ccd7a1f Mon Sep 17 00:00:00 2001 From: Vishwanatha Subbanna Date: Wed, 6 Sep 2017 11:40:45 +0530 Subject: Update shadow password file with new password Change-Id: Ida7c1aba6f17ac6f006f159d08e2638808f3a54c Signed-off-by: Vishwanatha Subbanna --- shadowlock.hpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 shadowlock.hpp (limited to 'shadowlock.hpp') diff --git a/shadowlock.hpp b/shadowlock.hpp new file mode 100644 index 0000000..dc17b5a --- /dev/null +++ b/shadowlock.hpp @@ -0,0 +1,52 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +namespace phosphor +{ +namespace user +{ +namespace shadow +{ + +using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; +using namespace phosphor::logging; + +/** @class Lock + * @brief Responsible for locking and unlocking /etc/shadow + */ +class Lock +{ + public: + Lock(const Lock&) = delete; + Lock& operator=(const Lock&) = delete; + Lock(Lock&&) = delete; + Lock& operator=(Lock&&) = delete; + + /** @brief Default constructor that just locks the shadow file */ + Lock() + { + if (!lckpwdf()) + { + log("Locking Shadow failed"); + elog(); + } + } + ~Lock() + { + if(!ulckpwdf()) + { + log("Un-Locking Shadow failed"); + elog(); + } + } +}; + +} // namespace shadow +} // namespace user +} // namespace phosphor -- cgit v1.2.1