> 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_cansee.9.md).

# cr\_cansee.9

`cr_cansee` — 根据用户凭据判断对象的可见性

## 名称

`cr_cansee`

## 概要

```c
#include <sys/proc.h>

int
cr_cansee(struct ucred *u1, struct ucred *u2);
```

## 描述

此函数判断持有凭据 `u1` 的主体能否看到与凭据 `u2` 关联的主体或对象。

特定类型的主体可能需要服从额外或不同的限制。例如，对于进程，参见 [p\_cansee(9)](/man/man9/p_cansee.9.md)，该函数会调用此函数。

实现依赖于 [cr\_bsd\_visible(9)](/man/man9/cr_bsd_visible.9.md)，因此其手册页中引用的 [sysctl(8)](/man/man8/sysctl.8.md) 变量会影响结果。

## 返回值

若持有凭据 `u1` 的主体可以“看到”持有凭据 `u2` 的主体或对象，此函数返回 0；否则返回 `ESRCH`。

## 错误

\[`ESRCH`] 持有凭据 `u1` 的主体已被监禁（jailed），且持有凭据 `u2` 的主体或对象不属于同一 jail 或其子 jail，由 [prison\_check(9)](/man/man9/prison_check.9.md) 判定。

\[`ESRCH`] MAC 子系统拒绝了可见性。

\[`ESRCH`] [cr\_bsd\_visible(9)](/man/man9/cr_bsd_visible.9.md) 根据当前生效的 BSD 安全策略拒绝了可见性。

## 参见

[cr\_bsd\_visible(9)](/man/man9/cr_bsd_visible.9.md), [mac(9)](/man/man9/mac.9.md), [p\_cansee(9)](/man/man9/p_cansee.9.md), [prison\_check(9)](/man/man9/prison_check.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_cansee.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.
