1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-24 07:20:37 +00:00

Update from Gnulib by running admin/merge-gnulib

This adds a new file m4/xattr.m4 from Gnulib,
for NFS v4 attribute copying.
Also, do these changes by hand:
* configure.ac: Mention $LIB_XATTR" in ACL summary.
* src/Makefile.in (QCOPY_ACL_LIB): New macro.
(LIBES): Use it.
This commit is contained in:
Paul Eggert 2023-01-13 19:32:47 -08:00
parent dce42f5561
commit 9912049173
13 changed files with 130 additions and 26 deletions

View File

@ -137,7 +137,7 @@
eval 'exec perl -wSx -0777 -pi "$0" "$@"'
if 0;
my $VERSION = '2020-04-04.15:07'; # UTC
my $VERSION = '2023-01-11.04:24'; # UTC
# The definition above must lie within the first 8 lines in order
# for the Emacs time-stamp write hook (at end) to update it.
# If you change this file with Emacs, please let the write hook
@ -280,7 +280,7 @@ if (defined $stmt_re)
}
# Replace the old copyright statement.
s/$stmt_re/$stmt_wrapped/;
s/$stmt_re/$stmt_wrapped/g;
}
}
else

View File

@ -6553,7 +6553,9 @@ if test "${HAVE_GTK}" = "yes"; then
fi
if test $USE_ACL -ne 0; then
ACL_SUMMARY="yes $LIB_ACL"
ACL_SUMMARY="yes"
test "$LIB_ACL" && ACL_SUMMARY="$ACL_SUMMARY $LIB_ACL"
test "$LIB_XATTR" && ACL_SUMMARY="$ACL_SUMMARY $LIB_XATTR"
else
ACL_SUMMARY=no
fi

View File

@ -949,6 +949,7 @@ LIB_PTHREAD = @LIB_PTHREAD@
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
LIB_TIMER_TIME = @LIB_TIMER_TIME@
LIB_WSOCK32 = @LIB_WSOCK32@
LIB_XATTR = @LIB_XATTR@
LIMITS_H = @LIMITS_H@
LN_S_FILEONLY = @LN_S_FILEONLY@
LTLIBGMP = @LTLIBGMP@
@ -1041,6 +1042,7 @@ PROFILING_CFLAGS = @PROFILING_CFLAGS@
PTHREAD_H_DEFINES_STRUCT_TIMESPEC = @PTHREAD_H_DEFINES_STRUCT_TIMESPEC@
PTHREAD_SIGMASK_LIB = @PTHREAD_SIGMASK_LIB@
PTRDIFF_T_SUFFIX = @PTRDIFF_T_SUFFIX@
QCOPY_ACL_LIB = @QCOPY_ACL_LIB@
RALLOC_OBJ = @RALLOC_OBJ@
RANLIB = @RANLIB@
REPLACE_ACCESS = @REPLACE_ACCESS@

View File

@ -23,6 +23,20 @@
#include "acl-internal.h"
#if USE_XATTR
# include <attr/libattr.h>
/* Returns 1 if NAME is the name of an extended attribute that is related
to permissions, i.e. ACLs. Returns 0 otherwise. */
static int
is_attr_permissions (const char *name, struct error_context *ctx)
{
return attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
}
#endif /* USE_XATTR */
/* Copy access control lists from one file to another. If SOURCE_DESC is
a valid file descriptor, use file descriptor operations, else use
@ -39,13 +53,33 @@ int
qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
int dest_desc, mode_t mode)
{
struct permission_context ctx;
int ret;
#ifdef USE_XATTR
/* in case no ACLs present and also to set higher mode bits
we chmod before setting ACLs as doing it after could overwrite them
(especially true for NFSv4, posix ACL has that ugly "mask" hack that
nobody understands) */
ret = chmod_or_fchmod (dst_name, dest_desc, mode);
/* Rather than fiddling with acls one by one, we just copy the whole ACL xattrs
(Posix or NFSv4). Of course, that won't address ACLs conversion
(i.e. posix <-> nfs4) but we can't do it anyway, so for now, we don't care
Functions attr_copy_* return 0 in case we copied something OR nothing
to copy */
if (ret == 0)
ret = source_desc <= 0 || dest_desc <= 0
? attr_copy_file (src_name, dst_name, is_attr_permissions, NULL)
: attr_copy_fd (src_name, source_desc, dst_name, dest_desc,
is_attr_permissions, NULL);
#else
/* no XATTR, so we proceed the old dusty way */
struct permission_context ctx;
ret = get_permissions (src_name, source_desc, mode, &ctx);
if (ret != 0)
return -2;
ret = set_permissions (&ctx, dst_name, dest_desc);
free_permission_context (&ctx);
#endif
return ret;
}

View File

@ -258,7 +258,9 @@ template <int w>
/* @assert.h omit start@ */
#if 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
#if defined __clang_major__ && __clang_major__ < 5
# define _GL_HAS_BUILTIN_TRAP 0
#elif 3 < __GNUC__ + (3 < __GNUC_MINOR__ + (4 <= __GNUC_PATCHLEVEL__))
# define _GL_HAS_BUILTIN_TRAP 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_TRAP __has_builtin (__builtin_trap)
@ -266,7 +268,9 @@ template <int w>
# define _GL_HAS_BUILTIN_TRAP 0
#endif
#if 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
#if defined __clang_major__ && __clang_major__ < 5
# define _GL_HAS_BUILTIN_UNREACHABLE 0
#elif 4 < __GNUC__ + (5 <= __GNUC_MINOR__)
# define _GL_HAS_BUILTIN_UNREACHABLE 1
#elif defined __has_builtin
# define _GL_HAS_BUILTIN_UNREACHABLE __has_builtin (__builtin_unreachable)

View File

@ -1,5 +1,5 @@
# acl.m4 - check for access control list (ACL) primitives
# serial 26
# serial 27
# Copyright (C) 2002, 2004-2023 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
@ -17,7 +17,7 @@ AC_DEFUN([gl_FUNC_ACL_ARG],
])
AC_DEFUN([gl_FUNC_ACL],
AC_DEFUN_ONCE([gl_FUNC_ACL],
[
AC_REQUIRE([gl_FUNC_ACL_ARG])
AC_CHECK_FUNCS_ONCE([fchmod])

View File

@ -18,7 +18,7 @@ AC_DEFUN([gl_ASSERT_H],
[AC_LANG_PROGRAM(
[[#if defined __clang__ && __STDC_VERSION__ < 202311
#pragma clang diagnostic error "-Wc2x-extensions"
#pragma clang diagnostic error "-Wc++17-extensions"
#pragma clang diagnostic error "-Wc++1z-extensions"
#endif
#ifdef INCLUDE_ASSERT_H
#include <assert.h>
@ -60,7 +60,7 @@ AC_DEFUN([gl_ASSERT_H],
/* Solaris 11.4 <assert.h> defines static_assert as a macro with 2 arguments.
We need it also to be invocable with a single argument. */
#if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus
#undef static_assert
#undef/**/static_assert
#define static_assert _Static_assert
#endif
#endif])

View File

@ -1,4 +1,4 @@
# gettime.m4 serial 12
# gettime.m4 serial 13
dnl Copyright (C) 2002, 2004-2006, 2009-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@ -26,17 +26,24 @@ AC_DEFUN([gl_CHECK_FUNC_TIMESPEC_GET],
dnl We can't use AC_CHECK_FUNC here, because timespec_get() is defined as a
dnl static inline function in <time.h> on MSVC 14.
AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <time.h>
struct timespec ts;
]],
[[return timespec_get (&ts, 0);]])
],
[gl_cv_func_timespec_get=yes],
[gl_cv_func_timespec_get=no])
])
dnl But at the same time, we need to notice a missing declaration, like
dnl gl_CHECK_FUNCS_ANDROID does.
AC_CHECK_DECL([timespec_get], , , [[#include <time.h>]])
if test $ac_cv_have_decl_timespec_get = yes; then
AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get],
[AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[#include <time.h>
struct timespec ts;
]],
[[return timespec_get (&ts, 0);]])
],
[gl_cv_func_timespec_get=yes],
[gl_cv_func_timespec_get=no])
])
else
gl_cv_func_timespec_get=no
fi
])
AC_DEFUN([gl_GETTIME_RES],

View File

@ -71,7 +71,7 @@ AC_DEFUN([gl_COMMON_BODY], [
&& (!defined __clang_minor__ \
|| (defined __apple_build_version__ \
? 6000000 <= __apple_build_version__ \
: 3 < __clang_major__ + (5 <= __clang_minor__))))
: 5 <= __clang_major__)))
# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__)
#else
# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr

View File

@ -456,6 +456,14 @@ AC_DEFUN([gl_INIT],
gl_PREREQ_PTHREAD_SIGMASK
])
gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask])
gl_FUNC_XATTR
AC_REQUIRE([gl_FUNC_ACL])
if test "$use_xattr" = yes; then
QCOPY_ACL_LIB="$LIB_XATTR"
else
QCOPY_ACL_LIB="$LIB_ACL"
fi
AC_SUBST([QCOPY_ACL_LIB])
gl_FUNC_READLINK
gl_CONDITIONAL([GL_COND_OBJ_READLINK],
[test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1])
@ -1543,5 +1551,6 @@ AC_DEFUN([gl_FILE_LIST], [
m4/warnings.m4
m4/wchar_t.m4
m4/wint_t.m4
m4/xattr.m4
m4/zzgnulib.m4
])

View File

@ -3,7 +3,7 @@ dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl serial 11
dnl serial 12
AC_DEFUN([gl_UTIMENS],
[
@ -11,7 +11,9 @@ AC_DEFUN([gl_UTIMENS],
AC_REQUIRE([gl_FUNC_UTIMES])
AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CHECK_FUNCS_ONCE([futimes futimesat futimens utimensat lutimes])
AC_CHECK_FUNCS_ONCE([futimens utimensat lutimes])
gl_CHECK_FUNCS_ANDROID([futimes], [[#include <sys/time.h>]])
gl_CHECK_FUNCS_ANDROID([futimesat], [[#include <sys/time.h>]])
if test $ac_cv_func_futimens = no && test $ac_cv_func_futimesat = yes; then
dnl FreeBSD 8.0-rc2 mishandles futimesat(fd,NULL,time). It is not

43
m4/xattr.m4 Normal file
View File

@ -0,0 +1,43 @@
# xattr.m4 - check for Extended Attributes (Linux)
# serial 5
# Copyright (C) 2003-2023 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
AC_DEFUN([gl_FUNC_XATTR],
[
AC_ARG_ENABLE([xattr],
AS_HELP_STRING([--disable-xattr],
[do not support extended attributes]),
[use_xattr=$enableval], [use_xattr=yes])
LIB_XATTR=
AC_SUBST([LIB_XATTR])
if test "$use_xattr" = yes; then
AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
use_xattr=no
if test "$ac_cv_header_attr_libattr_h" = yes \
&& test "$ac_cv_header_attr_error_context_h" = yes; then
xattr_saved_LIBS=$LIBS
AC_SEARCH_LIBS([attr_copy_file], [attr],
[test "$ac_cv_search_attr_copy_file" = "none required" ||
LIB_XATTR="$ac_cv_search_attr_copy_file"])
AC_CHECK_FUNCS([attr_copy_file])
LIBS=$xattr_saved_LIBS
if test "$ac_cv_func_attr_copy_file" = yes; then
use_xattr=yes
fi
fi
if test $use_xattr = no; then
AC_MSG_WARN([libattr development library was not found or not usable.])
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
fi
fi
if test "$use_xattr" = yes; then
AC_DEFINE([USE_XATTR], [1],
[Define to 1 to use the Linux extended attributes library.])
fi
])

View File

@ -147,6 +147,7 @@ LIB_ACL=@LIB_ACL@
CLOCK_TIME_LIB=@CLOCK_TIME_LIB@
EUIDACCESS_LIBGEN=@EUIDACCESS_LIBGEN@
NANOSLEEP_LIB=@NANOSLEEP_LIB@
QCOPY_ACL_LIB=@QCOPY_ACL_LIB@
LIB_TIMER_TIME=@LIB_TIMER_TIME@
DBUS_CFLAGS = @DBUS_CFLAGS@
@ -559,7 +560,7 @@ lisp = $(addprefix ${lispsource}/,${shortlisp})
LIBES = $(LIBS) $(W32_LIBS) $(LIBS_GNUSTEP) $(PGTK_LIBS) $(LIBX_BASE) $(LIBIMAGE) \
$(LIBX_OTHER) $(LIBSOUND) \
$(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(LIB_ACL) $(CLOCK_TIME_LIB) \
$(NANOSLEEP_LIB) $(WEBKIT_LIBS) \
$(NANOSLEEP_LIB) $(QCOPY_ACL_LIB) $(WEBKIT_LIBS) \
$(EUIDACCESS_LIBGEN) $(LIB_TIMER_TIME) $(DBUS_LIBS) \
$(LIB_EXECINFO) $(XRANDR_LIBS) $(XINERAMA_LIBS) $(XFIXES_LIBS) \
$(XDBE_LIBS) $(XSYNC_LIBS) \