···11+>From 7d1d3d38cb66b02c062de77847e3c0ecd842366c Mon Sep 17 00:00:00 2001
22+From: Pavel Raiskup <address@hidden>
33+Date: Mon, 4 Aug 2014 13:19:49 +0200
44+Subject: [PATCH] xattrs: fix bug in configure
55+66+Be careful to define HAVE_XATTRS when not all needed xattr-related
77+functions are properly defined either in libc or libattr.
88+99+Reported independently by Denis Excoffier and Dominyk Tille.
1010+1111+* acinclude.m4 (TAR_HEADERS_ATTR_XATTR_H): Check for each xattr
1212+function separately. Don't AC_CHECK_LIB (LIBS is filled by
1313+AC_SEARCH_LIBS when necessary).
1414+* lib/xattr-at.c: Do not build when HAVE_XATTRS is not defined.
1515+* src/Makefile.am: The LDADD -lattr was redundant.
1616+---
1717+ acinclude.m4 | 42 ++++++++++++++----------------------------
1818+ lib/xattr-at.c | 7 +++++++
1919+ src/Makefile.am | 4 ----
2020+ 3 files changed, 21 insertions(+), 32 deletions(-)
2121+2222+diff --git a/acinclude.m4 b/acinclude.m4
2323+index 3b28b3b..db0bbc7 100644
2424+--- a/acinclude.m4
2525++++ b/acinclude.m4
2626+@@ -40,37 +40,23 @@ AC_DEFUN([TAR_HEADERS_ATTR_XATTR_H],
2727+ # First check for <sys/xattr.h>
2828+ AC_CHECK_HEADERS([sys/xattr.h])
2929+ AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_sys_xattr_h" = yes])
3030+- AM_CONDITIONAL([TAR_LIB_ATTR],[false])
3131+- if test "$ac_cv_header_sys_xattr_h" = yes; then
3232+- AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \
3333+- setxattr fsetxattr lsetxattr \
3434+- listxattr flistxattr llistxattr,
3535+- # only when functions are present
3636+- AC_DEFINE([HAVE_SYS_XATTR_H], [1],
3737+- [define to 1 if we have <sys/xattr.h> header])
3838+- if test "$with_xattrs" != no; then
3939+- AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.])
4040+- fi
4141+- )
4242+- fi
4343+-
4444+- # If <sys/xattr.h> is not found, then check for <attr/xattr.h>
4545+ if test "$ac_cv_header_sys_xattr_h" != yes; then
4646+ AC_CHECK_HEADERS([attr/xattr.h])
4747+ AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_attr_xattr_h" = yes])
4848+- AC_CHECK_LIB([attr],[fgetxattr])
4949+- AM_CONDITIONAL([TAR_LIB_ATTR],[test "$ac_cv_lib_attr_fgetxattr" = yes])
5050+- if test "$ac_cv_header_attr_xattr_h" = yes; then
5151+- AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \
5252+- setxattr fsetxattr lsetxattr \
5353+- listxattr flistxattr llistxattr,
5454+- # only when functions are present
5555+- AC_DEFINE([HAVE_ATTR_XATTR_H], [1],
5656+- [define to 1 if we have <attr/xattr.h> header])
5757+- if test "$with_xattrs" != no; then
5858+- AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.])
5959+- fi
6060+- )
6161++ fi
6262++
6363++ if test "$with_xattrs" != no; then
6464++ for i in getxattr fgetxattr lgetxattr \
6565++ setxattr fsetxattr lsetxattr \
6666++ listxattr flistxattr llistxattr
6767++ do
6868++ AC_SEARCH_LIBS($i, attr)
6969++ eval found=\$ac_cv_search_$i
7070++ test "$found" = "no" && break
7171++ done
7272++
7373++ if test "$found" != no; then
7474++ AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.])
7575+ fi
7676+ fi
7777+ ])
7878+diff --git a/lib/xattr-at.c b/lib/xattr-at.c
7979+index 443ccae..009bde5 100644
8080+--- a/lib/xattr-at.c
8181++++ b/lib/xattr-at.c
8282+@@ -18,6 +18,11 @@
8383+8484+ #include <config.h>
8585+8686++/* Temporarily don't build. We are unable to build on (probably not only)
8787++ darwin due to lack of l*xattr callbacks (XATTR_NOFOLLOW is alternative) and
8888++ different function definitions. */
8989++#ifdef HAVE_XATTRS
9090++
9191+ #include "xattr-at.h"
9292+ #include "openat.h"
9393+9494+@@ -108,3 +113,5 @@
9595+ #undef AT_FUNC_RESULT
9696+ #undef AT_FUNC_POST_FILE_PARAM_DECLS
9797+ #undef AT_FUNC_POST_FILE_ARGS
9898++
9999++#endif
100100+diff --git a/src/Makefile.am b/src/Makefile.am
101101+index 82b2d46..42daaef 100644
102102+--- a/src/Makefile.am
103103++++ b/src/Makefile.am
104104+@@ -52,7 +52,3 @@ AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
105105+ LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV)
106106+107107+ tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) $(LIB_SELINUX)
108108+-
109109+-if TAR_LIB_ATTR
110110+-tar_LDADD += -lattr
111111+-endif
112112+--
113113+1.9.3
114114+