ARCHIVE_ENTRY_ACL(3)
π ARCHIVE_ENTRY_ACL(3) π
okay bestie, sit down, hydrate, because we're talking about archive_entry_acl β that's the ARCHIVE_ENTRY_ACL(3) manual page, and it is lowkey a whole personality. This is the family of functions that lets you mess with Access Control Lists inside archive entry descriptions. ACLs, iykyk β the fancy permission lists that go way beyond your basic rwx. This page is long so we're doing it in parts, and part one is right here, bestie π«Ά
β¨ NAME β¨
archive_entry_acl_add_entry, archive_entry_acl_add_entry_w, archive_entry_acl_clear, archive_entry_acl_count, archive_entry_acl_from_text, archive_entry_acl_from_text_w, archive_entry_acl_next, archive_entry_acl_reset, archive_entry_acl_to_text, archive_entry_acl_to_text_w, archive_entry_acl_types β functions for manipulating Access Control Lists in archive entry descriptions. slay π
π LIBRARY π
Streaming Archive Library (libarchive, -larchive) π¦
πΈ SYNOPSIS πΈ
like, here's the whole squad, exact vibes only:
#include <archive_entry.h>
void
archive_entry_acl_add_entry(struct archive_entry *a, int type,
int permset, int tag, int qualifier, const char *name);
void
archive_entry_acl_add_entry_w(struct archive_entry *a, int type,
int permset, int tag, int qualifier, const wchar_t *name);
void
archive_entry_acl_clear(struct archive_entry *a);
int
archive_entry_acl_count(struct archive_entry *a, int type);
int
archive_entry_acl_from_text(struct archive_entry *a, const char *text,
int type);
int
archive_entry_acl_from_text_w(struct archive_entry *a,
const wchar_t *text, int type);
int
archive_entry_acl_next(struct archive_entry *a, int type, int *ret_type,
int *ret_permset, int *ret_tag, int *ret_qual,
const char **ret_name);
int
archive_entry_acl_reset(struct archive_entry *a, int type);
char *
archive_entry_acl_to_text(struct archive_entry *a, ssize_t *len_p,
int flags);
wchar_t *
archive_entry_acl_to_text_w(struct archive_entry *a, ssize_t *len_p,
int flags);
int
archive_entry_acl_types(struct archive_entry *a);
twelve functions, one header, zero chill. the _w ones are the wide-character girlies, the rest are your everyday char crew. periodt β¨
more parts incoming bestie, don't go anywhere π
β¨ DESCRIPTION β¨
okay so bestie, βAccess Control Lists (ACLs)β extend the standard Unix permission model. The ACL interface of libarchive supports both POSIX.1e and NFSv4 style ACLs. Use of ACLs is restricted by various levels of ACL support in operating systems, file systems and archive formats. lowkey important, fr fr.
πΈ POSIX.1e Access Control Lists πΈ
A POSIX.1e ACL consists of a number of independent entries. Each entry specifies the permission set as a bitmask of basic permissions. Valid permissions in the permset are literally:
ARCHIVE_ENTRY_ACL_READ(r)ARCHIVE_ENTRY_ACL_WRITE(w)ARCHIVE_ENTRY_ACL_EXECUTE(x)
The permissions correspond to the normal Unix permissions. periodt.
The tag specifies the principal to which the permission applies. Valid values are:
ARCHIVE_ENTRY_ACL_USERβ The user specified by the name field.ARCHIVE_ENTRY_ACL_USER_OBJβ The owner of the file.ARCHIVE_ENTRY_ACL_GROUPβ The group specified by the name field.ARCHIVE_ENTRY_ACL_GROUP_OBJβ The group which owns the file.ARCHIVE_ENTRY_ACL_MASKβ The maximum permissions to be obtained via group permissions.ARCHIVE_ENTRY_ACL_OTHERβ Any principal who is not the file owner or a member of the owning group.
The principals ARCHIVE_ENTRY_ACL_USER_OBJ, ARCHIVE_ENTRY_ACL_GROUP_OBJ and ARCHIVE_ENTRY_ACL_OTHER are equivalent to user, group and other in the classic Unix permission model and specify non-extended ACL entries. it's giving classic.
All files have an access ACL (ARCHIVE_ENTRY_ACL_TYPE_ACCESS). This specifies the permissions required for access to the file itself. Directories have an additional ACL (ARCHIVE_ENTRY_ACL_TYPE_DEFAULT), which controls the initial access ACL for newly-created directory entries. slay.
π¦ NFSv4 Access Control Lists π¦
A NFSv4 ACL consists of multiple individual entries called Access Control Entries (ACEs). no cap.
There are four possible types of a NFSv4 ACE:
ARCHIVE_ENTRY_ACL_TYPE_ALLOWβ Allow principal to perform actions requiring given permissions.ARCHIVE_ENTRY_ACL_TYPE_DENYβ Prevent principal from performing actions requiring given permissions.ARCHIVE_ENTRY_ACL_TYPE_AUDITβ Log access attempts by principal which require given permissions.ARCHIVE_ENTRY_ACL_TYPE_ALARMβ Trigger a system alarm on access attempts by principal which require given permissions.
The tag specifies the principal to which the permission applies. Valid values are:
ARCHIVE_ENTRY_ACL_USERβ The user specified by the name field.ARCHIVE_ENTRY_ACL_USER_OBJβ The owner of the file.ARCHIVE_ENTRY_ACL_GROUPβ The group specified by the name field.ARCHIVE_ENTRY_ACL_GROUP_OBJβ The group which owns the file.ARCHIVE_ENTRY_ACL_EVERYONEβ Any principal who is not the file owner or a member of the owning group.
Entries with the ARCHIVE_ENTRY_ACL_USER or ARCHIVE_ENTRY_ACL_GROUP tag store the user and group name in the name string and optionally the user or group ID in the qualifier integer.
NFSv4 ACE permissions and flags are stored in the same permset bitfield. Some permissions share the same constant and permission character but have different effect on directories than on files. The following ACE permissions are supported:
ARCHIVE_ENTRY_ACL_READ_DATA(r) β Read data (file).ARCHIVE_ENTRY_ACL_LIST_DIRECTORY(r) β List entries (directory).ARCHIVE_ENTRY_ACL_WRITE_DATA(w) β Write data (file).ARCHIVE_ENTRY_ACL_ADD_FILE(w) β Create files (directory).ARCHIVE_ENTRY_ACL_EXECUTE(x) β Execute file or change into a directory.ARCHIVE_ENTRY_ACL_APPEND_DATA(p) β Append data (file).ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY(p) β Create subdirectories (directory).ARCHIVE_ENTRY_ACL_DELETE_CHILD(D) β Remove files and subdirectories inside a directory.ARCHIVE_ENTRY_ACL_DELETE(d) β Remove file or directory.ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES(a) β Read file or directory attributes.ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES(A) β Write file or directory attributes.ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS(R) β Read named file or directory attributes.ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS(W) β Write named file or directory attributes.ARCHIVE_ENTRY_ACL_READ_ACL(c) β Read file or directory ACL.ARCHIVE_ENTRY_ACL_WRITE_ACL(C) β Write file or directory ACL.ARCHIVE_ENTRY_ACL_WRITE_OWNER(o) β Change owner of a file or directory.ARCHIVE_ENTRY_ACL_SYNCHRONIZE(s) β Use synchronous I/O.
The following NFSv4 ACL inheritance flags are supported:
ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT(f) β Inherit parent directory ACE to files.ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT(d) β Inherit parent directory ACE to subdirectories.ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY(i) β Only inherit, do not apply the permission on the directory itself.ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT(n) β Do not propagate inherit flags. Only first-level entries inherit ACLs.ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS(S) β Trigger alarm or audit on successful access.ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS(F) β Trigger alarm or audit on failed access.ARCHIVE_ENTRY_ACL_ENTRY_INHERITED(I) β Mark that ACE was inherited.
π Functions π
archive_entry_acl_add_entry() and archive_entry_acl_add_entry_w() add a single ACL entry. For the access ACL and non-extended principals, the classic Unix permissions are updated. An archive entry cannot contain both POSIX.1e and NFSv4 ACL entries. π
archive_entry_acl_clear() removes all ACL entries and resets the enumeration pointer.
archive_entry_acl_count() counts the ACL entries that have the given type mask. type can be the bitwise-or of
ARCHIVE_ENTRY_ACL_TYPE_ACCESSARCHIVE_ENTRY_ACL_TYPE_DEFAULT
for POSIX.1e ACLs and
ARCHIVE_ENTRY_ACL_TYPE_ALLOWARCHIVE_ENTRY_ACL_TYPE_DENYARCHIVE_ENTRY_ACL_TYPE_AUDITARCHIVE_ENTRY_ACL_TYPE_ALARM
for NFSv4 ACLs. For POSIX.1e ACLs if ARCHIVE_ENTRY_ACL_TYPE_ACCESS is included and at least one extended ACL entry is found, the three non-extended ACLs are added.
archive_entry_acl_from_text() and archive_entry_acl_from_text_w() add new (or merge with existing) ACL entries from (wide) text. The argument type may take one of the following values:
ARCHIVE_ENTRY_ACL_TYPE_ACCESSARCHIVE_ENTRY_ACL_TYPE_DEFAULTARCHIVE_ENTRY_ACL_TYPE_NFS4
Supports all formats that can be created with archive_entry_acl_to_text() or respectively archive_entry_acl_to_text_w(). Existing ACL entries are preserved. To get a clean new ACL from text archive_entry_acl_clear() must be called first. Entries prefixed with βdefault:β are treated as ARCHIVE_ENTRY_ACL_TYPE_DEFAULT unless type is ARCHIVE_ENTRY_ACL_TYPE_NFS4. Invalid entries, non-parseable ACL entries and entries beginning with the β#β character (comments) are skipped.
archive_entry_acl_next() return the next entry of the ACL list. This functions may only be called after archive_entry_acl_reset() has indicated the presence of extended ACL entries.
archive_entry_acl_reset() prepare reading the list of ACL entries with archive_entry_acl_next(). The function returns 0 if no non-extended ACLs are found. In this case, the access permissions should be obtained by archive_entry_mode(3) or set using chmod(2). Otherwise, the function returns the same value as archive_entry_acl_count().
archive_entry_acl_to_text() and archive_entry_acl_to_text_w() convert the ACL entries for the given type into a (wide) string of ACL entries separated by newline. If the pointer len_p is not NULL, then the function shall return the length of the string (not including the NULL terminator) in the location pointed to by len_p. The flag argument is a bitwise-or.
The following flags are effective only on POSIX.1e ACL:
ARCHIVE_ENTRY_ACL_TYPE_ACCESSβ Output access ACLs.ARCHIVE_ENTRY_ACL_TYPE_DEFAULTβ Output POSIX.1e default ACLs.ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULTβ Prefix each default ACL entry with the word βdefault:β.ARCHIVE_ENTRY_ACL_STYLE_SOLARISβ The mask and other ACLs don not contain a double colon.
The following flags are effective only on NFSv4 ACL:
ARCHIVE_ENTRY_ACL_STYLE_COMPACTβ Do not output minus characters for unset permissions and flags in NFSv4 ACL permission and flag fields.
The following flags are effective on both POSIX.1e and NFSv4 ACL:
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_IDβ Add an additional colon-separated field containing the user or group id.ARCHIVE_ENTRY_ACL_STYLE_SEPARATOR_COMMAβ Separate ACL entries with comma instead of newline.
If the archive entry contains NFSv4 ACLs, all types of NFSv4 ACLs are returned. It the entry contains POSIX.1e ACLs and none of the flags ARCHIVE_ENTRY_ACL_TYPE_ACCESS or ARCHIVE_ENTRY_ACL_TYPE_DEFAULT are specified, both access and default entries are returned and default entries are prefixed with βdefault:β.
archive_entry_acl_types() get ACL entry types contained in an archive entry's ACL. As POSIX.1e and NFSv4 ACL entries cannot be mixed, this function is a very efficient way to detect if an ACL already contains POSIX.1e or NFSv4 ACL entries.
β¨ RETURN VALUES β¨
okay bestie, here's the part where we find out what you actually get back, because every function in this family has opinions π
archive_entry_acl_count()andarchive_entry_acl_reset()β these two return the number of ACL entries that match the given type mask. and here's the lil plot twist: for POSIX.1e ACLs, if the type mask includesARCHIVE_ENTRY_ACL_TYPE_ACCESSand at least one extended ACL entry exists, the three classic Unix permissions get counted too. so like, they're not just sitting on the sidelines, they're on the roster π«Άarchive_entry_acl_from_text()andarchive_entry_acl_from_text_w()β these returnARCHIVE_OKif every single entry was successfully parsed. but if one or more entries were invalid or just straight-up non-parseable, you getARCHIVE_WARNinstead. so it's giving "mostly fine but read the room" energy πarchive_entry_acl_next()β returnsARCHIVE_OKon success,ARCHIVE_EOFwhen there are no more ACL entries left (we love a clean ending), andARCHIVE_WARNif you never calledarchive_entry_acl_reset()first. yeah. that one's on you bestie πarchive_entry_acl_to_text()β returns a string representing the ACL entries matching the given type and flags on success, orNULLon error. iconic when it works, devastating when it doesn't πarchive_entry_acl_to_text_w()β same deal but make it wide: returns a wide string representing the ACL entries matching the given type and flags on success, orNULLon error. she's the wide-character sister, no cap β¨archive_entry_acl_types()β returns a bitmask of ACL entry types, or0if the archive entry has no ACL entries at all. zero. nothing. empty. the void πΈ
fr fr, watch those ARCHIVE_WARN returns β they're not full-on failures, they're lil "hey, something was off" notes, and if you ignore them you're gonna have a bad time π
π SEE ALSO π
go read those next bestie, they're the whole vibe, iykyk π
and that's the whole page, we ate and left no crumbs π
this lil masterpiece came from the Debian crew, dated February 15, 2017, and it lives in section 3 as ARCHIVE_ENTRY_ACL(3) β periodt π
π¦β
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2010 Joerg Sonnenberger
- Copyright (c) 2016 Martin Matuska
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms