Merging tizen into ckm. Stage 1.
[platform/core/test/security-tests.git] / src / common / fs_label_manager.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @file        fs_label_manager.h
18  * @author      Marcin Niesluchowski (m.niesluchow@samsung.com)
19  * @version     1.0
20  * @brief       Class for environment operations on file system.
21  */
22 #ifndef _FS_LABEL_MANAGER_H_
23 #define _FS_LABEL_MANAGER_H_
24
25 #include <string>
26 #include <sys/smack.h>
27
28 class FsLabelManager
29 {
30 public:
31     FsLabelManager() = delete;
32     FsLabelManager(const std::string &path, const std::string &label);
33     FsLabelManager(const FsLabelManager &second) = delete;
34     FsLabelManager& operator=(FsLabelManager &second) = delete;
35
36     virtual ~FsLabelManager();
37
38     void createFile(const std::string &relativePath);
39     void createLink(const std::string &relativeLinkPath, const std::string &relativeRealPath);
40
41     void testSmackSetLabel(const std::string &relativePath,
42                            const char *label,
43                            enum smack_label_type labelType);
44     void testSmackLSetLabel(const std::string &relativePath,
45                             const char *label,
46                             enum smack_label_type labelType);
47     void testSmackFSetLabel(const std::string &relativePath,
48                             const char *label,
49                             enum smack_label_type labelType);
50
51     void testSmackGetLabel(const std::string &relativePath,
52                            const char *label,
53                            enum smack_label_type labelType);
54     void testSmackLGetLabel(const std::string &relativePath,
55                             const char *label,
56                             enum smack_label_type labelType);
57     void testSmackFGetLabel(const std::string &relativePath,
58                             const char *label,
59                             enum smack_label_type labelType);
60
61     void testSmackClearLabels(const std::string &relativePath);
62
63 private:
64     void checkLabel(const std::string &path,
65                     const char *label,
66                     enum smack_label_type labelType);
67     void checkLinkLabel(const std::string &path,
68                         const char *label,
69                         enum smack_label_type labelType);
70
71     std::string m_path;
72     std::string m_label;
73 };
74
75 #endif // _FS_LABEL_MANAGER_H_