# 18.6.用户锁定

这个例子考虑了一个相对较小的存储系统，用户少于五十个。用户将拥有登录功能，并能存储数据和访问资源。

对于这种情况，[mac\_bsdextended(4)](https://man.freebsd.org/cgi/man.cgi?query=mac_bsdextended\&sektion=4\&format=html) 和 [mac\_seeotheruids(4)](https://man.freebsd.org/cgi/man.cgi?query=mac_seeotheruids\&sektion=4\&format=html) 策略模块可以共存，阻止访问系统对象，同时隐藏用户进程。

首先，在 **/boot/loader.conf** 中添加以下行：

```ini
mac_seeotheruids_load="YES"
```

可以通过将以下行添加到 **/etc/rc.conf** 来激活 [mac\_bsdextended(4)](https://man.freebsd.org/cgi/man.cgi?query=mac_bsdextended\&sektion=4\&format=html) 安全策略模块：

```ini
ugidfw_enable="YES"
```

默认规则存储在 **/etc/rc.bsdextended** 中，将在系统初始化时加载。但是，默认条目可能需要修改。由于此机器仅用于为用户提供服务，除了最后两行外，所有内容可以保持注释状态，以强制默认加载用户拥有的系统对象。

将所需的用户添加到此机器并重启。为了进行测试，尝试在两个控制台之间以不同用户身份登录。运行 `ps aux` 查看是否可以看到其他用户的进程。验证运行 [ls(1)](https://man.freebsd.org/cgi/man.cgi?query=ls\&sektion=1\&format=html) 是否无法访问其他用户的家目录。

除非已修改特定的 `sysctl` 设置以阻止超级用户访问，否则不要尝试使用 `root` 用户进行测试。

> **注意**
>
> 当新用户被添加时，他们的 [mac\_bsdextended(4)](https://man.freebsd.org/cgi/man.cgi?query=mac_bsdextended\&sektion=4\&format=html) 规则不会出现在规则集列表中。要快速更新规则集，可以使用 [kldunload(8)](https://man.freebsd.org/cgi/man.cgi?query=kldunload\&sektion=8\&format=html) 和 [kldload(8)](https://man.freebsd.org/cgi/man.cgi?query=kldload\&sektion=8\&format=html) 卸载并重新加载安全策略模块。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://handbook.bsdcn.org/di-18-zhang-qiang-zhi-fang-wen-kong-zhi/18.6.-yong-hu-suo-ding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
