summaryrefslogtreecommitdiffstats
path: root/user_channel/shadowlock.hpp
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2018-04-19 05:38:37 +0530
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2018-11-13 11:18:24 +0530
commit4654d99fda30800024c56b085ec9dcf2ac26c417 (patch)
tree4fdd7d29ac2d2914a7c5f837ef223881743d177d /user_channel/shadowlock.hpp
parent331f5d510b9061820bff0081b161bfea09407b0b (diff)
downloadphosphor-host-ipmid-4654d99fda30800024c56b085ec9dcf2ac26c417.tar.gz
phosphor-host-ipmid-4654d99fda30800024c56b085ec9dcf2ac26c417.zip
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 <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'user_channel/shadowlock.hpp')
-rw-r--r--user_channel/shadowlock.hpp50
1 files changed, 50 insertions, 0 deletions
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 <shadow.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+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<level::ERR>("Locking Shadow failed");
+ elog<InternalFailure>();
+ }
+ }
+ ~Lock()
+ {
+ if (!ulckpwdf())
+ {
+ log<level::ERR>("Un-Locking Shadow failed");
+ elog<InternalFailure>();
+ }
+ }
+};
+
+} // namespace shadow
+} // namespace user
+} // namespace phosphor
OpenPOWER on IntegriCloud