From: Paul Eggert Date: Sat, 14 Jan 2023 03:32:47 +0000 (-0800) Subject: Update from Gnulib by running admin/merge-gnulib X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=99120491730c5839a5ba15ded187d481af1e71a7;p=emacs.git 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. --- diff --git a/build-aux/update-copyright b/build-aux/update-copyright index ce919bac727..99196fceef6 100755 --- a/build-aux/update-copyright +++ b/build-aux/update-copyright @@ -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 diff --git a/configure.ac b/configure.ac index 8c11414fe0b..d7aec4414e3 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index 2ebf187e867..2097850c812 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -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@ diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c index 883bcf7d588..0f4159b7fd9 100644 --- a/lib/qcopy-acl.c +++ b/lib/qcopy-acl.c @@ -23,6 +23,20 @@ #include "acl-internal.h" +#if USE_XATTR + +# include + +/* 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; } diff --git a/lib/verify.h b/lib/verify.h index 17d6e78c816..b63cb264321 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -258,7 +258,9 @@ template /* @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 # 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) diff --git a/m4/acl.m4 b/m4/acl.m4 index e612f1ae34b..dc9853a156d 100644 --- a/m4/acl.m4 +++ b/m4/acl.m4 @@ -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]) diff --git a/m4/assert_h.m4 b/m4/assert_h.m4 index 6275f633a69..3801452ef0d 100644 --- a/m4/assert_h.m4 +++ b/m4/assert_h.m4 @@ -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 @@ -60,7 +60,7 @@ AC_DEFUN([gl_ASSERT_H], /* Solaris 11.4 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]) diff --git a/m4/gettime.m4 b/m4/gettime.m4 index 06f32fe26c2..7e353fcd00e 100644 --- a/m4/gettime.m4 +++ b/m4/gettime.m4 @@ -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 on MSVC 14. - AC_CACHE_CHECK([for timespec_get], [gl_cv_func_timespec_get], - [AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include - 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 ]]) + 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 + 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], diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 26239caa2b1..2db3376b01e 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -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 diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index ae5001c44b5..10c74fa2392 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -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 ]) diff --git a/m4/utimens.m4 b/m4/utimens.m4 index ae35ef789b8..c5d9b69e6f5 100644 --- a/m4/utimens.m4 +++ b/m4/utimens.m4 @@ -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 ]]) + gl_CHECK_FUNCS_ANDROID([futimesat], [[#include ]]) 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 diff --git a/m4/xattr.m4 b/m4/xattr.m4 new file mode 100644 index 00000000000..6141515652a --- /dev/null +++ b/m4/xattr.m4 @@ -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 +]) diff --git a/src/Makefile.in b/src/Makefile.in index 1a2a316b310..e08e5eead28 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -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) \