~ubuntu-branches/ubuntu/lucid/rsync/lucid

« back to all changes in this revision

Viewing changes to acls.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Slootman
  • Date: 2009-06-17 13:43:12 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20090617134312-aopuowraetuj41s8
Tags: 3.0.6-1
* new upstream release.
* Manpage now states that MD5 is used for protocol version 30 and higher.
  closes:#520330
* Updated to standards version 3.8.2. Added debian/README.source .
* Added lintian override for embedded-zlib, as this is a modified version
  optimized for the rsync protocol. I.e. the standard zlib version will not
  work as well.
* Added a 'status' option to the init.d script.
  closes:#492138
* Manpage now declares --delete-during to be the default in the summary.
  closes:#472767,#476368

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
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
7
7
 *
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;
90
90
 
 
91
static size_t prior_access_count = (size_t)-1;
 
92
static size_t prior_default_count = (size_t)-1;
 
93
 
91
94
/* === Calculations on ACL types === */
92
95
 
93
96
static const char *str_acl_type(SMB_ACL_TYPE_T type)
137
140
        else {
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;
141
145
        }
142
146
        racl->other_obj = NO_ENTRY;
143
147
}
749
753
        /* If we received a superfluous mask, throw it away. */
750
754
        duo_item->racl.mask_obj = NO_ENTRY;
751
755
#else
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;
758
 
                }
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;
761
758
#endif
762
759
 
794
791
 
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)
798
795
{
 
796
        if (prior_access_count == (size_t)-1)
 
797
                prior_access_count = access_acl_list.count;
 
798
 
799
799
        F_ACL(file) = cache_rsync_acl(sxp->acc_acl,
800
800
                                      SMB_ACL_TYPE_ACCESS, &access_acl_list);
801
801
 
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);
805
807
        }
806
808
}
807
809
 
 
810
static void uncache_duo_acls(item_list *duo_list, size_t start)
 
811
{
 
812
        acl_duo *duo_item = duo_list->items;
 
813
        acl_duo *duo_start = duo_item + start;
 
814
 
 
815
        duo_item += duo_list->count;
 
816
        duo_list->count = start;
 
817
 
 
818
        while (duo_item-- > duo_start) {
 
819
                rsync_acl_free(&duo_item->racl);
 
820
                if (duo_item->sacl)
 
821
                        sys_acl_free_acl(duo_item->sacl);
 
822
        }
 
823
}
 
824
 
 
825
void uncache_tmp_acls(void)
 
826
{
 
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;
 
830
        }
 
831
 
 
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;
 
835
        }
 
836
}
 
837
 
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)
810
840
{