zoukankan      html  css  js  c++  java
  • 拾遗:『Linux Capability』

    『Linux Capability』

      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 processes 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 capabili‐ties, which can be independently enabled and disabled. Capabilities are a per-thread attribute.

    一、kernel配置

    二、源码中权限相关注释(/usr/src/linux-*.*.*/include/linux/cred.h):

    其中定义了进程的三个能力位:inheritable(I)、permitted(P)和effective(E)

    • cap_effective:当一个进程将执行某项特权操作时,操作系统会检查cap_effective中对应位是否有效,而不再检查进程euid是否为0
    • cap_permitted:表示进程实际能够使用的能力,在cap_permitted中可以包含cap_effective中没有的能力
    • cap_inheritable表示能够被目标程序启动的子进程继承的能力

    三、setcap、getcap:用户层的用途是,将系统中具有suid、sgid权限位的文件,以更安全的capability机制管理,减少潜在的程序漏洞带来的危害

    root # find / -perm /4000
    root # find / -perm /2000

    『应用示例 一』

      ping只需要CAP_NET_RAW能力,即可在具有x权限的环境中执行,并不需要suid权限

      /* CAP_NET_RAW:use RAW and PACKET sockets;bind to any address for transparent proxying */ 

    root # chown u-s /bin/ping
    root # setcap CAP_NET_RAW+ep /bin/ping
    root # getcap /bin/ping
    /bin/ping = cap_net_raw+ep

    『应用示例 二』

      使普通用户可执行iftop

    root # setcap CAP_NET_RAW+ep /usr/sbin/iftop

    『应用示例 三』

      使普通用户可以使用chvt切换虚拟工作台

    root # setcap cap_dac_read_search,cap_sys_tty_config+ep /usr/bin/chvt

      

  • 相关阅读:
    Oracle学习笔记--Oracle启动过程归纳整理
    Oracle 11g rac开启归档
    Oracle 11g rac中关于crsctl stop cluster/crs/has的区别
    Linux环境下安装MySQL 5.7.28
    将root用户权限赋予普通用户
    用Navicat Premium 连接mysql数据库时报错 -- 1130 Host xxxx is not allowed to connect to this MySQL server
    PCoIP vs HDX (CITRIX ICA)远程访问协议对比
    systemctl
    组播查询命令
    默认路由ip default-network和ip route 0.0.0.0 0.0.0.0区别
  • 原文地址:https://www.cnblogs.com/hadex/p/5830823.html
Copyright © 2011-2022 走看看