aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2015-04-24 22:39:47 -0700
committerPaul Eggert2015-04-24 22:41:56 -0700
commit27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a (patch)
treea1bdf790a993c537044305912d3d4796789dccb0
parent52ba851db188de47b303120df00c77e3aad7e542 (diff)
downloademacs-27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a.tar.gz
emacs-27e6afeb6fe1f0b9f083fdfeacf6d69c6936a34a.zip
Merge from gnulib
This incorporates: 2015-04-24 file-has-acl: new module, split from acl 2015-04-24 manywarnings: add GCC 5.1 warnings 2015-04-21 lstat: fix cross-compilation 'ln -s' problem 2015-04-15 qacl: Simplify HP-UX acl_nontrivial check 2015-04-15 acl: On Linux, check for acls without libacl 2015-04-14 tempname: avoid unused parameter warnings (trivial) * lib/acl-internal.c: New file, from gnulib. * lib/file-has-acl.c: Remove; no longer imported from gnulib. * lib/acl-internal.h, lib/gnulib.mk, lib/qcopy-acl.c, lib/tempname.c: * m4/acl.m4, m4/gnulib-comp.m4, m4/lstat.m4, m4/manywarnings.m4: Update from gnulib.
-rw-r--r--lib/acl-internal.c (renamed from lib/file-has-acl.c)462
-rw-r--r--lib/acl-internal.h2
-rw-r--r--lib/gnulib.mk2
-rw-r--r--lib/qcopy-acl.c17
-rw-r--r--lib/tempname.c4
-rw-r--r--m4/acl.m447
-rw-r--r--m4/gnulib-comp.m42
-rw-r--r--m4/lstat.m448
-rw-r--r--m4/manywarnings.m423
9 files changed, 95 insertions, 512 deletions
diff --git a/lib/file-has-acl.c b/lib/acl-internal.c
index 2ef4e8bdefd..d9bd4461ea6 100644
--- a/lib/file-has-acl.c
+++ b/lib/acl-internal.c
@@ -17,19 +17,12 @@
17 17
18 Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */ 18 Written by Paul Eggert, Andreas Grünbacher, and Bruno Haible. */
19 19
20/* Without this pragma, gcc 4.7.0 20120126 may suggest that the
21 file_has_acl function might be candidate for attribute 'const' */
22#if (__GNUC__ == 4 && 6 <= __GNUC_MINOR__) || 4 < __GNUC__
23# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
24#endif
25
26#include <config.h> 20#include <config.h>
27 21
28#include "acl.h" 22#include "acl.h"
29 23
30#include "acl-internal.h" 24#include "acl-internal.h"
31 25
32
33#if USE_ACL && HAVE_ACL_GET_FILE 26#if USE_ACL && HAVE_ACL_GET_FILE
34 27
35# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */ 28# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
@@ -124,7 +117,6 @@ acl_access_nontrivial (acl_t acl)
124 117
125# endif 118# endif
126 119
127
128#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ 120#elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
129 121
130/* Test an ACL retrieved with GETACL. 122/* Test an ACL retrieved with GETACL.
@@ -344,18 +336,19 @@ acl_ace_nontrivial (int count, ace_t *entries)
344/* Return 1 if the given ACL is non-trivial. 336/* Return 1 if the given ACL is non-trivial.
345 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ 337 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
346int 338int
347acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb) 339acl_nontrivial (int count, struct acl_entry *entries)
348{ 340{
349 int i; 341 int i;
350 342
343 if (count > 3)
344 return 1;
345
351 for (i = 0; i < count; i++) 346 for (i = 0; i < count; i++)
352 { 347 {
353 struct acl_entry *ace = &entries[i]; 348 struct acl_entry *ace = &entries[i];
354 349
355 if (!((ace->uid == sb->st_uid && ace->gid == ACL_NSGROUP) 350 if (ace->uid != ACL_NSUSER && ace->gid != ACL_NSGROUP)
356 || (ace->uid == ACL_NSUSER && ace->gid == sb->st_gid) 351 return 1;
357 || (ace->uid == ACL_NSUSER && ace->gid == ACL_NSGROUP)))
358 return 1;
359 } 352 }
360 return 0; 353 return 0;
361} 354}
@@ -474,446 +467,3 @@ acl_nontrivial (int count, struct acl *entries)
474} 467}
475 468
476#endif 469#endif
477
478
479/* Return 1 if NAME has a nontrivial access control list, 0 if NAME
480 only has no or a base access control list, and -1 (setting errno)
481 on error. SB must be set to the stat buffer of NAME, obtained
482 through stat() or lstat(). */
483
484int
485file_has_acl (char const *name, struct stat const *sb)
486{
487#if USE_ACL
488 if (! S_ISLNK (sb->st_mode))
489 {
490# if HAVE_ACL_GET_FILE
491
492 /* POSIX 1003.1e (draft 17 -- abandoned) specific version. */
493 /* Linux, FreeBSD, Mac OS X, IRIX, Tru64 */
494 int ret;
495
496 if (HAVE_ACL_EXTENDED_FILE) /* Linux */
497 {
498 /* On Linux, acl_extended_file is an optimized function: It only
499 makes two calls to getxattr(), one for ACL_TYPE_ACCESS, one for
500 ACL_TYPE_DEFAULT. */
501 ret = acl_extended_file (name);
502 }
503 else /* FreeBSD, Mac OS X, IRIX, Tru64 */
504 {
505# if HAVE_ACL_TYPE_EXTENDED /* Mac OS X */
506 /* On Mac OS X, acl_get_file (name, ACL_TYPE_ACCESS)
507 and acl_get_file (name, ACL_TYPE_DEFAULT)
508 always return NULL / EINVAL. There is no point in making
509 these two useless calls. The real ACL is retrieved through
510 acl_get_file (name, ACL_TYPE_EXTENDED). */
511 acl_t acl = acl_get_file (name, ACL_TYPE_EXTENDED);
512 if (acl)
513 {
514 ret = acl_extended_nontrivial (acl);
515 acl_free (acl);
516 }
517 else
518 ret = -1;
519# else /* FreeBSD, IRIX, Tru64 */
520 acl_t acl = acl_get_file (name, ACL_TYPE_ACCESS);
521 if (acl)
522 {
523 int saved_errno;
524
525 ret = acl_access_nontrivial (acl);
526 saved_errno = errno;
527 acl_free (acl);
528 errno = saved_errno;
529# if HAVE_ACL_FREE_TEXT /* Tru64 */
530 /* On OSF/1, acl_get_file (name, ACL_TYPE_DEFAULT) always
531 returns NULL with errno not set. There is no point in
532 making this call. */
533# else /* FreeBSD, IRIX */
534 /* On Linux, FreeBSD, IRIX, acl_get_file (name, ACL_TYPE_ACCESS)
535 and acl_get_file (name, ACL_TYPE_DEFAULT) on a directory
536 either both succeed or both fail; it depends on the
537 file system. Therefore there is no point in making the second
538 call if the first one already failed. */
539 if (ret == 0 && S_ISDIR (sb->st_mode))
540 {
541 acl = acl_get_file (name, ACL_TYPE_DEFAULT);
542 if (acl)
543 {
544 ret = (0 < acl_entries (acl));
545 acl_free (acl);
546 }
547 else
548 ret = -1;
549 }
550# endif
551 }
552 else
553 ret = -1;
554# endif
555 }
556 if (ret < 0)
557 return - acl_errno_valid (errno);
558 return ret;
559
560# elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */
561
562# if defined ACL_NO_TRIVIAL
563
564 /* Solaris 10 (newer version), which has additional API declared in
565 <sys/acl.h> (acl_t) and implemented in libsec (acl_set, acl_trivial,
566 acl_fromtext, ...). */
567 return acl_trivial (name);
568
569# else /* Solaris, Cygwin, general case */
570
571 /* Solaris 2.5 through Solaris 10, Cygwin, and contemporaneous versions
572 of Unixware. The acl() call returns the access and default ACL both
573 at once. */
574 {
575 /* Initially, try to read the entries into a stack-allocated buffer.
576 Use malloc if it does not fit. */
577 enum
578 {
579 alloc_init = 4000 / sizeof (aclent_t), /* >= 3 */
580 alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (aclent_t))
581 };
582 aclent_t buf[alloc_init];
583 size_t alloc = alloc_init;
584 aclent_t *entries = buf;
585 aclent_t *malloced = NULL;
586 int count;
587
588 for (;;)
589 {
590 count = acl (name, GETACL, alloc, entries);
591 if (count < 0 && errno == ENOSPC)
592 {
593 /* Increase the size of the buffer. */
594 free (malloced);
595 if (alloc > alloc_max / 2)
596 {
597 errno = ENOMEM;
598 return -1;
599 }
600 alloc = 2 * alloc; /* <= alloc_max */
601 entries = malloced =
602 (aclent_t *) malloc (alloc * sizeof (aclent_t));
603 if (entries == NULL)
604 {
605 errno = ENOMEM;
606 return -1;
607 }
608 continue;
609 }
610 break;
611 }
612 if (count < 0)
613 {
614 if (errno == ENOSYS || errno == ENOTSUP)
615 ;
616 else
617 {
618 int saved_errno = errno;
619 free (malloced);
620 errno = saved_errno;
621 return -1;
622 }
623 }
624 else if (count == 0)
625 ;
626 else
627 {
628 /* Don't use MIN_ACL_ENTRIES: It's set to 4 on Cygwin, but Cygwin
629 returns only 3 entries for files with no ACL. But this is safe:
630 If there are more than 4 entries, there cannot be only the
631 "user::", "group::", "other:", and "mask:" entries. */
632 if (count > 4)
633 {
634 free (malloced);
635 return 1;
636 }
637
638 if (acl_nontrivial (count, entries))
639 {
640 free (malloced);
641 return 1;
642 }
643 }
644 free (malloced);
645 }
646
647# ifdef ACE_GETACL
648 /* Solaris also has a different variant of ACLs, used in ZFS and NFSv4
649 file systems (whereas the other ones are used in UFS file systems). */
650 {
651 /* Initially, try to read the entries into a stack-allocated buffer.
652 Use malloc if it does not fit. */
653 enum
654 {
655 alloc_init = 4000 / sizeof (ace_t), /* >= 3 */
656 alloc_max = MIN (INT_MAX, SIZE_MAX / sizeof (ace_t))
657 };
658 ace_t buf[alloc_init];
659 size_t alloc = alloc_init;
660 ace_t *entries = buf;
661 ace_t *malloced = NULL;
662 int count;
663
664 for (;;)
665 {
666 count = acl (name, ACE_GETACL, alloc, entries);
667 if (count < 0 && errno == ENOSPC)
668 {
669 /* Increase the size of the buffer. */
670 free (malloced);
671 if (alloc > alloc_max / 2)
672 {
673 errno = ENOMEM;
674 return -1;
675 }
676 alloc = 2 * alloc; /* <= alloc_max */
677 entries = malloced = (ace_t *) malloc (alloc * sizeof (ace_t));
678 if (entries == NULL)
679 {
680 errno = ENOMEM;
681 return -1;
682 }
683 continue;
684 }
685 break;
686 }
687 if (count < 0)
688 {
689 if (errno == ENOSYS || errno == EINVAL)
690 ;
691 else
692 {
693 int saved_errno = errno;
694 free (malloced);
695 errno = saved_errno;
696 return -1;
697 }
698 }
699 else if (count == 0)
700 ;
701 else
702 {
703 /* In the old (original Solaris 10) convention:
704 If there are more than 3 entries, there cannot be only the
705 ACE_OWNER, ACE_GROUP, ACE_OTHER entries.
706 In the newer Solaris 10 and Solaris 11 convention:
707 If there are more than 6 entries, there cannot be only the
708 ACE_OWNER, ACE_GROUP, ACE_EVERYONE entries, each once with
709 NEW_ACE_ACCESS_ALLOWED_ACE_TYPE and once with
710 NEW_ACE_ACCESS_DENIED_ACE_TYPE. */
711 if (count > 6)
712 {
713 free (malloced);
714 return 1;
715 }
716
717 if (acl_ace_nontrivial (count, entries))
718 {
719 free (malloced);
720 return 1;
721 }
722 }
723 free (malloced);
724 }
725# endif
726
727 return 0;
728# endif
729
730# elif HAVE_GETACL /* HP-UX */
731
732 {
733 struct acl_entry entries[NACLENTRIES];
734 int count;
735
736 count = getacl (name, NACLENTRIES, entries);
737
738 if (count < 0)
739 {
740 /* ENOSYS is seen on newer HP-UX versions.
741 EOPNOTSUPP is typically seen on NFS mounts.
742 ENOTSUP was seen on Quantum StorNext file systems (cvfs). */
743 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP)
744 ;
745 else
746 return -1;
747 }
748 else if (count == 0)
749 return 0;
750 else /* count > 0 */
751 {
752 if (count > NACLENTRIES)
753 /* If NACLENTRIES cannot be trusted, use dynamic memory
754 allocation. */
755 abort ();
756
757 /* If there are more than 3 entries, there cannot be only the
758 (uid,%), (%,gid), (%,%) entries. */
759 if (count > 3)
760 return 1;
761
762 {
763 struct stat statbuf;
764
765 if (stat (name, &statbuf) < 0)
766 return -1;
767
768 return acl_nontrivial (count, entries, &statbuf);
769 }
770 }
771 }
772
773# if HAVE_ACLV_H /* HP-UX >= 11.11 */
774
775 {
776 struct acl entries[NACLVENTRIES];
777 int count;
778
779 count = acl ((char *) name, ACL_GET, NACLVENTRIES, entries);
780
781 if (count < 0)
782 {
783 /* EOPNOTSUPP is seen on NFS in HP-UX 11.11, 11.23.
784 EINVAL is seen on NFS in HP-UX 11.31. */
785 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == EINVAL)
786 ;
787 else
788 return -1;
789 }
790 else if (count == 0)
791 return 0;
792 else /* count > 0 */
793 {
794 if (count > NACLVENTRIES)
795 /* If NACLVENTRIES cannot be trusted, use dynamic memory
796 allocation. */
797 abort ();
798
799 /* If there are more than 4 entries, there cannot be only the
800 four base ACL entries. */
801 if (count > 4)
802 return 1;
803
804 return aclv_nontrivial (count, entries);
805 }
806 }
807
808# endif
809
810# elif HAVE_ACLX_GET && defined ACL_AIX_WIP /* AIX */
811
812 acl_type_t type;
813 char aclbuf[1024];
814 void *acl = aclbuf;
815 size_t aclsize = sizeof (aclbuf);
816 mode_t mode;
817
818 for (;;)
819 {
820 /* The docs say that type being 0 is equivalent to ACL_ANY, but it
821 is not true, in AIX 5.3. */
822 type.u64 = ACL_ANY;
823 if (aclx_get (name, 0, &type, aclbuf, &aclsize, &mode) >= 0)
824 break;
825 if (errno == ENOSYS)
826 return 0;
827 if (errno != ENOSPC)
828 {
829 if (acl != aclbuf)
830 {
831 int saved_errno = errno;
832 free (acl);
833 errno = saved_errno;
834 }
835 return -1;
836 }
837 aclsize = 2 * aclsize;
838 if (acl != aclbuf)
839 free (acl);
840 acl = malloc (aclsize);
841 if (acl == NULL)
842 {
843 errno = ENOMEM;
844 return -1;
845 }
846 }
847
848 if (type.u64 == ACL_AIXC)
849 {
850 int result = acl_nontrivial ((struct acl *) acl);
851 if (acl != aclbuf)
852 free (acl);
853 return result;
854 }
855 else if (type.u64 == ACL_NFS4)
856 {
857 int result = acl_nfs4_nontrivial ((nfs4_acl_int_t *) acl);
858 if (acl != aclbuf)
859 free (acl);
860 return result;
861 }
862 else
863 {
864 /* A newer type of ACL has been introduced in the system.
865 We should better support it. */
866 if (acl != aclbuf)
867 free (acl);
868 errno = EINVAL;
869 return -1;
870 }
871
872# elif HAVE_STATACL /* older AIX */
873
874 union { struct acl a; char room[4096]; } u;
875
876 if (statacl (name, STX_NORMAL, &u.a, sizeof (u)) < 0)
877 return -1;
878
879 return acl_nontrivial (&u.a);
880
881# elif HAVE_ACLSORT /* NonStop Kernel */
882
883 {
884 struct acl entries[NACLENTRIES];
885 int count;
886
887 count = acl ((char *) name, ACL_GET, NACLENTRIES, entries);
888
889 if (count < 0)
890 {
891 if (errno == ENOSYS || errno == ENOTSUP)
892 ;
893 else
894 return -1;
895 }
896 else if (count == 0)
897 return 0;
898 else /* count > 0 */
899 {
900 if (count > NACLENTRIES)
901 /* If NACLENTRIES cannot be trusted, use dynamic memory
902 allocation. */
903 abort ();
904
905 /* If there are more than 4 entries, there cannot be only the
906 four base ACL entries. */
907 if (count > 4)
908 return 1;
909
910 return acl_nontrivial (count, entries);
911 }
912 }
913
914# endif
915 }
916#endif
917
918 return 0;
919}
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index 243ca32b822..9b9fae2e9e0 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -220,7 +220,7 @@ extern int acl_ace_nontrivial (int count, ace_t *entries) _GL_ATTRIBUTE_PURE;
220 220
221/* Return 1 if the given ACL is non-trivial. 221/* Return 1 if the given ACL is non-trivial.
222 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */ 222 Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. */
223extern int acl_nontrivial (int count, struct acl_entry *entries, struct stat *sb); 223extern int acl_nontrivial (int count, struct acl_entry *entries);
224 224
225# if HAVE_ACLV_H /* HP-UX >= 11.11 */ 225# if HAVE_ACLV_H /* HP-UX >= 11.11 */
226 226
diff --git a/lib/gnulib.mk b/lib/gnulib.mk
index 273b018bdb8..bec0d3bb19b 100644
--- a/lib/gnulib.mk
+++ b/lib/gnulib.mk
@@ -698,7 +698,7 @@ EXTRA_libgnu_a_SOURCES += putenv.c
698 698
699## begin gnulib module qacl 699## begin gnulib module qacl
700 700
701libgnu_a_SOURCES += acl-errno-valid.c file-has-acl.c qcopy-acl.c qset-acl.c 701libgnu_a_SOURCES += acl-errno-valid.c acl-internal.c qcopy-acl.c qset-acl.c
702 702
703EXTRA_DIST += acl-internal.h acl.h acl_entries.c 703EXTRA_DIST += acl-internal.h acl.h acl_entries.c
704 704
diff --git a/lib/qcopy-acl.c b/lib/qcopy-acl.c
index aac76a12432..bc258ba560b 100644
--- a/lib/qcopy-acl.c
+++ b/lib/qcopy-acl.c
@@ -437,20 +437,9 @@ qcopy_acl (const char *src_name, int source_desc, const char *dst_name,
437 if (ret < 0 && saved_errno == 0) 437 if (ret < 0 && saved_errno == 0)
438 { 438 {
439 saved_errno = errno; 439 saved_errno = errno;
440 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP) 440 if (errno == ENOSYS || errno == EOPNOTSUPP || errno == ENOTSUP
441 { 441 && !acl_nontrivial (count, entries))
442 struct stat source_statbuf; 442 saved_errno = 0;
443
444 if ((source_desc != -1
445 ? fstat (source_desc, &source_statbuf)
446 : stat (src_name, &source_statbuf)) == 0)
447 {
448 if (!acl_nontrivial (count, entries, &source_statbuf))
449 saved_errno = 0;
450 }
451 else
452 saved_errno = errno;
453 }
454 } 443 }
455 else 444 else
456 did_chmod = 1; 445 did_chmod = 1;
diff --git a/lib/tempname.c b/lib/tempname.c
index 8e6d26cc485..69c572fbcb4 100644
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -269,13 +269,13 @@ try_file (char *tmpl, void *flags)
269} 269}
270 270
271static int 271static int
272try_dir (char *tmpl, void *flags) 272try_dir (char *tmpl, void *flags _GL_UNUSED)
273{ 273{
274 return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR); 274 return __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
275} 275}
276 276
277static int 277static int
278try_nocreate (char *tmpl, void *flags) 278try_nocreate (char *tmpl, void *flags _GL_UNUSED)
279{ 279{
280 struct_stat64 st; 280 struct_stat64 st;
281 281
diff --git a/m4/acl.m4 b/m4/acl.m4
index c77f0edd0e7..186353c395b 100644
--- a/m4/acl.m4
+++ b/m4/acl.m4
@@ -1,5 +1,5 @@
1# acl.m4 - check for access control list (ACL) primitives 1# acl.m4 - check for access control list (ACL) primitives
2# serial 17 2# serial 18
3 3
4# Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc. 4# Copyright (C) 2002, 2004-2015 Free Software Foundation, Inc.
5# This file is free software; the Free Software Foundation 5# This file is free software; the Free Software Foundation
@@ -8,23 +8,29 @@
8 8
9# Written by Paul Eggert and Jim Meyering. 9# Written by Paul Eggert and Jim Meyering.
10 10
11AC_DEFUN([gl_FUNC_ACL], 11AC_DEFUN([gl_FUNC_ACL_ARG],
12[ 12[
13 gl_need_lib_has_acl=
13 AC_ARG_ENABLE([acl], 14 AC_ARG_ENABLE([acl],
14 AS_HELP_STRING([--disable-acl], [do not support ACLs]), 15 AS_HELP_STRING([--disable-acl], [do not support ACLs]),
15 , [enable_acl=auto]) 16 , [enable_acl=auto])
17])
18
16 19
20AC_DEFUN([gl_FUNC_ACL],
21[
22 AC_REQUIRE([gl_FUNC_ACL_ARG])
17 AC_CHECK_FUNCS_ONCE([fchmod]) 23 AC_CHECK_FUNCS_ONCE([fchmod])
18 LIB_ACL= 24 LIB_ACL=
19 use_acl=0 25 use_acl=0
20 if test "x$enable_acl" != "xno"; then 26 if test "$enable_acl" != no; then
21 dnl On all platforms, the ACL related API is declared in <sys/acl.h>. 27 dnl On all platforms, the ACL related API is declared in <sys/acl.h>.
22 AC_CHECK_HEADERS([sys/acl.h]) 28 AC_CHECK_HEADERS([sys/acl.h])
23 if test $ac_cv_header_sys_acl_h = yes; then 29 if test $ac_cv_header_sys_acl_h = yes; then
24 ac_save_LIBS=$LIBS 30 ac_save_LIBS=$LIBS
25 31
26 dnl Test for POSIX-draft-like API (Linux, FreeBSD, Mac OS X, IRIX, Tru64). 32 dnl Test for POSIX-draft-like API (GNU/Linux, FreeBSD, Mac OS X,
27 dnl -lacl is needed on Linux, -lpacl is needed on OSF/1. 33 dnl IRIX, Tru64). -lacl is needed on GNU/Linux, -lpacl on OSF/1.
28 if test $use_acl = 0; then 34 if test $use_acl = 0; then
29 AC_SEARCH_LIBS([acl_get_file], [acl pacl], 35 AC_SEARCH_LIBS([acl_get_file], [acl pacl],
30 [if test "$ac_cv_search_acl_get_file" != "none required"; then 36 [if test "$ac_cv_search_acl_get_file" != "none required"; then
@@ -40,7 +46,7 @@ AC_DEFUN([gl_FUNC_ACL],
40 # If the acl_get_file bug is detected, don't enable the ACL support. 46 # If the acl_get_file bug is detected, don't enable the ACL support.
41 gl_ACL_GET_FILE([use_acl=1], []) 47 gl_ACL_GET_FILE([use_acl=1], [])
42 if test $use_acl = 1; then 48 if test $use_acl = 1; then
43 dnl On Linux, additional API is declared in <acl/libacl.h>. 49 dnl On GNU/Linux, an additional API is declared in <acl/libacl.h>.
44 AC_CHECK_HEADERS([acl/libacl.h]) 50 AC_CHECK_HEADERS([acl/libacl.h])
45 AC_REPLACE_FUNCS([acl_entries]) 51 AC_REPLACE_FUNCS([acl_entries])
46 AC_CACHE_CHECK([for ACL_FIRST_ENTRY], 52 AC_CACHE_CHECK([for ACL_FIRST_ENTRY],
@@ -124,13 +130,15 @@ int type = ACL_TYPE_EXTENDED;]])],
124 130
125 LIBS=$ac_save_LIBS 131 LIBS=$ac_save_LIBS
126 fi 132 fi
127 if test "x$enable_acl$use_acl" = "xyes0"; then 133
134 if test "$enable_acl$use_acl" = yes0; then
128 AC_MSG_ERROR([ACLs enabled but support not detected]) 135 AC_MSG_ERROR([ACLs enabled but support not detected])
129 elif test "x$enable_acl$use_acl" = "xauto0"; then 136 elif test "$enable_acl$use_acl" = auto0; then
130 AC_MSG_WARN([libacl development library was not found or not usable.]) 137 AC_MSG_WARN([libacl development library was not found or not usable.])
131 AC_MSG_WARN([AC_PACKAGE_NAME will be built without ACL support.]) 138 AC_MSG_WARN([AC_PACKAGE_NAME will be built without ACL support.])
132 fi 139 fi
133 fi 140 fi
141 test $gl_need_lib_has_acl && LIB_HAS_ACL=$LIB_ACL
134 AC_SUBST([LIB_ACL]) 142 AC_SUBST([LIB_ACL])
135 AC_DEFINE_UNQUOTED([USE_ACL], [$use_acl], 143 AC_DEFINE_UNQUOTED([USE_ACL], [$use_acl],
136 [Define to nonzero if you want access control list support.]) 144 [Define to nonzero if you want access control list support.])
@@ -139,7 +147,7 @@ int type = ACL_TYPE_EXTENDED;]])],
139]) 147])
140 148
141# gl_ACL_GET_FILE(IF-WORKS, IF-NOT) 149# gl_ACL_GET_FILE(IF-WORKS, IF-NOT)
142# ------------------------------------- 150# ---------------------------------
143# If 'acl_get_file' works (does not have a particular bug), 151# If 'acl_get_file' works (does not have a particular bug),
144# run IF-WORKS, otherwise, IF-NOT. 152# run IF-WORKS, otherwise, IF-NOT.
145# When building natively, test for a Darwin 8.7.0 bug, whereby acl_get_file 153# When building natively, test for a Darwin 8.7.0 bug, whereby acl_get_file
@@ -166,3 +174,24 @@ AC_DEFUN([gl_ACL_GET_FILE],
166 fi])]) 174 fi])])
167 AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2]) 175 AS_IF([test "$gl_cv_func_working_acl_get_file" != no], [$1], [$2])
168]) 176])
177
178# On GNU/Linux, testing if a file has an acl can be done with the getxattr
179# syscall which doesn't require linking against additional libraries.
180AC_DEFUN([gl_FILE_HAS_ACL],
181[
182 AC_REQUIRE([gl_FUNC_ACL_ARG])
183 if test "$enable_acl" != no; then
184 AC_CHECK_HEADERS([linux/xattr.h],
185 [AC_CHECK_HEADERS([sys/xattr.h],
186 [AC_CHECK_FUNCS([getxattr])])])
187 fi
188 if test "$ac_cv_header_sys_xattr_h,$ac_cv_header_linux_xattr_h,$ac_cv_func_getxattr" = yes,yes,yes; then
189 LIB_HAS_ACL=
190 else
191 dnl Set gl_need_lib_has_acl to a nonempty value, so that any
192 dnl later gl_FUNC_ACL call will set LIB_HAS_ACL=$LIB_ACL.
193 gl_need_lib_has_acl=1
194 LIB_HAS_ACL=$LIB_ACL
195 fi
196 AC_SUBST([LIB_HAS_ACL])
197])
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index f32a4ddca5c..06636cfe76c 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -818,6 +818,7 @@ AC_DEFUN([gl_FILE_LIST], [
818 build-aux/snippet/warn-on-use.h 818 build-aux/snippet/warn-on-use.h
819 build-aux/update-copyright 819 build-aux/update-copyright
820 lib/acl-errno-valid.c 820 lib/acl-errno-valid.c
821 lib/acl-internal.c
821 lib/acl-internal.h 822 lib/acl-internal.h
822 lib/acl.h 823 lib/acl.h
823 lib/acl_entries.c 824 lib/acl_entries.c
@@ -856,7 +857,6 @@ AC_DEFUN([gl_FILE_LIST], [
856 lib/fcntl.in.h 857 lib/fcntl.in.h
857 lib/fdatasync.c 858 lib/fdatasync.c
858 lib/fdopendir.c 859 lib/fdopendir.c
859 lib/file-has-acl.c
860 lib/filemode.c 860 lib/filemode.c
861 lib/filemode.h 861 lib/filemode.h
862 lib/fpending.c 862 lib/fpending.c
diff --git a/m4/lstat.m4 b/m4/lstat.m4
index f6c7dd1ce44..adf752c0dfa 100644
--- a/m4/lstat.m4
+++ b/m4/lstat.m4
@@ -1,4 +1,4 @@
1# serial 26 1# serial 27
2 2
3# Copyright (C) 1997-2001, 2003-2015 Free Software Foundation, Inc. 3# Copyright (C) 1997-2001, 2003-2015 Free Software Foundation, Inc.
4# 4#
@@ -37,30 +37,28 @@ AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
37 [gl_cv_func_lstat_dereferences_slashed_symlink], 37 [gl_cv_func_lstat_dereferences_slashed_symlink],
38 [rm -f conftest.sym conftest.file 38 [rm -f conftest.sym conftest.file
39 echo >conftest.file 39 echo >conftest.file
40 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then 40 AC_RUN_IFELSE(
41 AC_RUN_IFELSE( 41 [AC_LANG_PROGRAM(
42 [AC_LANG_PROGRAM( 42 [AC_INCLUDES_DEFAULT],
43 [AC_INCLUDES_DEFAULT], 43 [[struct stat sbuf;
44 [[struct stat sbuf; 44 if (symlink ("conftest.file", "conftest.sym") != 0)
45 /* Linux will dereference the symlink and fail, as required by 45 return 1;
46 POSIX. That is better in the sense that it means we will not 46 /* Linux will dereference the symlink and fail, as required by
47 have to compile and use the lstat wrapper. */ 47 POSIX. That is better in the sense that it means we will not
48 return lstat ("conftest.sym/", &sbuf) == 0; 48 have to compile and use the lstat wrapper. */
49 ]])], 49 return lstat ("conftest.sym/", &sbuf) == 0;
50 [gl_cv_func_lstat_dereferences_slashed_symlink=yes], 50 ]])],
51 [gl_cv_func_lstat_dereferences_slashed_symlink=no], 51 [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
52 [case "$host_os" in 52 [gl_cv_func_lstat_dereferences_slashed_symlink=no],
53 # Guess yes on glibc systems. 53 [case "$host_os" in
54 *-gnu*) gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;; 54 *-gnu*)
55 # If we don't know, assume the worst. 55 # Guess yes on glibc systems.
56 *) gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;; 56 gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
57 esac 57 *)
58 ]) 58 # If we don't know, assume the worst.
59 else 59 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
60 # If the 'ln -s' command failed, then we probably don't even 60 esac
61 # have an lstat function. 61 ])
62 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no"
63 fi
64 rm -f conftest.sym conftest.file 62 rm -f conftest.sym conftest.file
65 ]) 63 ])
66 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in 64 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
diff --git a/m4/manywarnings.m4 b/m4/manywarnings.m4
index 44da98e38da..b4e38d94463 100644
--- a/m4/manywarnings.m4
+++ b/m4/manywarnings.m4
@@ -108,12 +108,13 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
108 -Waddress \ 108 -Waddress \
109 -Waggressive-loop-optimizations \ 109 -Waggressive-loop-optimizations \
110 -Wall \ 110 -Wall \
111 -Warray-bounds \
112 -Wattributes \ 111 -Wattributes \
113 -Wbad-function-cast \ 112 -Wbad-function-cast \
113 -Wbool-compare \
114 -Wbuiltin-macro-redefined \ 114 -Wbuiltin-macro-redefined \
115 -Wcast-align \ 115 -Wcast-align \
116 -Wchar-subscripts \ 116 -Wchar-subscripts \
117 -Wchkp \
117 -Wclobbered \ 118 -Wclobbered \
118 -Wcomment \ 119 -Wcomment \
119 -Wcomments \ 120 -Wcomments \
@@ -122,7 +123,10 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
122 -Wdate-time \ 123 -Wdate-time \
123 -Wdeprecated \ 124 -Wdeprecated \
124 -Wdeprecated-declarations \ 125 -Wdeprecated-declarations \
126 -Wdesignated-init \
125 -Wdisabled-optimization \ 127 -Wdisabled-optimization \
128 -Wdiscarded-array-qualifiers \
129 -Wdiscarded-qualifiers \
126 -Wdiv-by-zero \ 130 -Wdiv-by-zero \
127 -Wdouble-promotion \ 131 -Wdouble-promotion \
128 -Wempty-body \ 132 -Wempty-body \
@@ -133,6 +137,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
133 -Wformat-extra-args \ 137 -Wformat-extra-args \
134 -Wformat-nonliteral \ 138 -Wformat-nonliteral \
135 -Wformat-security \ 139 -Wformat-security \
140 -Wformat-signedness \
136 -Wformat-y2k \ 141 -Wformat-y2k \
137 -Wformat-zero-length \ 142 -Wformat-zero-length \
138 -Wfree-nonheap-object \ 143 -Wfree-nonheap-object \
@@ -140,15 +145,19 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
140 -Wimplicit \ 145 -Wimplicit \
141 -Wimplicit-function-declaration \ 146 -Wimplicit-function-declaration \
142 -Wimplicit-int \ 147 -Wimplicit-int \
148 -Wincompatible-pointer-types \
143 -Winit-self \ 149 -Winit-self \
144 -Winline \ 150 -Winline \
151 -Wint-conversion \
145 -Wint-to-pointer-cast \ 152 -Wint-to-pointer-cast \
146 -Winvalid-memory-model \ 153 -Winvalid-memory-model \
147 -Winvalid-pch \ 154 -Winvalid-pch \
148 -Wjump-misses-init \ 155 -Wjump-misses-init \
156 -Wlogical-not-parentheses \
149 -Wlogical-op \ 157 -Wlogical-op \
150 -Wmain \ 158 -Wmain \
151 -Wmaybe-uninitialized \ 159 -Wmaybe-uninitialized \
160 -Wmemset-transposed-args \
152 -Wmissing-braces \ 161 -Wmissing-braces \
153 -Wmissing-declarations \ 162 -Wmissing-declarations \
154 -Wmissing-field-initializers \ 163 -Wmissing-field-initializers \
@@ -159,6 +168,7 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
159 -Wnarrowing \ 168 -Wnarrowing \
160 -Wnested-externs \ 169 -Wnested-externs \
161 -Wnonnull \ 170 -Wnonnull \
171 -Wodr \
162 -Wold-style-declaration \ 172 -Wold-style-declaration \
163 -Wold-style-definition \ 173 -Wold-style-definition \
164 -Wopenmp-simd \ 174 -Wopenmp-simd \
@@ -176,6 +186,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
176 -Wreturn-type \ 186 -Wreturn-type \
177 -Wsequence-point \ 187 -Wsequence-point \
178 -Wshadow \ 188 -Wshadow \
189 -Wshift-count-negative \
190 -Wshift-count-overflow \
191 -Wsizeof-array-argument \
179 -Wsizeof-pointer-memaccess \ 192 -Wsizeof-pointer-memaccess \
180 -Wstack-protector \ 193 -Wstack-protector \
181 -Wstrict-aliasing \ 194 -Wstrict-aliasing \
@@ -185,7 +198,10 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
185 -Wsuggest-attribute=format \ 198 -Wsuggest-attribute=format \
186 -Wsuggest-attribute=noreturn \ 199 -Wsuggest-attribute=noreturn \
187 -Wsuggest-attribute=pure \ 200 -Wsuggest-attribute=pure \
201 -Wsuggest-final-methods \
202 -Wsuggest-final-types \
188 -Wswitch \ 203 -Wswitch \
204 -Wswitch-bool \
189 -Wswitch-default \ 205 -Wswitch-default \
190 -Wsync-nand \ 206 -Wsync-nand \
191 -Wsystem-headers \ 207 -Wsystem-headers \
@@ -217,8 +233,9 @@ AC_DEFUN([gl_MANYWARN_ALL_GCC],
217 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item" 233 gl_manywarn_set="$gl_manywarn_set $gl_manywarn_item"
218 done 234 done
219 235
220 # gcc --help=warnings outputs an unusual form for this option; list 236 # gcc --help=warnings outputs an unusual form for these options; list
221 # it here so that the above 'comm' command doesn't report a false match. 237 # them here so that the above 'comm' command doesn't report a false match.
238 gl_manywarn_set="$gl_manywarn_set -Warray-bounds=2"
222 gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc" 239 gl_manywarn_set="$gl_manywarn_set -Wnormalized=nfc"
223 240
224 # These are needed for older GCC versions. 241 # These are needed for older GCC versions.