2015-09-25 00:21:58 -07:00
|
|
|
/* Get permissions of a file. -*- coding: utf-8 -*-
|
2015-05-27 17:46:15 -07:00
|
|
|
|
2020-01-01 00:19:43 +00:00
|
|
|
Copyright (C) 2002-2003, 2005-2020 Free Software Foundation, Inc.
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2017-09-13 02:07:03 -07:00
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "acl.h"
|
|
|
|
|
|
|
|
#include "acl-internal.h"
|
|
|
|
|
|
|
|
/* Read the permissions of a file into CTX. If DESC is a valid file descriptor,
|
|
|
|
use file descriptor operations, else use filename based operations on NAME.
|
|
|
|
MODE is the file mode obtained from a previous stat call.
|
|
|
|
Return 0 if successful. Return -1 and set errno upon failure. */
|
|
|
|
|
|
|
|
int
|
|
|
|
get_permissions (const char *name, int desc, mode_t mode,
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
struct permission_context *ctx)
|
2015-05-27 17:46:15 -07:00
|
|
|
{
|
2015-06-06 18:37:45 -07:00
|
|
|
memset (ctx, 0, sizeof *ctx);
|
2015-05-27 17:46:15 -07:00
|
|
|
ctx->mode = mode;
|
|
|
|
|
|
|
|
#if USE_ACL && HAVE_ACL_GET_FILE
|
|
|
|
/* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
|
Update from Gnulib
This incorporates:
2018-10-05 explicit_bzero: make it possible to namespace
2018-10-04 fcntl: make it possible to namespace
2018-10-01 mkostemp, mkostemps: fix C++ compilation on Mac OS X
2018-09-19 maint: mktime.c now shared with glibc
2018-09-18 file-has-acl: fix test failure on Cygwin 2.9
2018-09-18 gettime: nanotime never existed
* admin/merge-gnulib (AVOIDED_MODULES): Add mkdir.
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/acl_entries.c, lib/explicit_bzero.c, lib/fcntl.c:
* lib/get-permissions.c, lib/gettime.c, lib/mktime.c:
* lib/set-permissions.c, lib/stdlib.in.h, m4/acl.m4, m4/gettime.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2018-10-08 18:21:47 -07:00
|
|
|
/* Linux, FreeBSD, Mac OS X, IRIX, Tru64, Cygwin >= 2.5 */
|
2015-05-27 17:46:15 -07:00
|
|
|
# if !HAVE_ACL_TYPE_EXTENDED
|
Update from Gnulib
This incorporates:
2018-10-05 explicit_bzero: make it possible to namespace
2018-10-04 fcntl: make it possible to namespace
2018-10-01 mkostemp, mkostemps: fix C++ compilation on Mac OS X
2018-09-19 maint: mktime.c now shared with glibc
2018-09-18 file-has-acl: fix test failure on Cygwin 2.9
2018-09-18 gettime: nanotime never existed
* admin/merge-gnulib (AVOIDED_MODULES): Add mkdir.
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/acl_entries.c, lib/explicit_bzero.c, lib/fcntl.c:
* lib/get-permissions.c, lib/gettime.c, lib/mktime.c:
* lib/set-permissions.c, lib/stdlib.in.h, m4/acl.m4, m4/gettime.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2018-10-08 18:21:47 -07:00
|
|
|
/* Linux, FreeBSD, IRIX, Tru64, Cygwin >= 2.5 */
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
if (HAVE_ACL_GET_FD && desc != -1)
|
|
|
|
ctx->acl = acl_get_fd (desc);
|
|
|
|
else
|
|
|
|
ctx->acl = acl_get_file (name, ACL_TYPE_ACCESS);
|
|
|
|
if (ctx->acl == NULL)
|
|
|
|
return acl_errno_valid (errno) ? -1 : 0;
|
|
|
|
|
|
|
|
/* With POSIX ACLs, a file cannot have "no" acl; a file without
|
|
|
|
extended permissions has a "minimal" acl which is equivalent to the
|
|
|
|
file mode. */
|
|
|
|
|
|
|
|
if (S_ISDIR (mode))
|
|
|
|
{
|
|
|
|
ctx->default_acl = acl_get_file (name, ACL_TYPE_DEFAULT);
|
|
|
|
if (ctx->default_acl == NULL)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
return -1;
|
2015-05-27 17:46:15 -07:00
|
|
|
}
|
|
|
|
|
Update from Gnulib
This incorporates:
2018-10-05 explicit_bzero: make it possible to namespace
2018-10-04 fcntl: make it possible to namespace
2018-10-01 mkostemp, mkostemps: fix C++ compilation on Mac OS X
2018-09-19 maint: mktime.c now shared with glibc
2018-09-18 file-has-acl: fix test failure on Cygwin 2.9
2018-09-18 gettime: nanotime never existed
* admin/merge-gnulib (AVOIDED_MODULES): Add mkdir.
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/acl_entries.c, lib/explicit_bzero.c, lib/fcntl.c:
* lib/get-permissions.c, lib/gettime.c, lib/mktime.c:
* lib/set-permissions.c, lib/stdlib.in.h, m4/acl.m4, m4/gettime.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2018-10-08 18:21:47 -07:00
|
|
|
# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */
|
2015-07-14 22:29:16 -07:00
|
|
|
|
|
|
|
/* TODO (see set_permissions). */
|
|
|
|
|
Update from Gnulib
This incorporates:
2018-10-05 explicit_bzero: make it possible to namespace
2018-10-04 fcntl: make it possible to namespace
2018-10-01 mkostemp, mkostemps: fix C++ compilation on Mac OS X
2018-09-19 maint: mktime.c now shared with glibc
2018-09-18 file-has-acl: fix test failure on Cygwin 2.9
2018-09-18 gettime: nanotime never existed
* admin/merge-gnulib (AVOIDED_MODULES): Add mkdir.
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/acl_entries.c, lib/explicit_bzero.c, lib/fcntl.c:
* lib/get-permissions.c, lib/gettime.c, lib/mktime.c:
* lib/set-permissions.c, lib/stdlib.in.h, m4/acl.m4, m4/gettime.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2018-10-08 18:21:47 -07:00
|
|
|
# endif
|
2015-07-14 22:29:16 -07:00
|
|
|
|
Update from Gnulib
This incorporates:
2018-10-05 explicit_bzero: make it possible to namespace
2018-10-04 fcntl: make it possible to namespace
2018-10-01 mkostemp, mkostemps: fix C++ compilation on Mac OS X
2018-09-19 maint: mktime.c now shared with glibc
2018-09-18 file-has-acl: fix test failure on Cygwin 2.9
2018-09-18 gettime: nanotime never existed
* admin/merge-gnulib (AVOIDED_MODULES): Add mkdir.
* doc/misc/texinfo.tex, lib/acl-internal.c, lib/acl-internal.h:
* lib/acl_entries.c, lib/explicit_bzero.c, lib/fcntl.c:
* lib/get-permissions.c, lib/gettime.c, lib/mktime.c:
* lib/set-permissions.c, lib/stdlib.in.h, m4/acl.m4, m4/gettime.m4:
Copy from Gnulib.
* lib/gnulib.mk.in: Regenerate.
2018-10-08 18:21:47 -07:00
|
|
|
# else /* HAVE_ACL_TYPE_EXTENDED */
|
2015-05-27 17:46:15 -07:00
|
|
|
/* Mac OS X */
|
|
|
|
|
|
|
|
/* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
|
|
|
|
and acl_get_file (name, ACL_TYPE_DEFAULT)
|
|
|
|
always return NULL / EINVAL. You have to use
|
|
|
|
acl_get_file (name, ACL_TYPE_EXTENDED)
|
|
|
|
or acl_get_fd (open (name, ...))
|
|
|
|
to retrieve an ACL.
|
|
|
|
On the other hand,
|
|
|
|
acl_set_file (name, ACL_TYPE_ACCESS, acl)
|
|
|
|
and acl_set_file (name, ACL_TYPE_DEFAULT, acl)
|
|
|
|
have the same effect as
|
|
|
|
acl_set_file (name, ACL_TYPE_EXTENDED, acl):
|
|
|
|
Each of these calls sets the file's ACL. */
|
|
|
|
|
|
|
|
if (HAVE_ACL_GET_FD && desc != -1)
|
|
|
|
ctx->acl = acl_get_fd (desc);
|
|
|
|
else
|
|
|
|
ctx->acl = acl_get_file (name, ACL_TYPE_EXTENDED);
|
|
|
|
if (ctx->acl == NULL)
|
|
|
|
return acl_errno_valid (errno) ? -1 : 0;
|
|
|
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
#elif USE_ACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
|
|
|
|
|
|
|
|
/* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
|
|
|
|
of Unixware. The acl() call returns the access and default ACL both
|
|
|
|
at once. */
|
|
|
|
# ifdef ACE_GETACL
|
|
|
|
/* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
|
|
|
|
file systems (whereas the other ones are used in UFS file systems).
|
|
|
|
There is an API
|
|
|
|
pathconf (name, _PC_ACL_ENABLED)
|
|
|
|
fpathconf (desc, _PC_ACL_ENABLED)
|
2016-01-25 12:35:15 +00:00
|
|
|
that allows us to determine which of the two kinds of ACLs is supported
|
2015-05-27 17:46:15 -07:00
|
|
|
for the given file. But some file systems may implement this call
|
|
|
|
incorrectly, so better not use it.
|
|
|
|
When fetching the source ACL, we simply fetch both ACL types.
|
|
|
|
When setting the destination ACL, we try either ACL types, assuming
|
|
|
|
that the kernel will translate the ACL from one form to the other.
|
Update from Gnulib
This incorporates:
2019-09-22 Update some URLs
2019-09-15 fcntl-h: fix compilation error of creat.c on MSVC
2019-09-15 creat: new module
2019-09-15 access: new module
2019-09-09 Add option to assume best, not worst, when cross-compiling.
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/careadlinkat.c, lib/careadlinkat.h, lib/count-leading-zeros.h:
* lib/count-trailing-zeros.h, lib/diffseq.h, lib/fcntl.in.h:
* lib/ftoastr.c, lib/get-permissions.c:
* lib/ieee754.in.h, lib/inttypes.in.h, lib/mktime.c, lib/open.c:
* lib/pathmax.h, lib/pipe2.c, lib/stddef.in.h, lib/stdint.in.h:
* lib/stdlib.in.h, lib/str-two-way.h, lib/string.in.h, lib/time.in.h:
* lib/timegm.c, lib/unistd.in.h, m4/canonicalize.m4:
* m4/extern-inline.m4, m4/fcntl_h.m4, m4/fdopendir.m4:
* m4/getgroups.m4, m4/getopt.m4, m4/gettimeofday.m4:
* m4/gnulib-common.m4, m4/largefile.m4:
* m4/lstat.m4, m4/memmem.m4, m4/mktime.m4, m4/nocrash.m4, m4/open.m4:
* m4/pselect.m4, m4/putenv.m4, m4/readlink.m4, m4/regex.m4:
* m4/symlink.m4, m4/unistd_h.m4, m4/utimens.m4, m4/utimes.m4:
Copy from Gnulib.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* m4/open-slash.m4: New file, copied from Gnulib.
2019-09-22 23:50:59 -07:00
|
|
|
(See in <https://docs.oracle.com/cd/E86824_01/html/E54765/acl-2.html>
|
2015-05-27 17:46:15 -07:00
|
|
|
the description of ENOTSUP.) */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (desc != -1)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = facl (desc, ACE_GETACLCNT, 0, NULL);
|
2015-05-27 17:46:15 -07:00
|
|
|
else
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = acl (name, ACE_GETACLCNT, 0, NULL);
|
2015-05-27 17:46:15 -07:00
|
|
|
if (ret < 0)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
{
|
|
|
|
if (errno == ENOSYS || errno == EINVAL)
|
|
|
|
ret = 0;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
ctx->ace_count = ret;
|
|
|
|
|
|
|
|
if (ctx->ace_count == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ctx->ace_entries = (ace_t *) malloc (ctx->ace_count * sizeof (ace_t));
|
|
|
|
if (ctx->ace_entries == NULL)
|
|
|
|
{
|
|
|
|
errno = ENOMEM;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc != -1)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = facl (desc, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
|
2015-05-27 17:46:15 -07:00
|
|
|
else
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = acl (name, ACE_GETACL, ctx->ace_count, ctx->ace_entries);
|
2015-05-27 17:46:15 -07:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
if (errno == ENOSYS || errno == EINVAL)
|
|
|
|
{
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
free (ctx->ace_entries);
|
|
|
|
ctx->ace_entries = NULL;
|
2015-05-27 17:46:15 -07:00
|
|
|
ctx->ace_count = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ret <= ctx->ace_count)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
{
|
|
|
|
ctx->ace_count = ret;
|
|
|
|
break;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
/* Huh? The number of ACL entries has increased since the last call.
|
|
|
|
Repeat. */
|
|
|
|
free (ctx->ace_entries);
|
|
|
|
ctx->ace_entries = NULL;
|
|
|
|
}
|
|
|
|
# endif
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (desc != -1)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = facl (desc, GETACLCNT, 0, NULL);
|
2015-05-27 17:46:15 -07:00
|
|
|
else
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = acl (name, GETACLCNT, 0, NULL);
|
2015-05-27 17:46:15 -07:00
|
|
|
if (ret < 0)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
{
|
|
|
|
if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
|
|
|
|
ret = 0;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
ctx->count = ret;
|
|
|
|
|
|
|
|
if (ctx->count == 0)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
break;
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
ctx->entries = (aclent_t *) malloc (ctx->count * sizeof (aclent_t));
|
|
|
|
if (ctx->entries == NULL)
|
|
|
|
{
|
|
|
|
errno = ENOMEM;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desc != -1)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = facl (desc, GETACL, ctx->count, ctx->entries);
|
2015-05-27 17:46:15 -07:00
|
|
|
else
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
ret = acl (name, GETACL, ctx->count, ctx->entries);
|
2015-05-27 17:46:15 -07:00
|
|
|
if (ret < 0)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
{
|
|
|
|
if (errno == ENOSYS || errno == ENOTSUP || errno == EOPNOTSUPP)
|
|
|
|
{
|
|
|
|
free (ctx->entries);
|
|
|
|
ctx->entries = NULL;
|
|
|
|
ctx->count = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
if (ret <= ctx->count)
|
Update from Gnulib
This incorporates:
2018-06-29 regex: glibc does not use intprops.h
2018-06-28 regex: port to recently proposed glibc regex merge
2018-06-25 Continue to use spaces for indentation, not tabs
2018-06-25 manywarnings: Don't enable -Wjump-misses-init by default
2018-06-25 acl-internal.h: remove _GL_ATTRIBUTE_CONST on void function
2018-06-24 manywarnings: accommodate GCC 9: remove -Wchkp and -Wabi
2018-06-24 maint: clarify comments about sticky EOF
2018-06-24 af_alg: avoid hangs when reading from streams
2018-06-17 crypto: use byteswap
2018-06-17 getloadavg: Return 0 on MS-Windows without Cygwi
2018-06-17 getloadavg: Allow building on MS-Windows without Cygwin
* build-aux/config.guess, build-aux/config.sub, doc/misc/texinfo.tex:
* lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c:
* lib/getloadavg.c, lib/gettimeofday.c, lib/md5.c, lib/pselect.c:
* lib/set-permissions.c, lib/sha1.c, lib/sha256.c, lib/sha512.c:
* lib/time.in.h, m4/getloadavg.m4, m4/gnulib-common.m4:
* m4/manywarnings.m4, m4/pthread_sigmask.m4, m4/vararrays.m4:
Copy from Gnulib.
2018-06-29 17:31:04 -07:00
|
|
|
{
|
|
|
|
ctx->count = ret;
|
|
|
|
break;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
/* Huh? The number of ACL entries has increased since the last call.
|
|
|
|
Repeat. */
|
|
|
|
free (ctx->entries);
|
|
|
|
ctx->entries = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif USE_ACL && HAVE_GETACL /* HP-UX */
|
|
|
|
|
2015-06-06 18:37:45 -07:00
|
|
|
{
|
|
|
|
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;
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
# if HAVE_ACLV_H
|
2015-06-06 18:37:45 -07:00
|
|
|
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. */
|
2015-05-27 17:46:15 -07:00
|
|
|
abort ();
|
2015-06-06 18:37:45 -07:00
|
|
|
ctx->aclv_count = ret;
|
2015-05-27 17:46:15 -07:00
|
|
|
# endif
|
2015-06-06 18:37:45 -07:00
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
#elif USE_ACL && HAVE_ACLX_GET && ACL_AIX_WIP /* AIX */
|
|
|
|
|
|
|
|
/* TODO (see set_permissions). */
|
|
|
|
|
|
|
|
#elif USE_ACL && HAVE_STATACL /* older AIX */
|
|
|
|
|
2015-06-06 18:37:45 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
#elif USE_ACL && HAVE_ACLSORT /* NonStop Kernel */
|
|
|
|
|
2015-06-06 18:37:45 -07:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
2015-05-27 17:46:15 -07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|