--- rsync-3.2.7/rsync.c.orig	2022-12-13 01:17:07 +0000
+++ rsync-3.2.7/rsync.c	2022-12-13 01:25:26 +0000
@@ -653,7 +653,11 @@
 #endif
 
 #ifdef HAVE_CHMOD
+#ifndef HAVE_AIX_ACLS
 	if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) {
+#endif
+		/* Because chmod will disable extended permissions on
+		 * AIX, so always use do_chmod update permissions */
 		int ret = am_root < 0 ? 0 : do_chmod(fname, new_mode);
 		if (ret < 0) {
 			rsyserr(FERROR_XFER, errno,
@@ -663,8 +667,10 @@
 		}
 		if (ret == 0) /* ret == 1 if symlink could not be set */
 			updated |= UPDATED_MODE;
+#ifndef HAVE_AIX_ACLS
 	}
 #endif
+#endif
 
 	if (INFO_GTE(NAME, 2) && flags & ATTRS_REPORT) {
 		if (updated)
--- rsync-3.2.7/lib/sysacls.c.orig	2022-12-13 01:26:47 +0000
+++ rsync-3.2.7/lib/sysacls.c	2022-12-13 01:32:31 +0000
@@ -43,7 +43,7 @@
  for older UNIX systems that don't support ACLs.
 
  The interfaces that each ACL implementation must support are as follows :
-
+SMB_ACL_OTHER
  int sys_acl_get_entry(SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p)
  int sys_acl_get_tag_type(SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p)
  int sys_acl_get_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T *tag_type_p, uint32 *bits_p, id_t *u_g_id_p)
@@ -1802,6 +1802,7 @@
 	case SMB_ACL_USER_OBJ:
 	case SMB_ACL_GROUP_OBJ:
 	case SMB_ACL_OTHER:
+	case SMB_ACL_MASK:
 		*tag_type_p = entry_d->ace_id->id_type;
 		break;
 
@@ -2424,7 +2425,7 @@
 	file_acl->acl_mode = S_IXACL;
 
 	for (acl_entry_link=theacl; acl_entry_link != NULL; acl_entry_link = acl_entry_link->nextp) {
-		acl_entry_link->entryp->ace_access >>= 6;
+		/* acl_entry_link->entryp->ace_access >>= 6; */
 		id_type = acl_entry_link->entryp->ace_id->id_type;
 
 		switch (id_type) {
--- rsync-3.2.7/syscall.c.orig	2022-12-12 05:41:19 +0000
+++ rsync-3.2.7/syscall.c	2022-12-16 02:24:25 +0000
@@ -22,6 +22,11 @@
 
 #include "rsync.h"
 
+#ifdef HAVE_SYS_ACL_H
+#include <sys/acl.h>
+#endif
+
+
 #if !defined MKNOD_CREATES_SOCKETS && defined HAVE_SYS_UN_H
 #include <sys/un.h>
 #endif
@@ -264,15 +269,37 @@
 # else
 			code = 1;
 # endif
-		} else
-			code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */
-		break;
+		} else {
+#ifdef HAVE_AIX_ACLS
+	struct stat s;
+	if (stat(path, &s) == -1)
+		return -1;
+#endif
+	code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */
+#ifdef HAVE_AIX_ACLS
+	/* The extended permissions are disabled when use the
+	* chmod() on AIX, so we must enable it again */
+	struct acl *acl;	
+
+	if (s.st_mode & S_IXACL) {
+		/* BUFSIZ equal MAX_ACL_SIZE */
+		if ((acl = (struct acl *)calloc(BUFSIZ, 1)) == NULL)
+			return -1;
+		if (statacl((char *)path, 0, acl, BUFSIZ) < 0)
+			return -1;
+		acl->acl_mode |= S_IXACL;
+		if (chacl((char *)path, acl, acl->acl_len) < 0)
+			return -1;
+		free(acl);
 	}
+#endif
+   }
+#endif /* !HAVE_LCHMOD */
 	if (code != 0 && (preserve_perms || preserve_executability))
 		return code;
 	return 0;
 }
-#endif
+}
 
 int do_rename(const char *old_path, const char *new_path)
 {
@@ -708,7 +735,6 @@
 		errno = EINVAL;
 		goto close_and_return_error;
 	}
-#endif
-
+#endif 
 	return fd;
 }
