2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef _SECURITY_MANAGER_TEST_POLICY_CONFIGURATION_
17 #define _SECURITY_MANAGER_TEST_POLICY_CONFIGURATION_
23 #include <sys/types.h>
25 namespace SecurityManagerTest {
27 gid_t nameToGid(const char *name);
29 class PolicyConfiguration {
31 typedef std::vector<gid_t> GidVector;
32 typedef std::vector<std::string> GroupVector;
33 typedef std::vector<std::string> PrivVector;
34 typedef std::map<std::string, std::string> PrivGroupMap;
36 struct UserDescription {
37 PrivVector privVector;
38 GroupVector groupVector;
42 enum UserType { GUEST, NORMAL, ADMIN, SYSTEM };
44 std::string getConfigFilePath(UserType userType);
45 PrivVector getUserPriv(UserType userType);
46 GroupVector getUserGroup(UserType userType);
47 GidVector getUserGid(UserType userType);
49 GroupVector getGroup();
50 UserDescription& getUserDescription(UserType userType);
51 gid_t groupToGid(const std::string &gname);
52 PrivGroupMap getPrivGroupMap();
53 GroupVector privToGroup(const PrivVector &privVector);
55 static bool getIsAskuserEnabled();
58 GidVector groupToGid(const GroupVector &groupVector);
59 UserDescription loadUserDescription(UserType userType);
60 PrivVector loadPrivFile(const std::string &path);
61 void loadPrivGroupMap(void);
63 PrivGroupMap m_privGroupMap;
64 std::map<std::string, gid_t> m_groupGidMap;
65 std::map<UserType, UserDescription> m_userDescriptionMap;
68 } // namespace SecurityManagerTest