linux系统编程之特权(Capabilities)程序、进程

2021/10/5 7:12:40

本文主要是介绍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 



这篇关于linux系统编程之特权(Capabilities)程序、进程的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程