capability.h 3.2 KB
Newer Older
R
r00357803 已提交
1
/*
2 3
 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
R
r00357803 已提交
4
 *
M
mamingshuai 已提交
5 6
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
R
r00357803 已提交
7
 *
M
mamingshuai 已提交
8 9
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.
R
r00357803 已提交
10
 *
M
mamingshuai 已提交
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 *    of conditions and the following disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
R
r00357803 已提交
30 31
 */

C
c00346986 已提交
32 33 34 35 36 37
#ifndef _SYS_CAPABILITY_H
#define _SYS_CAPABILITY_H

#ifdef __cplusplus
extern "C" {
#endif
M
mamingshuai 已提交
38 39
#define __NEED_pid_t
#include <bits/alltypes.h>
C
c00346986 已提交
40 41
#include <linux/capability.h>

R
r00357803 已提交
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
// posix capabilities
#define OHOS_CAP_CHOWN                       0
#define OHOS_CAP_DAC_EXECUTE                 1
#define OHOS_CAP_DAC_WRITE                   2
#define OHOS_CAP_DAC_READ_SEARCH             3
#define OHOS_CAP_FOWNER                      4
#define OHOS_CAP_KILL                        5
#define OHOS_CAP_SETGID                      6
#define OHOS_CAP_SETUID                      7

// socket capabilities
#define OHOS_CAP_NET_BIND_SERVICE            8
#define OHOS_CAP_NET_BROADCAST               9
#define OHOS_CAP_NET_ADMIN                   10
#define OHOS_CAP_NET_RAW                     11

// fs capabilities
#define OHOS_CAP_FS_MOUNT                    12
#define OHOS_CAP_FS_FORMAT                   13

// process capabilities
#define OHOS_CAP_SCHED_SETPRIORITY           14

// time capabilities
#define OHOS_CAP_SET_TIMEOFDAY               15
#define OHOS_CAP_CLOCK_SETTIME               16

// process capabilities
#define OHOS_CAP_CAPSET                      17

// reboot capability
#define OHOS_CAP_REBOOT                      18
// self deined privileged syscalls
#define OHOS_CAP_SHELL_EXEC                  19

C
c00346986 已提交
77 78
int capget(cap_user_header_t hdr_ptr, cap_user_data_t data_ptr);
int capset(cap_user_header_t hdr_ptr, const cap_user_data_t data_ptr);
M
mamingshuai 已提交
79
int ohos_capget(pid_t pid, unsigned int *caps);
R
r00357803 已提交
80
int ohos_capset(unsigned int caps);
C
c00346986 已提交
81 82 83 84 85 86

#ifdef __cplusplus
}
#endif

#endif /* _SYS_CAPABILITY_H */