1ACL_SET_FILE(3)          BSD Library Functions Manual          ACL_SET_FILE(3)
2

NAME

4     acl_set_file — set an ACL by filename
5

LIBRARY

7     Linux Access Control Lists library (libacl, -lacl).
8

SYNOPSIS

10     #include <sys/types.h>
11     #include <sys/acl.h>
12
13     int
14     acl_set_file(const char *path_p, acl_type_t type, acl_t acl);
15

DESCRIPTION

17     The acl_set_file() function associates an access ACL with a file or
18     directory, or associates a default ACL with a directory. The pathname for
19     the file or directory is pointed to by the argument path_p.
20
21     The effective user ID of the process must match the owner of the file or
22     directory or the process must have the CAP_FOWNER capability for the
23     request to succeed.
24
25     The value of the argument type is used to indicate whether the access ACL
26     or the default ACL associated with path_p is being set. If the type
27     parameter is ACL_TYPE_ACCESS, the access ACL of path_p shall be set. If
28     the type parameter is ACL_TYPE_DEFAULT, the default ACL of path_p shall
29     be set. If the argument type specifies a type of ACL that cannot be asso‐
30     ciated with path_p, then the function fails.
31
32     The acl parameter must reference a valid ACL according to the rules
33     described on the acl_valid(3) manual page if the type parameter is
34     ACL_TYPE_ACCESS, and must either reference a valid ACL or an ACL with
35     zero ACL entries if the type parameter is ACL_TYPE_DEFAULT. If the acl
36     parameter references an empty ACL, then the acl_set_file() function
37     removes any default ACL associated with the directory referred to by the
38     path_p parameter.
39

RETURN VALUE

41     The acl_set_file() function returns the value 0 if successful; otherwise
42     the value -1 is returned and the global variable errno is set to indicate
43     the error.
44

ERRORS

46     If any of the following conditions occur, the acl_set_file() function
47     returns -1 and sets errno to the corresponding value:
48
49     [EACCES]           Search permission is denied for a component of the
50                        path prefix or the object exists and the process does
51                        not have appropriate access rights.
52
53                        Argument type specifies a type of ACL that cannot be
54                        associated with path_p.
55
56     [EINVAL]           The argument acl does not point to a valid ACL.
57
58                        The ACL has more entries than the file referred to by
59                        path_p can obtain.
60
61                        The type parameter is not ACL_TYPE_ACCESS or
62                        ACL_TYPE_DEFAULT.
63
64                        The type parameter is ACL_TYPE_DEFAULT, but the file
65                        referred to by path_p is not a directory.
66
67     [ENAMETOOLONG]     The length of the argument path_p is too long.
68
69     [ENOENT]           The named object does not exist or the argument path_p
70                        points to an empty string.
71
72     [ENOSPC]           The directory or file system that would contain the
73                        new ACL cannot be extended or the file system is out
74                        of file allocation resources.
75
76     [ENOTDIR]          A component of the path prefix is not a directory.
77
78     [ENOTSUP]          The file identified by path_p cannot be associated
79                        with the ACL because the file system on which the file
80                        is located does not support this.
81
82     [EPERM]            The process does not have appropriate privilege to
83                        perform the operation to set the ACL.
84
85     [EROFS]            This function requires modification of a file system
86                        which is currently read-only.
87

STANDARDS

89     IEEE Std 1003.1e draft 17 (“POSIX.1e”, abandoned)
90
91     The behavior of acl_set_file() when the acl parameter refers to an empty
92     ACL and the type parameter is ACL_TYPE_DEFAULT is an extension in the
93     Linux implementation, in order that all values returned by acl_get_file()
94     can be passed to acl_set_file().  The POSIX.1e function for removing a
95     default ACL is acl_delete_def_file().
96

SEE ALSO

98     acl_delete_def_file(3), acl_get_file(3), acl_set_fd(3), acl_valid(3),
99     acl(5)
100

AUTHOR

102     Derived from the FreeBSD manual pages written by Robert N M Watson
103     <rwatson@FreeBSD.org>, and adapted for Linux by Andreas Gruenbacher
104     <a.gruenbacher@bestbits.at>.
105
106Linux ACL                       March 23, 2002                       Linux ACL
Impressum