blob: 80d0e045c2305ecb53e08ac30885a9442f547429 [file] [log] [blame]
Shawn Willdenc1d1fee2016-01-26 22:44:56 -07001/*
2 * Copyright (C) 2016 The Android Open Source Project
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#ifndef KEYSTORE_PERMISSIONS_H_
18#define KEYSTORE_PERMISSIONS_H_
19
20#include <unistd.h>
21
22/* Here are the permissions, actions, users, and the main function. */
23enum perm_t {
24 P_GET_STATE = 1 << 0,
25 P_GET = 1 << 1,
26 P_INSERT = 1 << 2,
27 P_DELETE = 1 << 3,
28 P_EXIST = 1 << 4,
29 P_LIST = 1 << 5,
30 P_RESET = 1 << 6,
31 P_PASSWORD = 1 << 7,
32 P_LOCK = 1 << 8,
33 P_UNLOCK = 1 << 9,
34 P_IS_EMPTY = 1 << 10,
35 P_SIGN = 1 << 11,
36 P_VERIFY = 1 << 12,
37 P_GRANT = 1 << 13,
38 P_DUPLICATE = 1 << 14,
39 P_CLEAR_UID = 1 << 15,
40 P_ADD_AUTH = 1 << 16,
41 P_USER_CHANGED = 1 << 17,
Shawn Willdene2a7b522017-04-11 09:27:40 -060042 P_GEN_UNIQUE_ID = 1 << 18,
Shawn Willdenc1d1fee2016-01-26 22:44:56 -070043};
44
45const char* get_perm_label(perm_t perm);
46
47/**
48 * Returns the UID that the callingUid should act as. This is here for
49 * legacy support of the WiFi and VPN systems and should be removed
50 * when WiFi can operate in its own namespace.
51 */
52uid_t get_keystore_euid(uid_t uid);
53
54bool has_permission(uid_t uid, perm_t perm, pid_t spid);
55
56/**
57 * Returns true if the callingUid is allowed to interact in the targetUid's
58 * namespace.
59 */
60bool is_granted_to(uid_t callingUid, uid_t targetUid);
61
62int configure_selinux();
63
64#endif // KEYSTORE_PERMISSIONS_H_