Make generateAppLabel() a static funcion of SmackRules class 32/23332/3
authorRafal Krypa <r.krypa@samsung.com>
Mon, 23 Jun 2014 15:32:41 +0000 (17:32 +0200)
committerRafal Krypa <r.krypa@samsung.com>
Tue, 24 Jun 2014 12:55:16 +0000 (14:55 +0200)
Eliminate security-manager-common.cpp containing a single function, which
now logically belongs to SmackRules class.

Change-Id: I5e7c063a5980d97b67c7f9640812d9890e24b2c7
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
src/server/CMakeLists.txt
src/server/service/installer.cpp
src/server/service/security-manager-common.cpp [deleted file]
src/server/service/security-manager-common.h [deleted file]
src/server/service/smack-rules.cpp
src/server/service/smack-rules.h

index 73e3c00..a53d379 100644 (file)
@@ -20,7 +20,6 @@ SET(COMMON_SOURCES
     ${COMMON_PATH}/dpl/core/src/noncopyable.cpp
     ${COMMON_PATH}/dpl/core/src/serialization.cpp
     ${COMMON_PATH}/dpl/core/src/singleton.cpp
-    ${COMMON_PATH}/service/security-manager-common.cpp
     )
 
 INCLUDE_DIRECTORIES(SYSTEM
index 8de407d..a1ade47 100644 (file)
@@ -39,7 +39,6 @@
 #include "protocols.h"
 #include "security-manager.h"
 #include "smack-rules.h"
-#include "security-manager-common.h"
 
 namespace SecurityManager {
 
@@ -232,7 +231,7 @@ bool setupPath(const std::string &pkgId, const std::pair<std::string, int> &appP
 
     switch (pathType) {
     case SECURITY_MANAGER_PATH_PRIVATE:
-        if(!generateAppLabel(pkgId,label))
+        if (!SmackRules::generateAppLabel(pkgId, label))
             return false;
         label_executables = true;
         label_transmute = false;
diff --git a/src/server/service/security-manager-common.cpp b/src/server/service/security-manager-common.cpp
deleted file mode 100644 (file)
index 2ae363a..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2014 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-common.cpp
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       This file contains implementation of utility functions for security-manager
- *
- */
-
-
-#include "security-manager-common.h"
-
-
-namespace SecurityManager {
-
-bool generateAppLabel(const std::string &appPkgId, std::string &label)
-{
-    (void) appPkgId; //todo use pkgId to generate label
-    label = "User";
-    return true;
-}
-
-} // namespace SecurityManager
-
diff --git a/src/server/service/security-manager-common.h b/src/server/service/security-manager-common.h
deleted file mode 100644 (file)
index 2f1a24b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *  Copyright (c) 2000 - 2014 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-common.h
- * @author      Jan Cybulski <j.cybulski@samsung.com>
- * @version     1.0
- * @brief       This file is header for utility functions for security-manager
- *
- */
-#ifndef _SECURITY_MANAGER_COMMON_H_
-#define _SECURITY_MANAGER_COMMON_H_
-
-#include <string>
-
-
-namespace SecurityManager {
-
-/**
- * This function generates label for application with package identifier
- * read from @ref appPkgId and assigns it to @ref label.
- * @param[in] appPkgId application's package identifier.
- * @param[out] label string into which application's label will be stored into.
- * @return true on success, false on error.
- */
-bool generateAppLabel(const std::string &appPkgId, std::string &label);
-
-
-} // namespace SecurityManager
-
-#endif
index dc57d5c..21089b7 100644 (file)
@@ -35,7 +35,6 @@
 #include <dpl/log/log.h>
 
 #include "smack-rules.h"
-#include "security-manager-common.h"
 
 namespace SecurityManager {
 
@@ -43,6 +42,13 @@ const char *const SMACK_APP_LABEL_TEMPLATE     = "~APP~";
 const char *const APP_RULES_TEMPLATE_FILE_PATH = "/etc/smack/app-rules-template.smack";
 const char *const APP_RULES_DIRECTORY          = "/etc/smack/accesses.d/";
 
+bool SmackRules::generateAppLabel(const std::string &appPkgId, std::string &label)
+{
+    (void) appPkgId; //todo use pkgId to generate label
+    label = "User";
+    return true;
+}
+
 SmackRules::SmackRules()
 {
     if (smack_accesses_new(&m_handle) < 0) {
@@ -176,14 +182,14 @@ bool SmackRules::addFromTemplate(const std::vector<std::string> &templateRules,
         }
 
         if (subjectIsTemplate) {
-            if (!SecurityManager::generateAppLabel(pkgId, subject)) {
+            if (!generateAppLabel(pkgId, subject)) {
                 LogError("Failed to generate app label from pkgid: " << pkgId);
                 return false;
             }
         }
 
         if (objectIsTemplate) {
-            if (!SecurityManager::generateAppLabel(pkgId, object)) {
+            if (!generateAppLabel(pkgId, object)) {
                 LogError("Failed to generate app label from pkgid: " << pkgId);
                 return false;
             }
index b9ab765..6aa6775 100644 (file)
@@ -69,6 +69,16 @@ public:
      *         false otherwise
      */
     static bool uninstallPackageRules(const std::string &pkgId);
+
+    /**
+    * Generates label for application with package identifier
+    * read from @ref appPkgId and assigns it to @ref label.
+    * @param[in] appPkgId application's package identifier.
+    * @param[out] label string into which application's label will be stored into.
+    * @return true on success, false on error.
+    */
+    static bool generateAppLabel(const std::string &appPkgId, std::string &label);
+
 private:
     static std::string getPackageRulesFilePath(const std::string &pkgId);