diff --git a/ChangeLog b/ChangeLog index e1f2492..ed68032 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2015-06-05 Paul Eggert + + 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 vasprintf-posix: avoid compiling vasnprintf where possible diff --git a/lib/get-permissions.c b/lib/get-permissions.c index ccee1f1..6c6618d 100644 --- a/lib/get-permissions.c +++ b/lib/get-permissions.c @@ -33,7 +33,7 @@ int 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 @@ get_permissions (const char *name, int desc, mode_t mode, #elif USE_ACL && HAVE_GETACL /* HP-UX */ - 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; + { + 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 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 @@ get_permissions (const char *name, int desc, mode_t mode, #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 ((char *) 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