Linux Basic notes--[020]--"Linux Capability"

Source: Internet
Author: User

"Linux Capability"

For the purpose of performing permission checks, traditional UNIX implementations distinguish, 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 processes is subject to full permission Chec King 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 Capabili‐ties, which can be independently enabled and disabled. Capabilities is a Per-thread attribute.

First, kernel configuration

Second, the source of authority-related comments (/usr/src/linux-*.*.*/include/linux/cred.h):

The three capacity bits of the process are defined: inheritable (I), permitted (P), and effective (E)

  • Cap_permitted: When a process performs a privileged operation, the operating system checks if the corresponding bit in cap_effective is valid, and no longer checks whether the process Euid is 0
  • Cap_permitted: Represents the ability of a process to actually be used, which can contain capabilities not in Cap_effective in cap_permitted
  • Cap_inheritable represents the ability to inherit from a child process that is initiated by the target program

Third, Setcap, Getcap: The use of the user layer, the system has suid, Sgid permissions bits of the file, with a more secure capability mechanism management, reduce the potential of the vulnerability of the program to harm

Find /-perm/4000Find /-perm/

"Application Example One"

Ping requires only cap_net_raw ability to execute in an environment with X permissions and does not require SUID permissions

/ * Cap_net_raw:use RAW and PACKET Sockets;bind to any address for transparent proxying * /

chown u-s/bin/pingroot # setcap cap_net_raw+ep/bin/ping/bin/ Ping/bin/ping = Cap_net_raw+ep

"Application Example II"

Enables ordinary users to perform iftop

Root # Setcap Cap_net_raw+ep/usr/sbin/iftop

"Application Example three"

Enables normal users to switch virtual Workbench using CHVT

Root # Setcap CAP_DAC_READ_SEARCH,CAP_SYS_TTY_CONFIG+EP/USR/BIN/CHVT

  

Linux Basic notes--[020]--"Linux Capability"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.