- Use F_OWNER() and F_GROUP() instead of F_UID() and F_GID().
[rsync/rsync.git] / acls.c
diff --git a/acls.c b/acls.c
index bfb12c7..af554cb 100644 (file)
--- a/acls.c
+++ b/acls.c
@@ -33,6 +33,7 @@ extern int protocol_version;
 extern int numeric_ids;
 extern int inc_recurse;
 
+/* Flags used to indicate what items are being transmitted for an entry. */
 #define XMIT_USER_OBJ (1<<0)
 #define XMIT_USER_LIST (1<<1)
 #define XMIT_GROUP_OBJ (1<<2)
@@ -40,6 +41,8 @@ extern int inc_recurse;
 #define XMIT_MASK_OBJ (1<<4)
 #define XMIT_OTHER_OBJ (1<<5)
 
+#define NO_ENTRY ((uchar)0x80)
+
 /* === ACL structures === */
 
 typedef struct {
@@ -57,7 +60,6 @@ typedef struct {
        uchar len;
 } idname;
 
-#define NO_ENTRY ((uchar)0x80)
 typedef struct rsync_acl {
        ida_entries users;
        ida_entries groups;
@@ -559,11 +561,11 @@ static void send_ida_entries(const ida_entries *idal, int user_names, int f)
        id_access *ida;
        size_t count = idal->count;
 
-       write_abbrevint(f, idal->count);
+       write_varint(f, idal->count);
 
        for (ida = idal->idas; count--; ida++) {
                char *name = user_names ? add_uid(ida->id) : add_gid(ida->id);
-               write_abbrevint(f, ida->id);
+               write_varint(f, ida->id);
                if (inc_recurse && name) {
                        int len = strlen(name);
                        write_byte(f, ida->access | (uchar)0x80);
@@ -580,7 +582,7 @@ static void send_rsync_acl(rsync_acl *racl, SMB_ACL_TYPE_T type,
        int ndx = find_matching_rsync_acl(racl, type, racl_list);
 
        /* Send 0 (-1 + 1) to indicate that literal ACL data follows. */
-       write_abbrevint(f, ndx + 1);
+       write_varint(f, ndx + 1);
 
        if (ndx < 0) {
                rsync_acl *new_racl = EXPAND_ITEM_LIST(racl_list, rsync_acl, 1000);
@@ -672,10 +674,10 @@ static uchar recv_acl_access(uchar *name_follows_val, int f)
 static uchar recv_ida_entries(ida_entries *ent, int user_names, int f)
 {
        uchar computed_mask_bits = 0;
-       int i, count = read_abbrevint(f);
+       int i, count = read_varint(f);
 
        if (count) {
-               if (!(ent->idas = new_array(id_access, ent->count)))
+               if (!(ent->idas = new_array(id_access, count)))
                        out_of_memory("recv_ida_entries");
        } else
                ent->idas = NULL;
@@ -684,20 +686,20 @@ static uchar recv_ida_entries(ida_entries *ent, int user_names, int f)
 
        for (i = 0; i < count; i++) {
                uchar has_name;
-               id_t id = read_abbrevint(f);
+               id_t id = read_varint(f);
                int access = recv_acl_access(&has_name, f);
 
                if (has_name) {
                        if (user_names)
                                id = recv_user_name(f, id);
                        else
-                               id = recv_group_name(f, id);
+                               id = recv_group_name(f, id, NULL);
                } else if (user_names) {
                        if (inc_recurse && am_root && !numeric_ids)
                                id = match_uid(id);
                } else {
                        if (inc_recurse && (!am_root || !numeric_ids))
-                               id = match_gid(id);
+                               id = match_gid(id, NULL);
                }
 
                ent->idas[i].id = id;
@@ -713,7 +715,7 @@ static int recv_rsync_acl(item_list *racl_list, SMB_ACL_TYPE_T type, int f)
        uchar computed_mask_bits = 0;
        acl_duo *duo_item;
        uchar flags;
-       int ndx = read_abbrevint(f);
+       int ndx = read_varint(f);
 
        if (ndx < 0 || (size_t)ndx > racl_list->count) {
                rprintf(FERROR, "recv_acl_index: %s ACL index %d > %d\n",
@@ -967,23 +969,22 @@ int set_acl(const char *fname, const struct file_struct *file, statx *sxp)
        return unchanged;
 }
 
-/* Non-incremental recursion needs to convert all the received IDs
- * in a single pass after the file-list is complete. */
+/* Non-incremental recursion needs to convert all the received IDs.
+ * This is done in a single pass after receiving the whole file-list. */
 static void match_racl_ids(const item_list *racl_list)
 {
        int list_cnt, name_cnt;
        acl_duo *duo_item = racl_list->items;
        for (list_cnt = racl_list->count; list_cnt--; duo_item++) {
                ida_entries *idal = &duo_item->racl.users;
-               for (name_cnt = idal->count; name_cnt--; idal++) {
-                       id_access *ida = idal->idas;
+               id_access *ida = idal->idas;
+               for (name_cnt = idal->count; name_cnt--; ida++)
                        ida->id = match_uid(ida->id);
-               }
+
                idal = &duo_item->racl.groups;
-               for (name_cnt = idal->count; name_cnt--; idal++) {
-                       id_access *ida = idal->idas;
-                       ida->id = match_gid(ida->id);
-               }
+               ida = idal->idas;
+               for (name_cnt = idal->count; name_cnt--; ida++)
+                       ida->id = match_gid(ida->id, NULL);
        }
 }