From 4654d99fda30800024c56b085ec9dcf2ac26c417 Mon Sep 17 00:00:00 2001 From: Richard Marian Thomaiyar Date: Thu, 19 Apr 2018 05:38:37 +0530 Subject: Add first user layer support. Exposes user layer library which will be used by both apphandler and netipmid for RAKP. Password is decrypted from the special file which is used by pam-ipmi. Change-Id: Ia6b99d4359a03843f19cd0e18f7269ad2e3cdb44 Signed-off-by: Richard Marian Thomaiyar --- user_channel/shadowlock.hpp | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 user_channel/shadowlock.hpp (limited to 'user_channel/shadowlock.hpp') diff --git a/user_channel/shadowlock.hpp b/user_channel/shadowlock.hpp new file mode 100644 index 0000000..8b09f21 --- /dev/null +++ b/user_channel/shadowlock.hpp @@ -0,0 +1,50 @@ +#pragma once + +#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