4
4
* Copyright (C) 1996 Andrew Tridgell
5
5
* Copyright (C) 1996 Paul Mackerras
6
* Copyright (C) 2006-2008 Wayne Davison
6
* Copyright (C) 2006-2009 Wayne Davison
8
8
* This program is free software; you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
88
88
static item_list access_acl_list = EMPTY_ITEM_LIST;
89
89
static item_list default_acl_list = EMPTY_ITEM_LIST;
91
static size_t prior_access_count = (size_t)-1;
92
static size_t prior_default_count = (size_t)-1;
91
94
/* === Calculations on ACL types === */
93
96
static const char *str_acl_type(SMB_ACL_TYPE_T type)
138
141
if (racl->group_obj == racl->mask_obj)
139
142
racl->group_obj = NO_ENTRY;
140
racl->mask_obj = NO_ENTRY;
143
if (racl->names.count != 0)
144
racl->mask_obj = NO_ENTRY;
142
146
racl->other_obj = NO_ENTRY;
749
753
/* If we received a superfluous mask, throw it away. */
750
754
duo_item->racl.mask_obj = NO_ENTRY;
752
if (!duo_item->racl.names.count) {
753
/* If we received a superfluous mask, throw it away. */
754
if (duo_item->racl.mask_obj != NO_ENTRY) {
755
/* Mask off the group perms with it first. */
756
duo_item->racl.group_obj &= duo_item->racl.mask_obj | NO_ENTRY;
757
duo_item->racl.mask_obj = NO_ENTRY;
759
} else if (duo_item->racl.mask_obj == NO_ENTRY) /* Must be non-empty with lists. */
756
if (duo_item->racl.names.count && duo_item->racl.mask_obj == NO_ENTRY) /* Must be non-empty with lists. */
760
757
duo_item->racl.mask_obj = (computed_mask_bits | duo_item->racl.group_obj) & ~NO_ENTRY;
795
792
/* Turn the ACL data in stat_x into cached ACL data, setting the index
796
793
* values in the file struct. */
797
void cache_acl(struct file_struct *file, stat_x *sxp)
794
void cache_tmp_acl(struct file_struct *file, stat_x *sxp)
796
if (prior_access_count == (size_t)-1)
797
prior_access_count = access_acl_list.count;
799
799
F_ACL(file) = cache_rsync_acl(sxp->acc_acl,
800
800
SMB_ACL_TYPE_ACCESS, &access_acl_list);
802
802
if (S_ISDIR(sxp->st.st_mode)) {
803
if (prior_default_count == (size_t)-1)
804
prior_default_count = default_acl_list.count;
803
805
F_DIR_DEFACL(file) = cache_rsync_acl(sxp->def_acl,
804
806
SMB_ACL_TYPE_DEFAULT, &default_acl_list);
810
static void uncache_duo_acls(item_list *duo_list, size_t start)
812
acl_duo *duo_item = duo_list->items;
813
acl_duo *duo_start = duo_item + start;
815
duo_item += duo_list->count;
816
duo_list->count = start;
818
while (duo_item-- > duo_start) {
819
rsync_acl_free(&duo_item->racl);
821
sys_acl_free_acl(duo_item->sacl);
825
void uncache_tmp_acls(void)
827
if (prior_access_count != (size_t)-1) {
828
uncache_duo_acls(&access_acl_list, prior_access_count);
829
prior_access_count = (size_t)-1;
832
if (prior_default_count != (size_t)-1) {
833
uncache_duo_acls(&default_acl_list, prior_default_count);
834
prior_default_count = (size_t)-1;
808
838
#ifndef HAVE_OSX_ACLS
809
839
static mode_t change_sacl_perms(SMB_ACL_T sacl, rsync_acl *racl, mode_t old_mode, mode_t mode)