---
name: "acl_set"
section: "3"
platform: "macos"
package: "Libc"
version: "1752.120.2"
release: "macOS 26.5"
platforms: ["freebsd", "macos"]
url: "https://new.carta.tech/acl_set"
---

# acl\_set(3)

set an ACL for a file

## NAME

**acl\_set\_fd**, **acl\_set\_fd\_np**, **acl\_set\_file**, **acl\_set\_link\_np** – set an ACL for a file

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/types.h\>**

**#include \<sys/acl.h\>**

*int*\

**acl\_set\_fd**(*int fd*, *acl\_t acl*);

*int*\

**acl\_set\_fd\_np**(*int fd*, *acl\_t acl*, *acl\_type\_t type*);

*int*\

**acl\_set\_file**(*const char \*path\_p*, *acl\_type\_t type*, *acl\_t acl*);

*int*\

**acl\_set\_link\_np**(*const char \*path\_p*, *acl\_type\_t type*, *acl\_t acl*);

## DESCRIPTION

The **acl\_set\_fd**(), **acl\_set\_fd\_np**(), **acl\_set\_file**(), and **acl\_set\_link\_np**() each associate an ACL with an object referred to by *fd* or *path\_p*. The **acl\_set\_fd\_np**() and **acl\_set\_link\_np**() functions are not POSIX.1e calls. The **acl\_set\_fd**() function allows only the setting of ACLs of type ACL\_TYPE\_EXTENDED where as **acl\_set\_fd\_np**() allows the setting of ACLs of any type.

The **acl\_set\_link\_np**() function acts on a symlink rather than its target, if the target of the path is a symlink. In the case of a symlink, this function will return an error because ACLs are not currently supported on symlinks. Note that the implementation is not atomic, and so the target could change between the time it is checked as not being a symlink, and the time the ACL is set.

## RETURN VALUES

The **acl\_set\_fd()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

If any of the following conditions occur, these functions shall return -1 and set *errno* to the corresponding value:

- \[EACCES\]

  Search permission is denied for a component of the path prefix, or the object exists and the process does not have appropriate access rights.

- \[EBADF\]

  The *fd* argument is not a valid file descriptor.

- \[EINVAL\]

  Argument *acl* does not point to a valid ACL for this object, or the ACL type specified in *type* is invalid for this object, or both.

- \[ENAMETOOLONG\]

  A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.

- \[ENOENT\]

  The named object does not exist, or the *path\_p* argument points to an empty string.

- \[ENOMEM\]

  Insufficient memory available to fulfill request.

- \[ENOSPC\]

  The directory or file system that would contain the new ACL cannot be extended, or the file system is out of file allocation resources.

- \[EOPNOTSUPP\]

  The file system does not support ACL retrieval.

- \[EROFS\]

  This function requires modification of a file system which is currently read-only.

## SEE ALSO

[acl(3)](/acl/3.md), [acl\_delete(3)](/acl_delete/3.md), [acl\_get(3)](/acl_get/3.md), [acl\_valid(3)](/acl_valid/3.md), [posix1e(3)](/posix1e/3.md)

## STANDARDS

POSIX.1e is described in IEEE POSIX.1e draft 17.

## AUTHORS

Michael Smith Robert N M Watson
