summaryrefslogtreecommitdiffstats
path: root/templates/html5/app/Frontend/widgets/Notifications
AgeCommit message (Expand)AuthorFilesLines
2018-10-15Git repo can be used as submodulesRomain Forlot3-297/+0
2018-10-15Rename to more meaningful name directoriesRomain Forlot3-0/+297
a id='n12' href='#n12'>12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
From 6c96a39ba7a7763ccd47e379dbfd8d376164985f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jos=C3=A9=20Bollo?= <jose.bollo@iot.bzh>
Date: Mon, 16 Nov 2015 14:26:25 +0100
Subject: [PATCH 13/14] Removing tizen-platform-config

Change-Id: Ic832a2b75229517b09faba969c27fb1a4b490121
---
 CMakeLists.txt                                | 16 +++++++-
 db/CMakeLists.txt                             |  2 +-
 policy/CMakeLists.txt                         |  1 +
 ...load => security-manager-policy-reload.in} |  4 +-
 src/common/file-lock.cpp                      |  4 +-
 src/common/include/file-lock.h                |  1 -
 src/common/include/privilege_db.h             |  3 +-
 src/common/service_impl.cpp                   | 39 ++++++-------------
 src/common/smack-rules.cpp                    | 12 ++----
 9 files changed, 37 insertions(+), 45 deletions(-)
 rename policy/{security-manager-policy-reload => security-manager-policy-reload.in} (94%)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28790d8..37a43cc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,7 +49,7 @@ ADD_DEFINITIONS("-Wall")                        # Generate all warnings
 ADD_DEFINITIONS("-Wextra")                      # Generate even more extra warnings
 
 STRING(REGEX MATCH "([^.]*)" API_VERSION "${VERSION}")
-ADD_DEFINITIONS("-DAPI_VERSION=\"$(API_VERSION)\"")
+ADD_DEFINITIONS("-DAPI_VERSION=\"${API_VERSION}\"")
 
 ADD_DEFINITIONS("-DSMACK_ENABLED")
 
@@ -58,6 +58,20 @@ IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
     ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
 ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
 
+SET(DATADIR        "/usr/share/security-manager" CACHE STRING "path to data directory")
+SET(SMACKRULESDIR  "/etc/smack/accesses.d"       CACHE STRING "path to Smack rules directory")
+SET(LOCKDIR        "/var/run/lock"               CACHE STRING "path to lock directory")
+SET(DB_INSTALL_DIR "/var/db/security-manager"    CACHE STRING "path to database directory")
+SET(DB_FILENAME    ".security-manager.db"        CACHE STRING "basename of database")
+SET(GLOBALUSER     "userapp"                     CACHE STRING "name of the global user")
+
+ADD_DEFINITIONS("-DDATADIR=\"${DATADIR}\"")
+ADD_DEFINITIONS("-DSMACKRULESDIR=\"${SMACKRULESDIR}\"")
+ADD_DEFINITIONS("-DLOCKDIR=\"${LOCKDIR}\"")
+ADD_DEFINITIONS("-DDB_INSTALL_DIR=\"${DB_INSTALL_DIR}\"")
+ADD_DEFINITIONS("-DDB_FILENAME=\"${DB_FILENAME}\"")
+ADD_DEFINITIONS("-DGLOBALUSER=\"${GLOBALUSER}\"")
+
 ADD_SUBDIRECTORY(src)
 ADD_SUBDIRECTORY(pc)
 ADD_SUBDIRECTORY(systemd)
diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt
index 9e8ffcc..d7af1a0 100644
--- a/db/CMakeLists.txt
+++ b/db/CMakeLists.txt
@@ -1,4 +1,4 @@
-SET(TARGET_DB ".security-manager.db")
+SET(TARGET_DB "$(DB_FILENAME)")
 
 ADD_CUSTOM_COMMAND(
     OUTPUT ${TARGET_DB} ${TARGET_DB}-journal
diff --git a/policy/CMakeLists.txt b/policy/CMakeLists.txt
index bd08edc..626a2bd 100644
--- a/policy/CMakeLists.txt
+++ b/policy/CMakeLists.txt
@@ -1,4 +1,5 @@
 FILE(GLOB USERTYPE_POLICY_FILES usertype-*.profile)
+CONFIGURE_FILE(security-manager-policy-reload.in security-manager-policy-reload @ONLY)
 INSTALL(FILES ${USERTYPE_POLICY_FILES} DESTINATION ${SHARE_INSTALL_PREFIX}/security-manager/policy)
 INSTALL(FILES "app-rules-template.smack" DESTINATION ${SHARE_INSTALL_PREFIX}/security-manager/policy)
 INSTALL(FILES "privilege-group.list" DESTINATION ${SHARE_INSTALL_PREFIX}/security-manager/policy)
diff --git a/policy/security-manager-policy-reload b/policy/security-manager-policy-reload.in
similarity index 94%
rename from policy/security-manager-policy-reload
rename to policy/security-manager-policy-reload.in
index 6f211c6..c1bc4e2 100755
--- a/policy/security-manager-policy-reload
+++ b/policy/security-manager-policy-reload.in
@@ -1,8 +1,8 @@
 #!/bin/sh -e
 
-POLICY_PATH=/usr/share/security-manager/policy
+POLICY_PATH=@DATADIR@/policy
 PRIVILEGE_GROUP_MAPPING=$POLICY_PATH/privilege-group.list
-DB_FILE=`tzplatform-get TZ_SYS_DB | cut -d= -f2`/.security-manager.db
+DB_FILE=@DB_INSTALL_DIR@/@DB_FILENAME@
 
 # Create default buckets
 while read bucket default_policy
diff --git a/src/common/file-lock.cpp b/src/common/file-lock.cpp
index 6f3996c..88d2092 100644
--- a/src/common/file-lock.cpp
+++ b/src/common/file-lock.cpp
@@ -30,9 +30,7 @@
 
 namespace SecurityManager {
 
-char const * const SERVICE_LOCK_FILE = tzplatform_mkpath3(TZ_SYS_RUN,
-                                                         "lock",
-                                                         "security-manager.lock");
+char const * const SERVICE_LOCK_FILE = LOCKDIR "/security-manager.lock";
 
 FileLocker::FileLocker(const std::string &lockFile, bool blocking)
 {
diff --git a/src/common/include/file-lock.h b/src/common/include/file-lock.h
index 604b019..21a86a0 100644
--- a/src/common/include/file-lock.h
+++ b/src/common/include/file-lock.h
@@ -29,7 +29,6 @@
 
 #include <dpl/exception.h>
 #include <dpl/noncopyable.h>
-#include <tzplatform_config.h>
 
 namespace SecurityManager {
 
diff --git a/src/common/include/privilege_db.h b/src/common/include/privilege_db.h
index 08fb9d6..3344987 100644
--- a/src/common/include/privilege_db.h
+++ b/src/common/include/privilege_db.h
@@ -35,14 +35,13 @@
 #include <vector>
 
 #include <dpl/db/sql_connection.h>
-#include <tzplatform_config.h>
 
 #ifndef PRIVILEGE_DB_H_
 #define PRIVILEGE_DB_H_
 
 namespace SecurityManager {
 
-const char *const PRIVILEGE_DB_PATH = tzplatform_mkpath(TZ_SYS_DB, ".security-manager.db");
+const char *const PRIVILEGE_DB_PATH = DB_INSTALL_DIR "/" DB_FILENAME;
 
 enum class QueryType {
     EGetPkgPrivileges,
diff --git a/src/common/service_impl.cpp b/src/common/service_impl.cpp
index ae305d3..42150fe 100644
--- a/src/common/service_impl.cpp
+++ b/src/common/service_impl.cpp
@@ -32,7 +32,6 @@
 #include <algorithm>
 
 #include <dpl/log/log.h>
-#include <tzplatform_config.h>
 
 #include "protocols.h"
 #include "privilege_db.h"
@@ -131,7 +130,13 @@ static inline int validatePolicy(policy_entry &policyEntry, std::string uidStr,
 
 static uid_t getGlobalUserId(void)
 {
-    static uid_t globaluid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+    static uid_t globaluid = 0;
+    if (!globaluid) {
+        struct passwd pw, *p;
+        char buf[4096];
+        int rc = getpwnam_r(GLOBALUSER, &pw, buf, sizeof buf, &p);
+        globaluid = (rc || p == NULL) ? 555 : p->pw_uid;
+    }
     return globaluid;
 }
 
@@ -161,37 +166,17 @@ static inline bool isSubDir(const char *parent, const char *subdir)
 
 static bool getUserAppDir(const uid_t &uid, std::string &userAppDir)
 {
-    struct tzplatform_context *tz_ctx = nullptr;
-
-    if (tzplatform_context_create(&tz_ctx))
-            return false;
-
-    if (tzplatform_context_set_user(tz_ctx, uid)) {
-        tzplatform_context_destroy(tz_ctx);
-        tz_ctx = nullptr;
+    struct passwd pw, *p;
+    char buf[4096];
+    int rc = getpwuid_r(uid, &pw, buf, sizeof buf, &p);
+    if (rc || p == NULL)
         return false;
-    }
-
-    enum tzplatform_variable id =
-            (uid == getGlobalUserId()) ? TZ_SYS_RW_APP : TZ_USER_APP;
-    const char *appDir = tzplatform_context_getenv(tz_ctx, id);
-    if (!appDir) {
-        tzplatform_context_destroy(tz_ctx);
-        tz_ctx = nullptr;
-        return false;
-    }
-
-    userAppDir = appDir;
-
-    tzplatform_context_destroy(tz_ctx);
-    tz_ctx = nullptr;
-
+    userAppDir = p->pw_dir;
     return true;
 }
 
 static inline bool installRequestAuthCheck(const app_inst_req &req, uid_t uid, bool &isCorrectPath, std::string &appPath)
 {
-    std::string userHome;
     std::string userAppDir;
     std::stringstream correctPath;
 
diff --git a/src/common/smack-rules.cpp b/src/common/smack-rules.cpp
index 922a56f..c2e0041 100644
--- a/src/common/smack-rules.cpp
+++ b/src/common/smack-rules.cpp
@@ -34,7 +34,6 @@
 #include <memory>
 
 #include <dpl/log/log.h>
-#include <tzplatform_config.h>
 
 #include "smack-labels.h"
 #include "smack-rules.h"
@@ -43,7 +42,7 @@ namespace SecurityManager {
 
 const char *const SMACK_APP_LABEL_TEMPLATE     = "~APP~";
 const char *const SMACK_PKG_LABEL_TEMPLATE     = "~PKG~";
-const char *const APP_RULES_TEMPLATE_FILE_PATH = tzplatform_mkpath4(TZ_SYS_SHARE, "security-manager", "policy", "app-rules-template.smack");
+const char *const APP_RULES_TEMPLATE_FILE_PATH = DATADIR "/policy/app-rules-template.smack";
 const char *const SMACK_APP_IN_PACKAGE_PERMS   = "rwxat";
 
 SmackRules::SmackRules()
@@ -237,14 +236,12 @@ void SmackRules::generatePackageCrossDeps(const std::vector<std::string> &pkgCon
 
 std::string SmackRules::getPackageRulesFilePath(const std::string &pkgId)
 {
-    std::string path(tzplatform_mkpath3(TZ_SYS_SMACK, "accesses.d", ("pkg_" + pkgId).c_str()));
-    return path;
+    return SMACKRULESDIR "/pkg_" + pkgId;
 }
 
 std::string SmackRules::getApplicationRulesFilePath(const std::string &appId)
 {
-    std::string path(tzplatform_mkpath3(TZ_SYS_SMACK, "accesses.d", ("app_" +  appId).c_str()));
-    return path;
+    return SMACKRULESDIR "/app_" + appId;
 }
 void SmackRules::installApplicationPrivilegesRules(const std::string &appId, const std::string &pkgId,
         const std::vector<std::string> &pkgContents, const std::vector<std::string> &privileges)
@@ -256,8 +253,7 @@ void SmackRules::installApplicationPrivilegesRules(const std::string &appId, con
     for (auto privilege : privileges) {
         if (privilege.empty())
             continue;
-        std::string fprivilege ( privilege + "-template.smack");
-        std::string path(tzplatform_mkpath4(TZ_SYS_SHARE, "security-manager", "policy", fprivilege.c_str()));
+        std::string path = DATADIR "/policy/" + privilege + "-template.smack";
         if( stat(path.c_str(), &buffer) == 0)
             smackRules.addFromTemplateFile(appId, pkgId, path);
     }
-- 
2.21.0