2 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Rafal Krypa <r.krypa@samsung.com>
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
20 * @author Lukasz Kostyra (l.kostyra@samsung.com)
22 * @brief Definition of Zone utilities
25 #ifndef _SECURITY_MANAGER_ZONE_UTILS_H_
26 #define _SECURITY_MANAGER_ZONE_UTILS_H_
30 // FIXME This module is a replacement for Vasum functions.
32 // When Vasum will be included into OBS, the module should be removed and vasum-client should
35 namespace SecurityManager
38 extern const std::string ZONE_HOST;
41 * Extracts Zone ID in which runs process having provided PID.
43 * This function parses /proc/<pid>/cpuset file and tries to acquire Zone ID name from it.
45 * @param[in] pid PID of process to get Zone ID from.
46 * @param[out] zoneId Zone ID extracted from cpuset. If process runs in host, returns "host" string.
47 * @return True on success, false on failure.
49 bool getZoneIdFromPid(int pid, std::string& zoneId);
52 * Generates zone-specific label from given @ref label and zone's name @ref zoneName
54 * @param[in] label Base label, used to generate new zone-specific label
55 * @param[in] zoneName Name of zone for which label will be generated
56 * @return Generated label
58 std::string zoneSmackLabelGenerate(const std::string &label, const std::string &zoneName);
61 * Map @ref hostLabel to @ref zoneLabel using Smack namespaces.
63 * FIXME This is a placeholder for Vasum API - implement when Smack Namespaces are implemented
65 * @param[in] hostLabel Smack label as seen from hosts perspective
66 * @param[in] zoneName Zone ID to which label will be mapped
67 * @param[in] zoneLabel Smack label seen from zone's perspective
68 * @return True on success, false on failure
70 bool zoneSmackLabelMap(const std::string &hostLabel, const std::string &zoneName,
71 const std::string &zoneLabel);
74 * Unmap label mapped by zoneSmackLabelMap.
76 * FIXME This is a placeholder for Vasum API - implement when Smack Namespaces are implemented
78 * @param[in] hostLabel Label to unmap
79 * @param[in] zoneName Zone ID for which unmapping should be done
80 * @return True on success, false on failure
82 bool zoneSmackLabelUnmap(const std::string &hostLabel, const std::string &zoneName);
84 } //namespace SecurityManager
86 #endif //_SECURITY_MANAGER_ZONE_UTILS_H_