Skip to content

CFE-4529: Added docs for policy function getacls() #3454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2025
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
48 changes: 48 additions & 0 deletions reference/functions/getacls.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
layout: default
title: getacls
published: true
---

[%CFEngine_function_prototype(path, type)%]

**Description:** Return the Access Control List (ACL) for a given file- or directory path.

This function returns the ACLs for a file or directory given by the `path`
argument. The `type` argument indicates whether to get the __access__ or
__default__ ACLs.

The __access__ ACLs defines the permissions for the given file or directory.
I.e., who (users, groups, others) can perform what actions (read, write,
execute) on that particular object.

The __default__ ACLs acts like a template of permissions to be inherited by
objects created within that directory. Please note that only directories can
have default ACLs.

If ACLs are not supported on the filesystem the function will return an empty
list.

**Arguments:**

- `path` : Absolute path to file or directory
- `type` : In the range `(access|default)`

**Example:**
Copy link
Contributor

@victormlg victormlg Jul 2, 2025

Choose a reason for hiding this comment

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

Maybe you could use the docs macro to include the example you have created in the other PR like it has been done for other functions

For example:

Example:

[%CFEngine_include_snippet(isreadable.cf, #+begin_src cfengine3, .*end_src)%]

Output:

[%CFEngine_include_snippet(isreadable.cf, #+begin_src\s+example_output\s*, .*end_src)%]


```cf3
bundle agent __main__
{
vars:
"default_acls"
string => getacls("/tmp/foo/", "default");
"access_acls"
string => getacls("/tmp/bar", "access");
}
```
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to show the expected output (you can add it to getacls.cf, cf. my previous comment)

Copy link
Member

Choose a reason for hiding this comment

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

Agreed that it would be nice to show the expected output.

But, then you need to be able to make sure you know what the result will be for whatever system doc build happens on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably won't be so easy given that ACLs are not supported on all platforms and file systems


**History:**

- Introduced in 3.27.

**See also:** `filestat()`