diff options
-rw-r--r-- | Makefile.am | 9 | ||||
-rw-r--r-- | configure.ac | 7 | ||||
-rw-r--r-- | mainapp.cpp | 28 | ||||
-rw-r--r-- | user.cpp | 28 | ||||
-rw-r--r-- | user.hpp | 62 |
5 files changed, 134 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index 6fc724c..472dd06 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,13 @@ sbin_PROGRAMS = phosphor-user-manager +noinst_HEADERS = user.hpp + phosphor_user_manager_SOURCES = \ + user.cpp \ mainapp.cpp + +phosphor_user_manager_LDFLAGS = $(SDBUSPLUS_LIBS) \ + $(PHOSPHOR_DBUS_INTERFACES_LIBS) + +phosphor_user_manager_CXXFLAGS = $(SYSTEMD_CFLAGS) \ + $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) diff --git a/configure.ac b/configure.ac index 59dfe11..9144029 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,13 @@ AC_PROG_CXX AC_PROG_INSTALL AC_PROG_MAKE_SET +# Checks for libraries. +PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, [AC_MSG_ERROR([Could not find sdbusplus...openbmc/sdbusplus package required])]) +PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, [AC_MSG_ERROR([Could not find phosphor-dbus-interfaces...openbmc/phosphor-dbus-interfaces package required])]) + +AC_ARG_VAR(USER_MANAGER_BUSNAME, [The Dbus busname to own]) +AS_IF([test "x$USER_MANAGER_BUSNAME" == "x"], [USER_MANAGER_BUSNAME="xyz.openbmc_project.User.Manager"]) +AC_DEFINE_UNQUOTED([USER_MANAGER_BUSNAME], ["$USER_MANAGER_BUSNAME"], [The DBus busname to own]) # Checks for typedefs, structures, and compiler characteristics. AX_CXX_COMPILE_STDCXX_14([noext]) diff --git a/mainapp.cpp b/mainapp.cpp index 1f450ac..04c7825 100644 --- a/mainapp.cpp +++ b/mainapp.cpp @@ -13,8 +13,36 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#include <string> +#include "user.hpp" +#include "config.h" + +// D-Bus root for user manager +constexpr auto USER_MANAGER_ROOT = "/xyz/openbmc_project/user"; int main(int argc, char** argv) { + auto bus = sdbusplus::bus::new_default(); + + // This is hard coded "root" user. + // TODO: This would need to be changed when the complete + // user management code is written. May be, have manager + // create these user objects. + // Issue: openbmc/openbmc#2299 + auto objPath = std::string{USER_MANAGER_ROOT} + '/' + "root"; + + sdbusplus::server::manager::manager objManager(bus, USER_MANAGER_ROOT); + phosphor::user::User user(bus, objPath.c_str()); + + // Claim the bus now + bus.request_name(USER_MANAGER_BUSNAME); + + // Wait for client request + while(true) + { + // process dbus calls / signals discarding unhandled + bus.process_discard(); + bus.wait(); + } return 0; } diff --git a/user.cpp b/user.cpp new file mode 100644 index 0000000..0a6727b --- /dev/null +++ b/user.cpp @@ -0,0 +1,28 @@ +/** + * Copyright © 2017 IBM Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "user.hpp" +namespace phosphor +{ +namespace user +{ + +void User::setPassword(std::string newPassword) +{ + return; +} + +} // namespace user +} // namespace phosphor diff --git a/user.hpp b/user.hpp new file mode 100644 index 0000000..25c7e62 --- /dev/null +++ b/user.hpp @@ -0,0 +1,62 @@ +#pragma once + +#include <string> +#include <sdbusplus/bus.hpp> +#include <sdbusplus/server/object.hpp> +#include <xyz/openbmc_project/User/Password/server.hpp> +namespace phosphor +{ +namespace user +{ + +namespace Base = sdbusplus::xyz::openbmc_project::User::server; +using Interface = sdbusplus::server::object::object<Base::Password>; + +/** @class User + * @brief Responsible for managing a specific user account. + * It is implementing just the Password interface + * for now. + */ +class User : public Interface +{ + public: + User() = delete; + ~User() = default; + User(const User&) = delete; + User& operator=(const User&) = delete; + User(User&&) = delete; + User& operator=(User&&) = delete; + + /** @brief Constructs User object. + * + * @param[in] bus - sdbusplus handler + * @param[in] path - D-Bus path + */ + User(sdbusplus::bus::bus& bus, const char* path) + : Interface(bus, path), + bus(bus), + path(path) + { + // Do nothing + } + + /** @brief user password set method. If this is called for + * a user ID that already has the password, the password + * would be updated, else password would be created. + * Since this needs an already authenticated session, + * old password is not needed. + * + * @param[in] newPassword - New password + */ + void setPassword(std::string newPassword) override; + + private: + /** @brief sdbusplus handler */ + sdbusplus::bus::bus& bus; + + /** @brief object path */ + const std::string& path; +}; + +} // namespace user +} // namespace phosphor |