f4f15f72adaf8edc12c77a96ca6b81a700d1d811
[platform/core/security/security-manager.git] / src / common / include / smack-labels.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Contact: Rafal Krypa <r.krypa@samsung.com>
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License
17  */
18 /**
19  * @file        smack-labels.h
20  * @author      Jan Cybulski <j.cybulski@samsung.com>
21  * @author      Rafal Krypa <r.krypa@samsung.com>
22  * @version     1.0
23  * @brief       Header file of functions managing smack labels
24  *
25  */
26 #ifndef _SMACK_LABELS_H_
27 #define _SMACK_LABELS_H_
28
29 #include <string>
30 #include <utility>
31 #include <smack-exceptions.h>
32 #include <security-manager.h>
33
34 namespace SecurityManager {
35 namespace SmackLabels {
36
37 /**
38  * Sets Smack labels on a directory and its contents, recursively.
39  *
40  * @param appId[in] application's identifier
41  * @param path[in] path to a file or directory to setup
42  * @param pathType[in] type of path to setup. See description of
43  *         app_install_path_type in security-manager.h for details
44  *
45  */
46 void setupPath(const std::string &appId, const std::string &path,
47     app_install_path_type pathType);
48
49 /**
50  * Sets Smack labels on a <ROOT_APP>/<pkg_id> and <ROOT_APP>/<pkg_id>/<app_id>
51  * non-recursively
52  *
53  * @param pkgId[in] package identifier
54  * @param appId[in] application's identifier
55  * @param basePath[in] <ROOT_APP> path
56  */
57 void setupCorrectPath(const std::string &pkgId, const std::string &appId,
58         const std::string &basePath);
59
60 /**
61  * Generates application name for a label fetched from Cynara
62  *
63  * @param[in] label string to fetch application name for
64  * @return application name on success, empty string on error.
65 */
66 std::string generateAppNameFromLabel(const std::string &label);
67
68 /**
69  * Generates label for an application with an application ID read from @ref appId.
70  *
71  * @param[in] appId application's identifier
72  * @return resulting Smack label
73 */
74 std::string generateAppLabel(const std::string &appId);
75
76 /**
77  * Generates label for an application with a package ID read from @ref pkgId.
78  *
79  * @param[in] pkgId
80  * @return resulting Smack label
81  */
82 std::string generatePkgLabel(const std::string &pkgId);
83
84 } // namespace SmackLabels
85 } // namespace SecurityManager
86
87 #endif /* _SMACK_LABELS_H_ */