Diff for /embedaddon/rsync/acls.c between versions 1.1 and 1.1.1.4

version 1.1, 2012/02/17 15:09:30 version 1.1.1.4, 2021/03/17 00:32:36
Line 3 Line 3
  *   *
  * Copyright (C) 1996 Andrew Tridgell   * Copyright (C) 1996 Andrew Tridgell
  * Copyright (C) 1996 Paul Mackerras   * Copyright (C) 1996 Paul Mackerras
 * Copyright (C) 2006-2009 Wayne Davison * Copyright (C) 2006-2020 Wayne Davison
  *   *
  * This program is free software; you can redistribute it and/or modify   * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
Line 48  extern int preserve_specials; Line 48  extern int preserve_specials;
 /* When we send the access bits over the wire, we shift them 2 bits to the  /* When we send the access bits over the wire, we shift them 2 bits to the
  * left and use the lower 2 bits as flags (relevant only to a name entry).   * left and use the lower 2 bits as flags (relevant only to a name entry).
  * This makes the protocol more efficient than sending a value that would   * This makes the protocol more efficient than sending a value that would
 * be likely to have its hightest bits set. */ * be likely to have its highest bits set. */
 #define XFLAG_NAME_FOLLOWS 0x0001u  #define XFLAG_NAME_FOLLOWS 0x0001u
 #define XFLAG_NAME_IS_USER 0x0002u  #define XFLAG_NAME_IS_USER 0x0002u
   
Line 168  static rsync_acl *create_racl(void) Line 168  static rsync_acl *create_racl(void)
 {  {
         rsync_acl *racl = new(rsync_acl);          rsync_acl *racl = new(rsync_acl);
   
         if (!racl)  
                 out_of_memory("create_racl");  
         *racl = empty_rsync_acl;          *racl = empty_rsync_acl;
   
         return racl;          return racl;
Line 332  static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl * Line 330  static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *
         if (temp_ida_list.count) {          if (temp_ida_list.count) {
 #ifdef SMB_ACL_NEED_SORT  #ifdef SMB_ACL_NEED_SORT
                 if (temp_ida_list.count > 1) {                  if (temp_ida_list.count > 1) {
                        qsort(temp_ida_list.items, temp_ida_list.count,                        qsort(temp_ida_list.items, temp_ida_list.count, sizeof (id_access), id_access_sorter);
                              sizeof (id_access), id_access_sorter); 
                 }                  }
 #endif  #endif
                if (!(racl->names.idas = new_array(id_access, temp_ida_list.count)))                racl->names.idas = new_array(id_access, temp_ida_list.count);
                        out_of_memory("unpack_smb_acl");                memcpy(racl->names.idas, temp_ida_list.items, temp_ida_list.count * sizeof (id_access));
                memcpy(racl->names.idas, temp_ida_list.items, 
                       temp_ida_list.count * sizeof (id_access)); 
         } else          } else
                 racl->names.idas = NULL;                  racl->names.idas = NULL;
   
Line 423  static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsy Line 418  static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsy
 #ifdef ACLS_NEED_MASK  #ifdef ACLS_NEED_MASK
         mask_bits = racl->mask_obj == NO_ENTRY ? racl->group_obj & ~NO_ENTRY : racl->mask_obj;          mask_bits = racl->mask_obj == NO_ENTRY ? racl->group_obj & ~NO_ENTRY : racl->mask_obj;
         COE( sys_acl_create_entry,(smb_acl, &entry) );          COE( sys_acl_create_entry,(smb_acl, &entry) );
        COE( sys_acl_set_info,(entry, SMB_ACL_MASK, mask_bits, NULL) );        COE( sys_acl_set_info,(entry, SMB_ACL_MASK, mask_bits, 0) );
 #else  #else
         if (racl->mask_obj != NO_ENTRY) {          if (racl->mask_obj != NO_ENTRY) {
                 COE( sys_acl_create_entry,(smb_acl, &entry) );                  COE( sys_acl_create_entry,(smb_acl, &entry) );
Line 507  static int get_rsync_acl(const char *fname, rsync_acl  Line 502  static int get_rsync_acl(const char *fname, rsync_acl 
   
                 if (cnt) {                  if (cnt) {
                         char *bp = buf + 4*4;                          char *bp = buf + 4*4;
                        id_access *ida;                        id_access *ida = racl->names.idas = new_array(id_access, cnt);
                        if (!(ida = racl->names.idas = new_array(id_access, cnt))) 
                                out_of_memory("get_rsync_acl"); 
                         racl->names.count = cnt;                          racl->names.count = cnt;
                         for ( ; cnt--; ida++, bp += 4+4) {                          for ( ; cnt--; ida++, bp += 4+4) {
                                 ida->id = IVAL(bp, 0);                                  ida->id = IVAL(bp, 0);
Line 560  int get_acl(const char *fname, stat_x *sxp) Line 553  int get_acl(const char *fname, stat_x *sxp)
                 if (!preserve_devices)                  if (!preserve_devices)
 #endif  #endif
                         return 0;                          return 0;
        }        } else if (IS_MISSING_FILE(sxp->st))
                 return 0;
   
         if (get_rsync_acl(fname, sxp->acc_acl, SMB_ACL_TYPE_ACCESS,          if (get_rsync_acl(fname, sxp->acc_acl, SMB_ACL_TYPE_ACCESS,
                           sxp->st.st_mode) < 0) {                            sxp->st.st_mode) < 0) {
Line 704  static uchar recv_ida_entries(int f, ida_entries *ent) Line 698  static uchar recv_ida_entries(int f, ida_entries *ent)
         uchar computed_mask_bits = 0;          uchar computed_mask_bits = 0;
         int i, count = read_varint(f);          int i, count = read_varint(f);
   
        if (count) {        ent->idas = count ? new_array(id_access, count) : NULL;
                if (!(ent->idas = new_array(id_access, count))) 
                        out_of_memory("recv_ida_entries"); 
        } else 
                ent->idas = NULL; 
 
         ent->count = count;          ent->count = count;
   
         for (i = 0; i < count; i++) {          for (i = 0; i < count; i++) {
Line 824  void cache_tmp_acl(struct file_struct *file, stat_x *s Line 813  void cache_tmp_acl(struct file_struct *file, stat_x *s
         if (prior_access_count == (size_t)-1)          if (prior_access_count == (size_t)-1)
                 prior_access_count = access_acl_list.count;                  prior_access_count = access_acl_list.count;
   
        F_ACL(file) = cache_rsync_acl(sxp->acc_acl,        F_ACL(file) = cache_rsync_acl(sxp->acc_acl, SMB_ACL_TYPE_ACCESS, &access_acl_list);
                                      SMB_ACL_TYPE_ACCESS, &access_acl_list); 
   
         if (S_ISDIR(sxp->st.st_mode)) {          if (S_ISDIR(sxp->st.st_mode)) {
                 if (prior_default_count == (size_t)-1)                  if (prior_default_count == (size_t)-1)
                         prior_default_count = default_acl_list.count;                          prior_default_count = default_acl_list.count;
                F_DIR_DEFACL(file) = cache_rsync_acl(sxp->def_acl,                F_DIR_DEFACL(file) = cache_rsync_acl(sxp->def_acl, SMB_ACL_TYPE_DEFAULT, &default_acl_list);
                                      SMB_ACL_TYPE_DEFAULT, &default_acl_list); 
         }          }
 }  }
   
Line 995  static int set_rsync_acl(const char *fname, acl_duo *d Line 982  static int set_rsync_acl(const char *fname, acl_duo *d
                 mode = 0; /* eliminate compiler warning */                  mode = 0; /* eliminate compiler warning */
 #else  #else
                 if (type == SMB_ACL_TYPE_ACCESS) {                  if (type == SMB_ACL_TYPE_ACCESS) {
                        cur_mode = change_sacl_perms(duo_item->sacl, &duo_item->racl,                        cur_mode = change_sacl_perms(duo_item->sacl, &duo_item->racl, cur_mode, mode);
                                                     cur_mode, mode); 
                         if (cur_mode == (mode_t)-1)                          if (cur_mode == (mode_t)-1)
                                 return 0;                                  return 0;
                 }                  }
Line 1116  int default_perms_for_dir(const char *dir) Line 1102  int default_perms_for_dir(const char *dir)
                 case ENOSYS:                  case ENOSYS:
                         /* No ACLs are available. */                          /* No ACLs are available. */
                         break;                          break;
                case ENOENT:                default:
                        if (dry_run) {                        if (dry_run && errno == ENOENT) {
                                 /* We're doing a dry run, so the containing directory                                  /* We're doing a dry run, so the containing directory
                                  * wasn't actually created.  Don't worry about it. */                                   * wasn't actually created.  Don't worry about it. */
                                 break;                                  break;
                         }                          }
                         /* Otherwise fall through. */  
                 default:  
                         rprintf(FWARNING,                          rprintf(FWARNING,
                                 "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n",                                  "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n",
                                 dir, str_acl_type(SMB_ACL_TYPE_DEFAULT), strerror(errno));                                  dir, str_acl_type(SMB_ACL_TYPE_DEFAULT), strerror(errno));
Line 1143  int default_perms_for_dir(const char *dir) Line 1127  int default_perms_for_dir(const char *dir)
         /* Apply the permission-bit entries of the default ACL, if any. */          /* Apply the permission-bit entries of the default ACL, if any. */
         if (racl.user_obj != NO_ENTRY) {          if (racl.user_obj != NO_ENTRY) {
                 perms = rsync_acl_get_perms(&racl);                  perms = rsync_acl_get_perms(&racl);
                if (verbose > 2)                if (DEBUG_GTE(ACL, 1))
                         rprintf(FINFO, "got ACL-based default perms %o for directory %s\n", perms, dir);                          rprintf(FINFO, "got ACL-based default perms %o for directory %s\n", perms, dir);
         }          }
   

Removed from v.1.1  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>