changeset 18006:7802c55be261

acl-permissions: port to older AIX, C89 HP-UX * lib/get-permissions.c (get_permissions): If USE_ACL && HAVE_GETACL /* HP-UX */, don't assume C99. If USE_ACL && HAVE_STATACL /* older AIX */, add missing decl that broke a build, reported by Michael Felt.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 05 Jun 2015 07:50:51 -0700
parents 7e97da340d57
children c4b5318623b4
files ChangeLog lib/get-permissions.c
diffstat 2 files changed, 56 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 03 16:08:10 2015 -0700
+++ b/ChangeLog	Fri Jun 05 07:50:51 2015 -0700
@@ -1,3 +1,11 @@
+2015-06-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+	acl-permissions: port to older AIX, C89 HP-UX
+	* lib/get-permissions.c (get_permissions):
+	If USE_ACL && HAVE_GETACL /* HP-UX */, don't assume C99.
+	If USE_ACL && HAVE_STATACL /* older AIX */, add missing decl
+	that broke a build, reported by Michael Felt.
+
 2015-06-03  Pádraig Brady  <P@draigBrady.com>
 
 	vasprintf-posix: avoid compiling vasnprintf where possible
--- a/lib/get-permissions.c	Wed Jun 03 16:08:10 2015 -0700
+++ b/lib/get-permissions.c	Fri Jun 05 07:50:51 2015 -0700
@@ -33,7 +33,7 @@
 get_permissions (const char *name, int desc, mode_t mode,
 		 struct permission_context *ctx)
 {
-  memset (ctx, 0, sizeof(*ctx));
+  memset (ctx, 0, sizeof *ctx);
   ctx->mode = mode;
 
 #if USE_ACL && HAVE_ACL_GET_FILE
@@ -215,38 +215,40 @@
 
 #elif USE_ACL && HAVE_GETACL /* HP-UX */
 
-  int ret;
+  {
+    int ret;
 
-  if (desc != -1)
-    ret = fgetacl (desc, NACLENTRIES, ctx->entries);
-  else
-    ret = getacl (name, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
-	ret = 0;
-      else
-        return -1;
-    }
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+    if (desc != -1)
+      ret = fgetacl (desc, NACLENTRIES, ctx->entries);
+    else
+      ret = getacl (name, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
+          ret = 0;
+        else
+          return -1;
+      }
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
 
 # if HAVE_ACLV_H
-  ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
-  if (ret < 0)
-    {
-      if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
-        ret = 0;
-      else
-        return -2;
-    }
-  else if (ret > NACLVENTRIES)
-    /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
+    ret = acl ((char *) name, ACL_GET, NACLVENTRIES, ctx->aclv_entries);
+    if (ret < 0)
+      {
+        if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
+          ret = 0;
+        else
+          return -2;
+      }
+    else if (ret > NACLVENTRIES)
+      /* If NACLVENTRIES cannot be trusted, use dynamic memory allocation.  */
       abort ();
-  ctx->aclv_count = ret;
+    ctx->aclv_count = ret;
 # endif
+  }
 
 #elif USE_ACL && HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
 
@@ -254,24 +256,27 @@
 
 #elif USE_ACL && HAVE_STATACL /* older AIX */
 
-  if (desc != -1)
-    ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  else
-    ret = statacl (name, STX_NORMAL, &ctx->u.a, sizeof (ctx->u));
-  if (ret == 0)
-    ctx->have_u = true;
+  {
+    int ret;
+    if (desc != -1)
+      ret = fstatacl (desc, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    else
+      ret = statacl (name, STX_NORMAL, &ctx->u.a, sizeof ctx->u);
+    if (ret == 0)
+      ctx->have_u = true;
+  }
 
 #elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
 
-  int ret;
-
-  ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
-  if (ret < 0)
-    return -1;
-  else if (ret > NACLENTRIES)
-    /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
-    abort ();
-  ctx->count = ret;
+  {
+    int ret = acl ((char *) name, ACL_GET, NACLENTRIES, ctx->entries);
+    if (ret < 0)
+      return -1;
+    else if (ret > NACLENTRIES)
+      /* If NACLENTRIES cannot be trusted, use dynamic memory allocation.  */
+      abort ();
+    ctx->count = ret;
+  }
 
 #endif