ACL_SET_FILE
Section: C Library Functions (3)
Index
Return to Main Contents
BSD mandoc
Linux ACL
NAME
acl_set_file
acl_set_file_at
- set an ACL by filename
LIBRARY
Linux Access Control Lists library (libacl, -lacl).
SYNOPSIS
In sys/types.h
In sys/acl.h
Ft int
Fo acl_set_file
Fa const char *path_p
Fa acl_type_t type
Fa acl_t acl
Fc Ft int
Fo acl_set_file_at
Fa int dirfd
Fa const char *path_p
Fa int at_flags
Fa acl_type_t type
Fa acl_t acl
Fc
DESCRIPTION
The
Fn acl_set_file
function associates an access ACL with a file or directory, or
associates a default ACL with a directory. The pathname for the file or
directory is given in the argument
path_p
If
path_p
is a symbolic link,
Fn acl_set_file
operates on the file or directory the link refers to.
The effective user ID of the process must match the owner of the file or
directory or the process must have the CAP_FOWNER capability for the
request to succeed.
The value of the argument
type
is used to indicate whether the access ACL or the default ACL associated
with
path_p
is being set. If the
type
parameter is
ACL_TYPE_ACCESS
the access ACL of
path_p
shall be set. If the
type
parameter is
ACL_TYPE_DEFAULT
the default ACL of
path_p
shall be set. If the argument
type
specifies a type of ACL that cannot be associated with
path_p
then the function fails.
The
acl
parameter must reference a valid ACL according to the rules described on the
acl_valid3
manual page if the
type
parameter is
ACL_TYPE_ACCESS
and must either reference a valid ACL or an ACL with zero ACL entries if the
type
parameter is
ACL_TYPE_DEFAULT
If the
acl
parameter references an empty ACL, then the
Fn acl_set_file
function removes any default ACL associated with the directory referred to
by the
path_p
parameter.
Fn acl_set_file_at
The
Fn acl_set_file_at
function operates in exactly the same way as
Fn acl_set_file ,
except for the differences described here.
If the pathname given in
path_p
is relative, then it is interpreted relative to the directory referred to by the file descriptor
dirfd
(rather than relative to the current working directory of the calling process, as is done by
Fn acl_set_file ) .
If
path_p
is relative and
dirfd
is the special value
AT_FDCWD
then
path_p
is interpreted relative to the current working directory of the calling process (like
Fn acl_set_file ) .
If
path_p
is absolute, then
dirfd
is ignored.
The
at_flags
argument can either be 0, or include one or more of the following flags ORed:
- AT_EMPTY_PATH
-
If
path_p
is an empty string, operate on the file referred to by
dirfd
(which may have been obtained using the
open(2)
O_PATH
flag). In this case,
dirfd
can refer to any type of file, not just a directory, and the behavior of
Fn acl_set_file_at
is similar to that of
Fn acl_set_fd .
- AT_SYMLINK_NOFOLLOW
-
If
path_p
refers to a symbolic link, do not dereference it: instead, fail the operation
and set the global variable
errno
to
Er ENOTSUP .
This indicates that the symbolic link cannot have ACLs.
RETURN VALUE
Rv -std acl_set_file acl_set_file_at
ERRORS
If any of the following conditions occur, the
Fn acl_set_file
and
Fn acl_set_file_at
functions return
-1
and set
errno
to the corresponding value:
- Bq Er 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.
Argument
type
specifies a type of ACL that cannot be associated with
path_p
- Bq Er EBADF
-
The argument
path_p
is relative but the argument
dirfd
is neither
AT_FDCWD
nor a valid file descriptor.
- Bq Er EINVAL
-
The argument
acl
does not point to a valid ACL.
The ACL has more entries than the file referred to by
path_p
can obtain.
The
type
parameter is not
ACL_TYPE_ACCESS
or
ACL_TYPE_DEFAULT
The
type
parameter is
ACL_TYPE_DEFAULT
but the file referred to by
path_p
is not a directory.
An invalid flag was specified in the
at_flags
argument.
- Bq Er ENAMETOOLONG
-
The length of the argument
path_p
is too long.
- Bq Er ENOENT
-
The named object does not exist or the argument
path_p
points to an empty string.
- Bq Er 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.
- Bq Er ENOTDIR
-
A component of the path prefix is not a directory.
The argument
path_p
is relative and the argument
dirfd
is a file descriptor referring to a file other than a directory.
- Bq Er ENOTSUP
-
The argument
at_flags
includes the flag
AT_SYMLINK_NOFOLLOW
and
path_p
is a symbolic link.
The file identified by
path_p
cannot be associated with the ACL because the file system on which the file
is located does not support this.
- Bq Er EPERM
-
The process does not have appropriate privilege to perform the operation to set the ACL.
- Bq Er EROFS
-
This function requires modification of a file system which is currently rea-only.
STANDARDS
IEEE Std 1003.1e draft 17 (lqPOSIX.1erq, abandoned)
The behavior of
Fn acl_set_file
when the
acl
parameter refers to an empty ACL and the
type
parameter is
ACL_TYPE_DEFAULT
is an extension in the Linux implementation, in order that all values returned by
Fn acl_get_file
can be passed to
Fn acl_set_file .
The POSIX.1e function for removing a default ACL is
Fn acl_delete_def_file .
Function
Fn acl_get_file_at
is a Linux specific extension.
SEE ALSO
acl_delete_def_file3,
acl_get_file3,
acl_set_fd3,
acl_valid3,
acl(5)
AUTHOR
Derived from the FreeBSD manual pages written by
An Robert N M Watson Aq
rwatson@FreeBSD.org ,
and adapted for Linux by
An Andreas Gruenbacher Aq
andreas.gruenbacher@gmail.com .
Index
- NAME
-
- LIBRARY
-
- SYNOPSIS
-
- DESCRIPTION
-
- Fn acl_set_file_at
-
- RETURN VALUE
-
- ERRORS
-
- STANDARDS
-
- SEE ALSO
-
- AUTHOR
-