> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/cr_canseeotheruids.9.md).

# cr\_canseeotheruids.9

`cr_canseeotheruids` — 判断主体能否看到具有不同用户 ID 的实体

## 名称

`cr_canseeotheruids`

## 概要

```c
int
cr_canseeotheruids(struct ucred *u1, struct ucred *u2);
```

## 描述

> **注意**：此函数为内部函数。其功能已集成到 [cr\_bsd\_visible(9)](/man/man9/cr_bsd_visible.9.md) 中，应改用后者。

此函数检查持有凭据 `u1` 的主体是否被某项策略禁止查看持有凭据 `u2` 的主体或对象，该策略要求两份凭据具有相同的真实用户 ID。

当且仅当 [sysctl(8)](/man/man8/sysctl.8.md) 变量 `security.bsd.see_other_uids` 设置为 0 时，此策略生效。

按惯例，超级用户（有效用户 ID 为 0）不受此策略限制，前提是 [sysctl(8)](/man/man8/sysctl.8.md) 变量 `security.bsd.suser_enabled` 为非零值，且没有活动的 MAC 策略明确拒绝此豁免（参见 [priv\_check\_cred(9)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man9/priv_check_cred.9.md)）。

## 返回值

若策略被禁用、两份凭据具有相同的真实用户 ID，或 `u1` 拥有可豁免此策略的特权，`cr_canseeotheruids` 函数返回 0；否则返回 `ESRCH`。

## 参见

[cr\_bsd\_visible(9)](/man/man9/cr_bsd_visible.9.md), [priv\_check\_cred(9)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man9/priv_check_cred.9.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/cr_canseeotheruids.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
