# 18.8.MAC 框架的故障排除

**`multilabel` 标志未能保持启用状态**

如果根（**/**）分区的 `multilabel` 标志没有保持启用，可以按照以下步骤解决此临时错误：

1. 编辑 **/etc/fstab**，将根分区设置为 `ro`（只读）。
2. 以单用户模式重启系统。
3. 在 **/** 上运行 `tunefs -l enable`。
4. 重启系统。
5. 运行 `mount -urw /`，然后将 **/etc/fstab** 中的 `ro` 改回 `rw`，再次重启系统。
6. 使用 `mount` 检查输出，确保根文件系统上已正确设置 `multilabel`。

**在建立安全环境后，Xorg 无法启动**

这可能是由 MAC 的 `partition` 策略或 MAC 标签策略中的标签错误引起的。可以按以下步骤进行调试：

1. 检查错误信息。如果用户属于 `insecure` 类别，则可能是 `partition` 策略引起的。尝试将用户的类设置回 `default` 类，并使用 `cap_mkdb` 重建数据库。如果此方法无效，继续进行第二步。
2. 仔细检查用户、Xorg 和 **/dev** 条目的标签策略设置。
3. 如果这两步都没有解决问题，可以将错误信息及环境描述发送到 [FreeBSD general questions mailing list](https://lists.freebsd.org/subscription/freebsd-questions) 寻求帮助。

**报错 `_secure_path: unable to stat .login_conf`**

该错误通常在用户尝试从 `root` 用户切换到另一个用户时出现。通常发生在用户的标签设置比他们尝试切换的用户高时。例如，如果 `joe` 的默认标签是 `biba/low`，而 `root` 的标签是 `biba/high`，则 `root` 无法查看 `joe` 的主目录。无论 `root` 是否通过 `su` 切换为 `joe`，Biba 完整性模型都不允许 `root` 查看低完整性级别的对象。

**系统不再识别 `root`**

当出现这种情况时，`whoami` 返回 `0`，`su` 返回 `who are you?`。

这可能是因为通过 [sysctl(8)](https://man.freebsd.org/cgi/man.cgi?query=sysctl\&sektion=8\&format=html) 禁用了标签策略，或者安全策略模块被卸载。如果禁用了策略，则需要重新配置登录能力数据库。请仔细检查 **/etc/login.conf**，确保所有的 `label` 选项已删除，并使用 `cap_mkdb` 重建数据库。

如果是由于策略限制了对 **master.passwd** 的访问，也会导致此问题。这通常发生在管理员在与系统使用的通用策略冲突的标签下修改了文件的情况下。在这些情况下，用户信息会被系统读取，但由于文件继承了新的标签，访问会被阻止。可以通过 [sysctl(8)](https://man.freebsd.org/cgi/man.cgi?query=sysctl\&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://book.bsdcn.org/hanbook/di-18-zhang-qiang-zhi-fang-wen-kong-zhi/18.8.-mac-kuang-jia-de-gu-zhang-pai-chu.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.
