SET(TARGET_CMD "security-manager-cmd")
SET(TARGET_CLEANUP "security-manager-cleanup")
SET(TARGET_NSS "security-manager-nss")
+SET(TARGET_INITDB "security-manager-init-db")
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(pc)
systemctl daemon-reload
if [ $1 = 1 ]; then
# installation
- security-manager-cmd --init-db
+ security-manager-init-db
systemctl start security-manager.service security-manager.socket
fi
if [ $1 = 2 ]; then
# update
systemctl stop security-manager.service security-manager.socket
- security-manager-cmd --init-db
+ security-manager-init-db
systemctl start security-manager.service security-manager.socket
fi
%attr(755,root,root) %{_bindir}/security-manager
%attr(755,root,root) %{_bindir}/security-manager-cmd
%attr(755,root,root) %{_bindir}/security-manager-cleanup
+%attr(755,root,root) %{_bindir}/security-manager-init-db
%attr(755,root,root) %{_sysconfdir}/gumd/useradd.d/50_security-manager-add.post
%attr(755,root,root) %{_sysconfdir}/gumd/userdel.d/50_security-manager-remove.pre
%config(noreplace) %attr(444,root,root) %{TZ_SYS_VAR}/security-manager/apps-labels
${INCLUDE_PATH}
${COMMON_PATH}/include
${DPL_PATH}/core/include
- ${DPL_PATH}/db/include
${DPL_PATH}/log/include
)
#include <config.h>
#include <filesystem.h>
-#include <privilege_db.h>
namespace po = boost::program_options;
("manage-users,m", po::value<std::string>(), "add or remove user, parameter is either a/add or r/remove")
("manage-privilege,o", po::value<std::string>(), "allow or deny privilege, parameter is either a/allow or d/deny")
("backup,b", "make a backup of the database file")
- ("init-db,d", "initialize the security-manager database as when running the manager")
;
return opts;
}
if (SECURITY_MANAGER_SUCCESS == FS::overwriteFile(Config::getPrivilegeDbPath(),
Config::getPrivilegeDbFallbackPath()))
return EXIT_SUCCESS;
- } else if (vm.count("init-db")) {
- SecurityManager::initDb();
- return EXIT_SUCCESS;
} else {
std::cout << "No command argument was given." << std::endl;
usage(std::string(argv[0]));
TARGET_LINK_LIBRARIES(${TARGET_CLEANUP}
${TARGET_COMMON}
)
+
+########## INIT-DB SERVICE ######################################
+SET(INITDB_SOURCES
+ ${SERVER_PATH}/init-db/security-manager-init-db.cpp
+ )
+ADD_EXECUTABLE(${TARGET_INITDB} ${INITDB_SOURCES})
+SET_TARGET_PROPERTIES(${TARGET_INITDB}
+ PROPERTIES
+ COMPILE_FLAGS "-D_GNU_SOURCE -fvisibility=hidden")
+
+TARGET_LINK_LIBRARIES(${TARGET_INITDB}
+ ${TARGET_COMMON}
+ )
+
INSTALL(TARGETS ${TARGET_CLEANUP} DESTINATION ${BIN_INSTALL_DIR})
+INSTALL(TARGETS ${TARGET_INITDB} DESTINATION ${BIN_INSTALL_DIR})
INSTALL(TARGETS ${TARGET_SERVER} DESTINATION ${BIN_INSTALL_DIR})
-
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Rafal Krypa <r.krypa@samsung.com>
+ *
+ * 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
+ */
+/*
+ * @file security-manager-init-db.cpp
+ * @author Dariusz Michaluk (d.michaluk@samsung.com)
+ * @version 1.0
+ * @brief Implementation of security-manager-init-db service
+ */
+
+#include <iostream>
+#include <privilege_db.h>
+
+int main(void)
+{
+ try {
+ SecurityManager::initDb();
+ return EXIT_SUCCESS;
+ } catch (...) {
+ std::cerr << "Unknown exception thrown" << std::endl;
+ }
+
+ return EXIT_FAILURE;
+}