Change manifest file path into each home directories 56/89656/1 accepted/tizen/3.0/common/20161114.110006 accepted/tizen/3.0/ivi/20161011.044408 accepted/tizen/3.0/mobile/20161015.033536 accepted/tizen/3.0/tv/20161016.004752 accepted/tizen/3.0/wearable/20161015.083304 accepted/tizen/common/20160926.154142 accepted/tizen/ivi/20160927.020907 accepted/tizen/mobile/20160927.020851 accepted/tizen/tv/20160927.020712 accepted/tizen/wearable/20160927.020831 submit/tizen/20160926.005548 submit/tizen_3.0_common/20161104.104000 submit/tizen_3.0_ivi/20161010.000003 submit/tizen_3.0_mobile/20161015.000003 submit/tizen_3.0_tv/20161015.000002 submit/tizen_3.0_wearable/20161015.000003
authorSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 26 Sep 2016 08:42:58 +0000 (17:42 +0900)
committerSungbae Yoo <sungbae.yoo@samsung.com>
Mon, 26 Sep 2016 08:44:09 +0000 (17:44 +0900)
Signed-off-by: Sungbae Yoo <sungbae.yoo@samsung.com>
Change-Id: Ife496f7bf33b129120cf5eb6c34818e713d82e6d

CMakeLists.txt
module/CMakeLists.txt
module/krate.cpp
packaging/krate.spec
server/CMakeLists.txt
server/manager.cpp

index c7e3422..bb54602 100755 (executable)
@@ -80,10 +80,6 @@ IF(NOT DEFINED SYSTEMD_UNIT_DIR)
        SET(SYSTEMD_UNIT_DIR "${CMAKE_INSTALL_PREFIX}/lib/systemd/system")
 ENDIF(NOT DEFINED SYSTEMD_UNIT_DIR)
 
-IF(NOT DEFINED CONF_DIR)
-       SET(CONF_INSTALL_DIR "${SYSCONF_INSTALL_DIR}/krate")
-ENDIF(NOT DEFINED CONF_DIR)
-
 ADD_DEFINITIONS(-DUG_WAYLAND)
 
 ADD_SUBDIRECTORY(${KRATE_LIB})
index ab4f5e3..9a7295f 100644 (file)
@@ -44,10 +44,6 @@ PKG_CHECK_MODULES(PAM_DEPS   REQUIRED
 INCLUDE_DIRECTORIES(${PAM_INCLUDE_DIR} ${PAM_DEPS_INCLUDE_DIRS})
 TARGET_LINK_LIBRARIES(${PAM_NAME} ${PAM_LIBRARY} ${PAM_DEPS_LIBRARIES} pthread)
 
-TARGET_COMPILE_DEFINITIONS(${PAM_NAME} PRIVATE
-       CONF_PATH="${CONF_DIR}"
-)
-
 CONFIGURE_FILE(pam.d/systemd-user.in pam.d/systemd-user-${PROJECT_NAME})
 
 INSTALL(TARGETS ${PAM_NAME} DESTINATION ${LIB_INSTALL_DIR}/security)
index b81a901..409b12e 100644 (file)
@@ -40,7 +40,7 @@
 
 std::string buildKrateManifestPath(const std::string& name)
 {
-       return CONF_PATH "/" + name + ".xml";
+       return "/home/" + name + "/.config/krate/krate.xml";
 }
 
 std::string getKrateName(pam_handle_t* handle)
index 62c6508..9454f00 100644 (file)
@@ -41,7 +41,6 @@ krates.
 %attr(644,root,root) %{TZ_SYS_RO_ICONS}/krate/shortcut_icon.png
 %attr(644,root,root) %{TZ_SYS_RO_ICONS}/krate/indicator_icon.png
 %attr(644,root,root) %{TZ_SYS_RO_ICONS}/krate/notification_sub_icon.png
-#%attr(700,root,root) %dir %{TZ_SYS_ETC}/krate
 %attr(755,root,root) %{_libdir}/security/pam_krate.so
 %attr(700,root,root) %{_sbindir}/krate-admin-cli
 %config /etc/pam.d/*
@@ -67,7 +66,6 @@ krates.
          -DHOME_DIR=%{TZ_SYS_HOME} \
          -DSYSTEMD_UNIT_DIR=%{_unitdir} \
          -DPAMD_DIR=/etc/pam.d \
-         -DCONF_DIR=%{TZ_SYS_ETC}/krate \
          -DICON_DIR="%{TZ_SYS_RO_ICONS}/krate" \
          -DAPP_INSTALL_PREFIX="%{TZ_SYS_RO_APP}" \
          -DAPP_SHARE_PACKAGES_DIR="%{TZ_SYS_RO_PACKAGES}"
index c973a82..91bc477 100644 (file)
@@ -55,7 +55,6 @@ SET_TARGET_PROPERTIES(${SERVER_NAME} PROPERTIES COMPILE_FLAGS "-fPIE")
 SET_TARGET_PROPERTIES(${SERVER_NAME} PROPERTIES LINK_FLAGS "-pie")
 
 TARGET_COMPILE_DEFINITIONS(${SERVER_NAME} PRIVATE
-       CONF_PATH="${CONF_DIR}"
        RUN_PATH="${RUN_DIR}"
        ICON_PATH="${ICON_DIR}"
 )
index ec6f58a..ad7fb6a 100644 (file)
@@ -25,6 +25,7 @@
 #include <tzplatform_config.h>
 #include <auth-passwd-admin.h>
 #include <gum/gum-user.h>
+#include <gum/gum-user-service.h>
 #include <gum/common/gum-user-types.h>
 #include <klay/error.h>
 #include <klay/process.h>
@@ -191,17 +192,35 @@ int packageEventHandler(uid_t target_uid, int req_id,
        return 0;
 }
 
-void initializeCreatedKrateList() {
-       try {
-               runtime::DirectoryIterator iter(CONF_PATH "/"), end;
+void initializeCreatedKrateList()
+{
+       const gchar *type[] = {"security", NULL};
+       gchar *username;
+       GumUserService *service;
+       GumUserList *users;
+       GumUser *user;
+
+       service = gum_user_service_create_sync(FALSE);
+       if (!service) {
+               return;
+       }
+
+       users = gum_user_service_get_user_list_sync(service, type);
+       if (!users) {
+               return;
+       }
 
-               while (iter != end) {
-                       const std::string& file = iter->getName();
-                       const std::string& name(file.substr(0, file.rfind(".xml")));
-                       createdKrateList.push_back(name);
-                       ++iter;
+       for (GumUserList *src_list = users; src_list != NULL; src_list = g_list_next(src_list)) {
+               user = (GumUser*) src_list->data;
+               if (user) {
+                       g_object_get(G_OBJECT(user), "username", &username, NULL);
+                       createdKrateList.push_back(username);
+                       g_free(username);
                }
-       } catch (runtime::Exception& e) {}
+       }
+
+       gum_user_service_list_free(users);
+       g_object_unref(service);
 }
 
 #define NT_TITLE     NOTIFICATION_TEXT_TYPE_TITLE
@@ -536,13 +555,21 @@ int Manager::createKrate(const std::string& name, const std::string& manifest)
 
                        maskUserServices(user);
 
+                   ::tzplatform_set_user(user.getUid());
+                       runtime::File confDir(std::string(::tzplatform_getenv(TZ_USER_HOME)) + "/.config/krate");
+                   ::tzplatform_reset_user();
+                       if (!confDir.exists()) {
+                               confDir.makeDirectory(true);
+                               confDir.chmod(700);
+                       }
+
                        manifestFile.reset(xml::Parser::parseString(manifest));
                        //write container author info
                        if (!pkgId.empty()) {
                                std::cout << manifestFile->getRootNode().getName() << std::endl;
                                manifestFile->getRootNode().addNewChild("author").setContent(pkgId);
                        }
-                       manifestFile->write(CONF_PATH "/" + name + ".xml", "UTF-8", true);
+                       manifestFile->write(confDir.getPath() + "/" + name + ".xml", "UTF-8", true);
 
                        //unlock the user
                        setKrateState(user.getUid(), 1);
@@ -571,7 +598,13 @@ int Manager::removeKrate(const std::string& name)
        std::unique_ptr<xml::Document> manifestFile;
        bool canRemove = false;
 
-       manifestFile.reset(xml::Parser::parseFile(CONF_PATH "/" + name + ".xml"));
+       runtime::User user(name);
+    ::tzplatform_set_user(user.getUid());
+       std::string confPath(::tzplatform_getenv(TZ_USER_HOME));
+       confPath += "/.config/krate";
+    ::tzplatform_reset_user();
+
+       manifestFile.reset(xml::Parser::parseFile(confPath + "/" + name + ".xml"));
        xml::Node::NodeList authors = manifestFile->evaluate("/manifest/author");
        for (const xml::Node& author : authors) {
                if (author.getContent() == pkgId) {