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

# groupmember.9

`groupmember` — 检查凭据是否要求某些组成员身份

## 名称

`groupmember`

## 概要

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

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

```c
bool
groupmember(gid_t gid, const struct ucred *cred)
bool
realgroupmember(gid_t gid, const struct ucred *cred)
```

## 描述

`groupmember` 函数检查凭据 `cred` 是否指示关联的主体或对象是由组 ID `gid` 指定的组的成员。

`cred` 中考虑的组是有效组和补充组。不考虑实际组。

`realgroupmember` 函数工作方式相同，区别在于它考虑的是实际组和补充组，而不是有效组。

## 返回值

`groupmember` 和 `realgroupmember` 函数在给定凭据指示为组 `gid` 的成员时返回 `true`，否则返回 `false`。

## 参见

`getgroups(2)`, `setgroups(2)`

## 作者

本手册页最初由 Chad David <davidc@acns.ab.ca> 编写，并由 Olivier Certner <olce.freebsd@certner.fr> 修订。


---

# 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/groupmember.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.
