From 04e445830cb607c69888534d88e6f1f6eb01839e Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Date: Fri, 29 May 2015 20:47:45 +0200
Subject: [PATCH] acl-permissions: Fix build on Mac OS X and older AIX
 (Bug#20681)

* lib/set-permissions.c (set_acls): Fix more errors introduced in the acl
module rewrite.
---
 ChangeLog             |  4 ++++
 lib/set-permissions.c | 13 +++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fb8b44677e..a44510a6d1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-05-29  Andreas Gruenbacher  <andreas.gruenbacher@gmail.com>
 
+	acl-permissions: Fix build on Mac OS X and older AIX (Bug#20681)
+	* lib/set-permissions.c (set_acls): Fix more errors introduced in the acl
+	module rewrite.
+
 	acl-permissions: Fix build on Solaris and Cygwin
 	Reported by Tom G. Christensen <tgc@jupiterrise.com>:
 	* lib/set-permissions.c (set_acls): The count, entries, ace_count, and
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index db3696c560..ba291f316f 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -566,7 +566,7 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
 	{
 	  acl_free (acl);
 
-	  acl = acl_init (acl);
+	  acl = acl_init (0);
 	  if (acl)
 	    {
 	      if (HAVE_ACL_SET_FD && desc != -1)
@@ -582,12 +582,13 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
   else
     {
       if (HAVE_ACL_SET_FD && desc != -1)
-	ret = acl_set_fd (desc, acl);
+	ret = acl_set_fd (desc, ctx->acl);
       else
-	ret = acl_set_file (name, ACL_TYPE_EXTENDED, acl);
+	ret = acl_set_file (name, ACL_TYPE_EXTENDED, ctx->acl);
       if (ret != 0)
 	{
-	  if (! acl_errno_valid (saved_errno) && ! acl_extended_nontrivial (acl))
+	  if (! acl_errno_valid (errno)
+	      && ! acl_extended_nontrivial (ctx->acl))
 	    ret = 0;
 	}
     }
@@ -696,9 +697,9 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
   if (ret == 0 && ctx->have_u)
     {
       if (desc != -1)
-	ret = fchacl (desc, &u.a, u.a.acl_len);
+	ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
       else
-	ret = chacl (name, &u.a, u.a.acl_len);
+	ret = chacl (name, &ctx->u.a, ctx->u.a.acl_len);
       if (ret < 0)
 	{
 	  if (errno == ENOSYS && from_mode)
-- 
2.39.5