搜索

13.7. 锁定重新分区

download PDF
polkit 可让您为单个操作设置权限。对于 udisks2,磁盘管理服务工具,配置位于 /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy。此文件包含一组操作和默认值,它们可被系统管理员覆盖。
重要
请记住,存储在 /etc 中的 polkit 配置会覆盖 /usr/share/ 中软件包所提供的配置。

过程 13.7. 要禁止用户更改磁盘设置

  1. 创建一个与 /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy 中内容相同的文件。
    cp /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy /etc/share/polkit-1/actions/org.freedesktop.udisks2.policy
    不要更改 /usr/share/polkit-1/actions/org.freedesktop.udisks2.policy 文件,您的更改会被下一次软件包更新覆盖。
  2. 删除您不需要的操作,并将以下行添加到 /etc/polkit-1/actions/org.freedesktop.udisks2.policy 文件中:
      <action id="org_freedesktop_udisks2_modify-device">
         <message>Authentication is required to modify the disks settings</message>
        <defaults>
          <allow_any>no</allow_any>
          <allow_inactive>no</allow_inactive>
          <allow_active>yes</allow_active>
        </defaults>
      </action>
    
    如果只想确保只有 root 用户才可以执行操作,则需要把 no 替换为 auth_admin
  3. 保存更改。
当用户尝试更改磁盘设置时,会返回以下信息:
Authentication is required to modify the disks settings
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.