Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions content/reference/functions/getgroupinfo.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
layout: default
title: getgroupinfo
---

{{< CFEngine_function_prototype(optional_gidorname) >}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we write optional_ like this in other functions?

Suggested change
{{< CFEngine_function_prototype(optional_gidorname) >}}
{{< CFEngine_function_prototype(optional_gidorname) >}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


**Description:** Return information about the current group or any other, looked up by group ID (GID) or group name.

This function searches for a group known to the system.
If the `optional_gidorname` parameter is omitted, the current group (that is currently running the agent) is retrieved.
If `optional_gidorname` is specified, the group entry is looked up by name or ID, using the standard `getgrgid()` and `getgrnam()` POSIX functions (but note that these functions may in turn talk to LDAP, for instance).
On platforms that don't support these POSIX functions, the function simply fails.

{{< CFEngine_function_attributes(optional_gidorname) >}}

**Example:**

```cf3
bundle agent main
{
vars:
"group" data => getgroupinfo(0);

reports:
"$(group[name])";
"$(group[gid])";
"$(group[members])";
}
```

Output:

```
R: root
R: 0
```

**History:** Introduced in CFEngine 3.27

**See also:** [`getgroups()`][getgroups].