1. 程式人生 > 其它 >linux系統程式設計之特權(Capabilities)程式、程序

linux系統程式設計之特權(Capabilities)程式、程序

在系統程式設計中,經常會看到特權程式、程序一說,特權指的是一種能力。官方定義:Linux capabilities are special attributes in the Linux kernel that grant processes and binary executables specific privileges that are normally reserved for processes whose effective user ID is 0 (The root user, and only the root user, has UID 0).

跟sudo的作用是類似的。

通過

man 7 capabilities可以檢視所有的各種能力。

CAPABILITIES(7)                                                                  Linux Programmer's Manual                                                                 CAPABILITIES(7)

NAME
       capabilities - overview of Linux capabilities

DESCRIPTION
       For  the  purpose  of  performing  permission checks, traditional UNIX implementations distinguish two categories of processes: privileged processes (whose effective user ID is 
0, referred to as superuser or root), and unprivileged processes (whose effective UID is nonzero). Privileged processes bypass all kernel permission checks, while unprivileged pro- cesses are subject to full permission checking based on the process's credentials (usually: effective UID, effective GID, and supplementary group list).
Starting with kernel 2.2, Linux divides the privileges traditionally associated with superuser into distinct units, known as capabilities, which can be independently enabled and disabled. Capabilities are a per-thread attribute. Capabilities list The following list shows the capabilities implemented on Linux, and the operations or behaviors that each capability permits: CAP_AUDIT_CONTROL (since Linux 2.6.11) Enable and disable kernel auditing; change auditing filter rules; retrieve auditing status and filtering rules. CAP_AUDIT_WRITE (since Linux 2.6.11) Write records to kernel auditing log. CAP_BLOCK_SUSPEND (since Linux 3.5) Employ features that can block system suspend (epoll(7) EPOLLWAKEUP, /proc/sys/wake_lock). CAP_CHOWN Make arbitrary changes to file UIDs and GIDs (see chown(2)). CAP_DAC_OVERRIDE Bypass file read, write, and execute permission checks. (DAC is an abbreviation of "discretionary access control".) CAP_DAC_READ_SEARCH * Bypass file read permission checks and directory read and execute permission checks; * Invoke open_by_handle_at(2). CAP_FOWNER * Bypass permission checks on operations that normally require the file system UID of t

https://www.vultr.com/docs/working-with-linux-capabilities

LightDB Enterprise Postgres--金融級關係型資料庫,更快、更穩、更懂金融!