123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700 |
- #include "archive_platform.h"
- #if ARCHIVE_ACL_FREEBSD
- #ifdef HAVE_ERRNO_H
- #include <errno.h>
- #endif
- #ifdef HAVE_FCNTL_H
- #include <fcntl.h>
- #endif
- #ifdef HAVE_SYS_TYPES_H
- #include <sys/types.h>
- #endif
- #ifdef HAVE_SYS_ACL_H
- #define _ACL_PRIVATE
- #include <sys/acl.h>
- #endif
- #include "archive_entry.h"
- #include "archive_private.h"
- #include "archive_read_disk_private.h"
- #include "archive_write_disk_private.h"
- typedef struct {
- const int a_perm;
- const int p_perm;
- } acl_perm_map_t;
- static const acl_perm_map_t acl_posix_perm_map[] = {
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
- {ARCHIVE_ENTRY_ACL_READ, ACL_READ},
- };
- static const int acl_posix_perm_map_size =
- (int)(sizeof(acl_posix_perm_map)/sizeof(acl_posix_perm_map[0]));
- #if ARCHIVE_ACL_FREEBSD_NFS4
- static const acl_perm_map_t acl_nfs4_perm_map[] = {
- {ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
- {ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
- {ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
- {ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_FILE, ACL_ADD_FILE},
- {ARCHIVE_ENTRY_ACL_APPEND_DATA, ACL_APPEND_DATA},
- {ARCHIVE_ENTRY_ACL_ADD_SUBDIRECTORY, ACL_ADD_SUBDIRECTORY},
- {ARCHIVE_ENTRY_ACL_READ_NAMED_ATTRS, ACL_READ_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_WRITE_NAMED_ATTRS, ACL_WRITE_NAMED_ATTRS},
- {ARCHIVE_ENTRY_ACL_DELETE_CHILD, ACL_DELETE_CHILD},
- {ARCHIVE_ENTRY_ACL_READ_ATTRIBUTES, ACL_READ_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_WRITE_ATTRIBUTES, ACL_WRITE_ATTRIBUTES},
- {ARCHIVE_ENTRY_ACL_DELETE, ACL_DELETE},
- {ARCHIVE_ENTRY_ACL_READ_ACL, ACL_READ_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
- {ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
- {ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
- };
- static const int acl_nfs4_perm_map_size =
- (int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0]));
- static const acl_perm_map_t acl_nfs4_flag_map[] = {
- {ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT, ACL_ENTRY_FILE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_DIRECTORY_INHERIT, ACL_ENTRY_DIRECTORY_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY},
- {ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS, ACL_ENTRY_SUCCESSFUL_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS, ACL_ENTRY_FAILED_ACCESS},
- {ARCHIVE_ENTRY_ACL_ENTRY_INHERITED, ACL_ENTRY_INHERITED}
- };
- static const int acl_nfs4_flag_map_size =
- (int)(sizeof(acl_nfs4_flag_map)/sizeof(acl_nfs4_flag_map[0]));
- #endif
- static int
- translate_acl(struct archive_read_disk *a,
- struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
- {
- #if ARCHIVE_ACL_FREEBSD_NFS4
- int brand;
- acl_flagset_t acl_flagset;
- acl_entry_type_t acl_type;
- #endif
- acl_tag_t acl_tag;
- acl_entry_t acl_entry;
- acl_permset_t acl_permset;
- int i, entry_acl_type, perm_map_size;
- const acl_perm_map_t *perm_map;
- int r, s, ae_id, ae_tag, ae_perm;
- void *q;
- const char *ae_name;
- #if ARCHIVE_ACL_FREEBSD_NFS4
-
-
-
- if (acl_get_brand_np(acl, &brand) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to read ACL brand");
- return (ARCHIVE_WARN);
- }
- switch (brand) {
- case ACL_BRAND_POSIX:
- switch (default_entry_acl_type) {
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Invalid ACL entry type for POSIX.1e ACL");
- return (ARCHIVE_WARN);
- }
- break;
- case ACL_BRAND_NFS4:
- if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Invalid ACL entry type for NFSv4 ACL");
- return (ARCHIVE_WARN);
- }
- break;
- default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Unknown ACL brand");
- return (ARCHIVE_WARN);
- }
- #endif
- s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
- if (s == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to get first ACL entry");
- return (ARCHIVE_WARN);
- }
- while (s == 1) {
- ae_id = -1;
- ae_name = NULL;
- ae_perm = 0;
- if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get ACL tag type");
- return (ARCHIVE_WARN);
- }
- switch (acl_tag) {
- case ACL_USER:
- q = acl_get_qualifier(acl_entry);
- if (q != NULL) {
- ae_id = (int)*(uid_t *)q;
- acl_free(q);
- ae_name = archive_read_disk_uname(&a->archive,
- ae_id);
- }
- ae_tag = ARCHIVE_ENTRY_ACL_USER;
- break;
- case ACL_GROUP:
- q = acl_get_qualifier(acl_entry);
- if (q != NULL) {
- ae_id = (int)*(gid_t *)q;
- acl_free(q);
- ae_name = archive_read_disk_gname(&a->archive,
- ae_id);
- }
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP;
- break;
- case ACL_MASK:
- ae_tag = ARCHIVE_ENTRY_ACL_MASK;
- break;
- case ACL_USER_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_USER_OBJ;
- break;
- case ACL_GROUP_OBJ:
- ae_tag = ARCHIVE_ENTRY_ACL_GROUP_OBJ;
- break;
- case ACL_OTHER:
- ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
- break;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- case ACL_EVERYONE:
- ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
- break;
- #endif
- default:
-
- s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
- continue;
- }
-
- entry_acl_type = default_entry_acl_type;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
-
- if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
- archive_set_error(&a->archive, errno, "Failed "
- "to get ACL type from a NFSv4 ACL entry");
- return (ARCHIVE_WARN);
- }
- switch (acl_type) {
- case ACL_ENTRY_TYPE_ALLOW:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
- break;
- case ACL_ENTRY_TYPE_DENY:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_DENY;
- break;
- case ACL_ENTRY_TYPE_AUDIT:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_AUDIT;
- break;
- case ACL_ENTRY_TYPE_ALARM:
- entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
- break;
- default:
- archive_set_error(&a->archive, errno,
- "Invalid NFSv4 ACL entry type");
- return (ARCHIVE_WARN);
- }
-
- if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get flagset from a NFSv4 "
- "ACL entry");
- return (ARCHIVE_WARN);
- }
- for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
- r = acl_get_flag_np(acl_flagset,
- acl_nfs4_flag_map[i].p_perm);
- if (r == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to check flag in a NFSv4 "
- "ACL flagset");
- return (ARCHIVE_WARN);
- } else if (r)
- ae_perm |= acl_nfs4_flag_map[i].a_perm;
- }
- }
- #endif
- if (acl_get_permset(acl_entry, &acl_permset) != 0) {
- archive_set_error(&a->archive, errno,
- "Failed to get ACL permission set");
- return (ARCHIVE_WARN);
- }
- #if ARCHIVE_ACL_FREEBSD_NFS4
- if (default_entry_acl_type & ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
- perm_map_size = acl_nfs4_perm_map_size;
- perm_map = acl_nfs4_perm_map;
- } else {
- #endif
- perm_map_size = acl_posix_perm_map_size;
- perm_map = acl_posix_perm_map;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- }
- #endif
- for (i = 0; i < perm_map_size; ++i) {
- r = acl_get_perm_np(acl_permset, perm_map[i].p_perm);
- if (r == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to check permission in an ACL "
- "permission set");
- return (ARCHIVE_WARN);
- } else if (r)
- ae_perm |= perm_map[i].a_perm;
- }
- archive_entry_acl_add_entry(entry, entry_acl_type,
- ae_perm, ae_tag,
- ae_id, ae_name);
- s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
- if (s == -1) {
- archive_set_error(&a->archive, errno,
- "Failed to get next ACL entry");
- return (ARCHIVE_WARN);
- }
- }
- return (ARCHIVE_OK);
- }
- static int
- set_acl(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl,
- int ae_requested_type, const char *tname)
- {
- int acl_type = 0;
- acl_t acl;
- acl_entry_t acl_entry;
- acl_permset_t acl_permset;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- acl_flagset_t acl_flagset;
- int r;
- #endif
- int ret;
- int ae_type, ae_permset, ae_tag, ae_id;
- int perm_map_size;
- const acl_perm_map_t *perm_map;
- uid_t ae_uid;
- gid_t ae_gid;
- const char *ae_name;
- int entries;
- int i;
- ret = ARCHIVE_OK;
- entries = archive_acl_reset(abstract_acl, ae_requested_type);
- if (entries == 0)
- return (ARCHIVE_OK);
- switch (ae_requested_type) {
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- acl_type = ACL_TYPE_ACCESS;
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
- acl_type = ACL_TYPE_DEFAULT;
- break;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
- acl_type = ACL_TYPE_NFS4;
- break;
- #endif
- default:
- errno = ENOENT;
- archive_set_error(a, errno, "Unsupported ACL type");
- return (ARCHIVE_FAILED);
- }
- acl = acl_init(entries);
- if (acl == (acl_t)NULL) {
- archive_set_error(a, errno,
- "Failed to initialize ACL working storage");
- return (ARCHIVE_FAILED);
- }
- while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
- &ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
- if (acl_create_entry(&acl, &acl_entry) != 0) {
- archive_set_error(a, errno,
- "Failed to create a new ACL entry");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- switch (ae_tag) {
- case ARCHIVE_ENTRY_ACL_USER:
- ae_uid = archive_write_disk_uid(a, ae_name, ae_id);
- acl_set_tag_type(acl_entry, ACL_USER);
- acl_set_qualifier(acl_entry, &ae_uid);
- break;
- case ARCHIVE_ENTRY_ACL_GROUP:
- ae_gid = archive_write_disk_gid(a, ae_name, ae_id);
- acl_set_tag_type(acl_entry, ACL_GROUP);
- acl_set_qualifier(acl_entry, &ae_gid);
- break;
- case ARCHIVE_ENTRY_ACL_USER_OBJ:
- acl_set_tag_type(acl_entry, ACL_USER_OBJ);
- break;
- case ARCHIVE_ENTRY_ACL_GROUP_OBJ:
- acl_set_tag_type(acl_entry, ACL_GROUP_OBJ);
- break;
- case ARCHIVE_ENTRY_ACL_MASK:
- acl_set_tag_type(acl_entry, ACL_MASK);
- break;
- case ARCHIVE_ENTRY_ACL_OTHER:
- acl_set_tag_type(acl_entry, ACL_OTHER);
- break;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- case ARCHIVE_ENTRY_ACL_EVERYONE:
- acl_set_tag_type(acl_entry, ACL_EVERYONE);
- break;
- #endif
- default:
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Unsupported ACL tag");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- #if ARCHIVE_ACL_FREEBSD_NFS4
- r = 0;
- switch (ae_type) {
- case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
- r = acl_set_entry_type_np(acl_entry,
- ACL_ENTRY_TYPE_ALLOW);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_DENY:
- r = acl_set_entry_type_np(acl_entry,
- ACL_ENTRY_TYPE_DENY);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
- r = acl_set_entry_type_np(acl_entry,
- ACL_ENTRY_TYPE_AUDIT);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
- r = acl_set_entry_type_np(acl_entry,
- ACL_ENTRY_TYPE_ALARM);
- break;
- case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
- case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
-
- break;
- default:
- archive_set_error(a, ARCHIVE_ERRNO_MISC,
- "Unsupported ACL entry type");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- if (r != 0) {
- archive_set_error(a, errno,
- "Failed to set ACL entry type");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- #endif
- if (acl_get_permset(acl_entry, &acl_permset) != 0) {
- archive_set_error(a, errno,
- "Failed to get ACL permission set");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- if (acl_clear_perms(acl_permset) != 0) {
- archive_set_error(a, errno,
- "Failed to clear ACL permissions");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- #if ARCHIVE_ACL_FREEBSD_NFS4
- if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
- perm_map_size = acl_nfs4_perm_map_size;
- perm_map = acl_nfs4_perm_map;
- } else {
- #endif
- perm_map_size = acl_posix_perm_map_size;
- perm_map = acl_posix_perm_map;
- #if ARCHIVE_ACL_FREEBSD_NFS4
- }
- #endif
- for (i = 0; i < perm_map_size; ++i) {
- if (ae_permset & perm_map[i].a_perm) {
- if (acl_add_perm(acl_permset,
- perm_map[i].p_perm) != 0) {
- archive_set_error(a, errno,
- "Failed to add ACL permission");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- }
- }
- #if ARCHIVE_ACL_FREEBSD_NFS4
- if (ae_requested_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
-
- if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
- archive_set_error(a, errno,
- "Failed to get flagset from an NFSv4 "
- "ACL entry");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- if (acl_clear_flags_np(acl_flagset) != 0) {
- archive_set_error(a, errno,
- "Failed to clear flags from an NFSv4 "
- "ACL flagset");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- for (i = 0; i < acl_nfs4_flag_map_size; ++i) {
- if (ae_permset & acl_nfs4_flag_map[i].a_perm) {
- if (acl_add_flag_np(acl_flagset,
- acl_nfs4_flag_map[i].p_perm) != 0) {
- archive_set_error(a, errno,
- "Failed to add flag to "
- "NFSv4 ACL flagset");
- ret = ARCHIVE_FAILED;
- goto exit_free;
- }
- }
- }
- }
- #endif
- }
-
- if (fd >= 0) {
- if (acl_set_fd_np(fd, acl, acl_type) == 0)
- ret = ARCHIVE_OK;
- else {
- if (errno == EOPNOTSUPP) {
-
- ret = ARCHIVE_OK;
- } else {
- archive_set_error(a, errno,
- "Failed to set acl on fd: %s", tname);
- ret = ARCHIVE_WARN;
- }
- }
- }
- #if HAVE_ACL_SET_LINK_NP
- else if (acl_set_link_np(name, acl_type, acl) != 0)
- #else
-
- else if (acl_set_file(name, acl_type, acl) != 0)
- #endif
- {
- if (errno == EOPNOTSUPP) {
-
- ret = ARCHIVE_OK;
- } else {
- archive_set_error(a, errno, "Failed to set acl: %s",
- tname);
- ret = ARCHIVE_WARN;
- }
- }
- exit_free:
- acl_free(acl);
- return (ret);
- }
- int
- archive_read_disk_entry_setup_acls(struct archive_read_disk *a,
- struct archive_entry *entry, int *fd)
- {
- const char *accpath;
- acl_t acl;
- int r;
- accpath = NULL;
- if (*fd < 0) {
- accpath = archive_read_disk_entry_setup_path(a, entry, fd);
- if (accpath == NULL)
- return (ARCHIVE_WARN);
- }
- archive_entry_acl_clear(entry);
- acl = NULL;
- #if ARCHIVE_ACL_FREEBSD_NFS4
-
- if (*fd >= 0)
- acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
- else if (!a->follow_symlinks)
- acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
- else
- acl = acl_get_file(accpath, ACL_TYPE_NFS4);
-
- if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
- acl_free(acl);
- acl = NULL;
- return (ARCHIVE_OK);
- }
- if (acl != NULL) {
- r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
- acl_free(acl);
- acl = NULL;
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate NFSv4 ACLs");
- }
- return (r);
- }
- #endif
-
- if (*fd >= 0)
- acl = acl_get_fd_np(*fd, ACL_TYPE_ACCESS);
- #if HAVE_ACL_GET_LINK_NP
- else if (!a->follow_symlinks)
- acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
- #else
- else if ((!a->follow_symlinks)
- && (archive_entry_filetype(entry) == AE_IFLNK))
-
- acl = NULL;
- #endif
- else
- acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
- #if HAVE_ACL_IS_TRIVIAL_NP
-
- if (acl != NULL && acl_is_trivial_np(acl, &r) == 0 && r == 1) {
- acl_free(acl);
- acl = NULL;
- }
- #endif
- if (acl != NULL) {
- r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
- acl_free(acl);
- acl = NULL;
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate access ACLs");
- return (r);
- }
- }
-
- if (S_ISDIR(archive_entry_mode(entry))) {
- if (*fd >= 0)
- acl = acl_get_fd_np(*fd, ACL_TYPE_DEFAULT);
- else
- acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
- if (acl != NULL) {
- r = translate_acl(a, entry, acl,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
- acl_free(acl);
- if (r != ARCHIVE_OK) {
- archive_set_error(&a->archive, errno,
- "Couldn't translate default ACLs");
- return (r);
- }
- }
- }
- return (ARCHIVE_OK);
- }
- int
- archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl, __LA_MODE_T mode)
- {
- int ret = ARCHIVE_OK;
- (void)mode;
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
- ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
- if (ret != ARCHIVE_OK)
- return (ret);
- }
- if ((archive_acl_types(abstract_acl)
- & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
- ret = set_acl(a, fd, name, abstract_acl,
- ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
-
- return (ret);
- }
- #if ARCHIVE_ACL_FREEBSD_NFS4
- else if ((archive_acl_types(abstract_acl) &
- ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
- ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
- }
- #endif
- return (ret);
- }
- #endif
|