summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2015-06-06 18:37:45 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2015-06-06 18:38:30 -0700
commit325bf192ae281046834884b12705d6c522871b24 (patch)
tree4faf44a87bd0fde9ea9134e7cb928b629d8558e1 /lib
parent6fec047e9470731d588e52f516c1c704a7a55411 (diff)
downloademacs-325bf192ae281046834884b12705d6c522871b24.tar.gz
Merge from gnulib
This incorporates: 2015-06-06 acl-permissions: pacify -Wsuggest-attribute=const 2015-06-05 stdio: Don't redefine gets when using C++ 2015-06-05 acl-permissions: port to AIX, C89 HP-UX 2015-06-02 file-has-acl: fix build on Mac OS X 10 2015-06-01 gnulib-tool: concatenate lib_SOURCES to a single line 2015-06-01 pthread_sigmask: discount system version if a simple macro 2015-05-31 readlinkat: avoid OS X 10.10 trailing slash bug * doc/misc/texinfo.tex, lib/acl-internal.h, lib/get-permissions.c: * lib/readlinkat.c, lib/set-permissions.c, lib/stdio.in.h: * m4/acl.m4, m4/pthread_sigmask.m4, m4/readlinkat.m4: Copy from gnulib. * lib/gnulib.mk: Regenerate.
Diffstat (limited to 'lib')
-rw-r--r--lib/acl-internal.h6
-rw-r--r--lib/get-permissions.c93
-rw-r--r--lib/gnulib.mk3
-rw-r--r--lib/readlinkat.c18
-rw-r--r--lib/set-permissions.c2
-rw-r--r--lib/stdio.in.h3
6 files changed, 75 insertions, 50 deletions
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 11fdea14042..d592a7559f0 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -289,6 +289,10 @@ struct permission_context {
int get_permissions (const char *, int, mode_t, struct permission_context *);
int set_permissions (struct permission_context *, const char *, int);
-void free_permission_context (struct permission_context *);
+void free_permission_context (struct permission_context *)
+#if ! (defined USE_ACL && (HAVE_ACL_GET_FILE || defined GETACL))
+ _GL_ATTRIBUTE_CONST
+#endif
+ ;
_GL_INLINE_HEADER_END
diff --git a/lib/get-permissions.c b/lib/get-permissions.c
index ccee1f1410e..6c6618df989 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
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 95f2f8b48a6..2dd0ef82c3c 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -44,8 +44,7 @@ HAVE_INCLUDE_NEXT = (__GNUC__ || 60000000 <= __DECC_VER)
## begin gnulib module acl-permissions
-libgnu_a_SOURCES += acl-errno-valid.c acl-internal.c \
- get-permissions.c set-permissions.c
+libgnu_a_SOURCES += acl-errno-valid.c acl-internal.c get-permissions.c set-permissions.c
EXTRA_DIST += acl-internal.h acl.h acl_entries.c
diff --git a/lib/readlinkat.c b/lib/readlinkat.c
index f4826f92028..c91cf0e8200 100644
--- a/lib/readlinkat.c
+++ b/lib/readlinkat.c
@@ -18,7 +18,10 @@
#include <config.h>
+#include <errno.h>
#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
#if HAVE_READLINKAT
@@ -27,6 +30,21 @@
ssize_t
rpl_readlinkat (int fd, char const *file, char *buf, size_t len)
{
+# if READLINK_TRAILING_SLASH_BUG
+ size_t file_len = strlen (file);
+ if (file_len && file[file_len - 1] == '/')
+ {
+ /* Even if FILE without the slash is a symlink to a directory,
+ both lstat() and stat() must resolve the trailing slash to
+ the directory rather than the symlink. We can therefore
+ safely use stat() to distinguish between EINVAL and
+ ENOTDIR/ENOENT, avoiding extra overhead of rpl_lstat(). */
+ struct stat st;
+ if (stat (file, &st) == 0)
+ errno = EINVAL;
+ return -1;
+ }
+# endif /* READLINK_TRAILING_SLASH_BUG */
return readlinkat (fd, file, buf, len);
}
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index ba291f316f6..22368799f7e 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -699,7 +699,7 @@ set_acls (struct permission_context *ctx, const char *name, int desc,
if (desc != -1)
ret = fchacl (desc, &ctx->u.a, ctx->u.a.acl_len);
else
- ret = chacl (name, &ctx->u.a, ctx->u.a.acl_len);
+ ret = chacl ((char *) name, &ctx->u.a, ctx->u.a.acl_len);
if (ret < 0)
{
if (errno == ENOSYS && from_mode)
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 759c94d7abf..ec438742969 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -723,11 +723,10 @@ _GL_WARN_ON_USE (getline, "getline is unportable - "
so any use of gets warrants an unconditional warning; besides, C11
removed it. */
#undef gets
-#if HAVE_RAW_DECL_GETS
+#if HAVE_RAW_DECL_GETS && !defined __cplusplus
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif
-
#if @GNULIB_OBSTACK_PRINTF@ || @GNULIB_OBSTACK_PRINTF_POSIX@
struct obstack;
/* Grow an obstack with formatted output. Return the number of