# capability.h - [Overview](#section1132315430165626) - [Summary](#section1852449319165626) - [Data Structures](#nested-classes) - [Macros](#define-members) - [Typedefs](#typedef-members) - [Functions](#func-members) ## **Overview** **Related Modules:** [PROCESS](PROCESS.md) **Description:** Declares functions and related data structures for obtaining and setting process capabilities. **Since:** 1.0 **Version:** 1.0 ## **Summary** ## Data Structures

Data Structure Name

Description

__user_cap_header_struct

Defines the user capability header.

__user_cap_data_struct

Defines user capability data.

## Macros

Macro Name and Value

Description

CAP_CHOWN 0

Indicates the capability of changing the file ownership.

CAP_DAC_OVERRIDE 1

Indicates the capability of ignoring discretionary access control (DAC) restrictions on files.

CAP_DAC_READ_SEARCH 2

Indicates the capability of ignoring DAC restrictions on file read and search.

CAP_FOWNER 3

Indicates the capability of ignoring the restrictions on the matching between the user ID of the file owner and process ID.

CAP_KILL 5

Indicates the capability of ignoring the restrictions on sending signals to processes that do not belong to themselves.

CAP_SETGID 6

Indicates the capability of changing the group ID of a process.

CAP_SETUID 7

Indicates the capability of changing the user ID of a process.

CAP_SETPCAP 8

Indicates the capability of transferring capabilities to other processes and deleting capabilities.

CAP_NET_BIND_SERVICE 10

Indicates the capability of binding a port.

CAP_NET_BROADCAST 11

Indicates the capability of network broadcasting or multicasting.

CAP_NET_ADMIN 12

Indicates the capability of executing network management tasks.

CAP_NET_RAW 13

Indicates the capability of using raw sockets.

CAP_SYS_PTRACE 19

Indicates the capability of tracing any process.

CAP_SYS_ADMIN 21

Indicates the capability of executing system management tasks.

CAP_SYS_BOOT 22

Indicates the capability of rebooting system.

CAP_SYS_NICE 23

Indicates the capability of setting the priority.

CAP_SYS_TIME 25

Indicates the capability of changing the system clock.

OHOS_CAP_CHOWN 0

Indicates the capability of changing the file ownership. This macro is used by ohos_capset.

OHOS_CAP_DAC_EXECUTE 1

Indicates the capability of ignoring DAC restrictions on file execution. This macro is used by ohos_capset.

OHOS_CAP_DAC_WRITE 2

Indicates the capability of ignoring DAC restrictions on file write. This macro is used by ohos_capset.

OHOS_CAP_DAC_READ_SEARCH 3

Indicates the capability of ignoring DAC restrictions on file read and search. This macro is used by ohos_capset.

OHOS_CAP_FOWNER 4

Indicates the capability of ignoring the restrictions on the matching between the user ID of the file owner and process ID. This macro is used by ohos_capset.

OHOS_CAP_KILL 5

Indicates the capability of ignoring the restrictions on sending signals to processes that do not belong to themselves. This macro is used by ohos_capset.

OHOS_CAP_SETGID 6

Indicates the capability of changing the group ID of a process. This macro is used by ohos_capset.

OHOS_CAP_SETUID 7

Indicates the capability of changing the user ID of a process. This macro is used by ohos_capset.

OHOS_CAP_NET_BIND_SERVICE 8

Indicates the capability of binding a port. This macro is used by ohos_capset.

OHOS_CAP_NET_BROADCAST 9

Indicates the capability of network broadcasting or multicasting. This macro is used by ohos_capset.

OHOS_CAP_NET_ADMIN 10

Indicates the capability of executing network management tasks. This macro is used by ohos_capset.

OHOS_CAP_NET_RAW 11

Indicates the capability of using raw sockets. This macro is used by ohos_capset.

OHOS_CAP_FS_MOUNT 12

Indicates the capability of mounting the file system. This macro is used by ohos_capset.

OHOS_CAP_FS_FORMAT 13

Indicates the capability of formatting the file system. This macro is used by ohos_capset.

OHOS_CAP_SCHED_SETPRIORITY 14

Indicates the capability of setting the scheduling priority. This macro is used by ohos_capset.

OHOS_CAP_SET_TIMEOFDAY 15

Indicates the capability of setting the date. This macro is used by ohos_capset.

OHOS_CAP_CLOCK_SETTIME 16

Indicates the capability of setting the clock. This macro is used by ohos_capset.

OHOS_CAP_CAPSET 17

Indicates the capability of setting the capabilities. This macro is used by ohos_capset.

OHOS_CAP_REBOOT 18

Indicates the capability of rebooting system. This macro is used by ohos_capset.

OHOS_CAP_SHELL_EXEC 19

Indicates the capability of calling shell. This macro is used by ohos_capset.

## Typedefs

Typedef Name

Description

cap_user_header_t

typedef struct __user_cap_header_struct *

Defines the user capability header.

cap_user_data_t

typedef struct __user_cap_data_struct *

Defines user capability data.

## Functions

Function

Description

capget (cap_user_header_t hdr_ptr, cap_user_data_t data_ptr)

int

Obtains the capability information of a specified process based on the input parameters (compatible with the Linux API format).

capset (cap_user_header_t hdr_ptr, const cap_user_data_t data_ptr)

int

Sets the capability information for a specified process based on the input parameters (compatible with the Linux API format).

ohos_capget (pid_t pid, unsigned int *caps)

int

Obtains the capability information of the specified process process based on the input parameters.

ohos_capset (unsigned int caps)

int

Sets the capability information of the current process based on the input parameters.