>From 7d1d3d38cb66b02c062de77847e3c0ecd842366c Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <address@hidden>
Date: Mon, 4 Aug 2014 13:19:49 +0200
Subject: [PATCH] xattrs: fix bug in configure
Be careful to define HAVE_XATTRS when not all needed xattr-related
functions are properly defined either in libc or libattr.
Reported independently by Denis Excoffier and Dominyk Tille.
* acinclude.m4 (TAR_HEADERS_ATTR_XATTR_H): Check for each xattr
function separately. Don't AC_CHECK_LIB (LIBS is filled by
AC_SEARCH_LIBS when necessary).
* lib/xattr-at.c: Do not build when HAVE_XATTRS is not defined.
* src/Makefile.am: The LDADD -lattr was redundant.
---
acinclude.m4 | 42 ++++++++++++++----------------------------
lib/xattr-at.c | 7 +++++++
src/Makefile.am | 4 ----
3 files changed, 21 insertions(+), 32 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index 3b28b3b..db0bbc7 100644
a
|
b
|
AC_DEFUN([TAR_HEADERS_ATTR_XATTR_H], |
40 | 40 | # First check for <sys/xattr.h> |
41 | 41 | AC_CHECK_HEADERS([sys/xattr.h]) |
42 | 42 | AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_sys_xattr_h" = yes]) |
43 | | AM_CONDITIONAL([TAR_LIB_ATTR],[false]) |
44 | | if test "$ac_cv_header_sys_xattr_h" = yes; then |
45 | | AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ |
46 | | setxattr fsetxattr lsetxattr \ |
47 | | listxattr flistxattr llistxattr, |
48 | | # only when functions are present |
49 | | AC_DEFINE([HAVE_SYS_XATTR_H], [1], |
50 | | [define to 1 if we have <sys/xattr.h> header]) |
51 | | if test "$with_xattrs" != no; then |
52 | | AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) |
53 | | fi |
54 | | ) |
55 | | fi |
56 | | |
57 | | # If <sys/xattr.h> is not found, then check for <attr/xattr.h> |
58 | 43 | if test "$ac_cv_header_sys_xattr_h" != yes; then |
59 | 44 | AC_CHECK_HEADERS([attr/xattr.h]) |
60 | 45 | AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_attr_xattr_h" = yes]) |
61 | | AC_CHECK_LIB([attr],[fgetxattr]) |
62 | | AM_CONDITIONAL([TAR_LIB_ATTR],[test "$ac_cv_lib_attr_fgetxattr" = yes]) |
63 | | if test "$ac_cv_header_attr_xattr_h" = yes; then |
64 | | AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ |
65 | | setxattr fsetxattr lsetxattr \ |
66 | | listxattr flistxattr llistxattr, |
67 | | # only when functions are present |
68 | | AC_DEFINE([HAVE_ATTR_XATTR_H], [1], |
69 | | [define to 1 if we have <attr/xattr.h> header]) |
70 | | if test "$with_xattrs" != no; then |
71 | | AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) |
72 | | fi |
73 | | ) |
| 46 | fi |
| 47 | |
| 48 | if test "$with_xattrs" != no; then |
| 49 | for i in getxattr fgetxattr lgetxattr \ |
| 50 | setxattr fsetxattr lsetxattr \ |
| 51 | listxattr flistxattr llistxattr |
| 52 | do |
| 53 | AC_SEARCH_LIBS($i, attr) |
| 54 | eval found=\$ac_cv_search_$i |
| 55 | test "$found" = "no" && break |
| 56 | done |
| 57 | |
| 58 | if test "$found" != no; then |
| 59 | AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.]) |
74 | 60 | fi |
75 | 61 | fi |
76 | 62 | ]) |
diff --git a/lib/xattr-at.c b/lib/xattr-at.c
index 443ccae..009bde5 100644
a
|
b
|
|
18 | 18 | |
19 | 19 | #include <config.h> |
20 | 20 | |
| 21 | /* Temporarily don't build. We are unable to build on (probably not only) |
| 22 | darwin due to lack of l*xattr callbacks (XATTR_NOFOLLOW is alternative) and |
| 23 | different function definitions. */ |
| 24 | #ifdef HAVE_XATTRS |
| 25 | |
21 | 26 | #include "xattr-at.h" |
22 | 27 | #include "openat.h" |
23 | 28 | |
… |
… |
|
108 | 113 | #undef AT_FUNC_RESULT |
109 | 114 | #undef AT_FUNC_POST_FILE_PARAM_DECLS |
110 | 115 | #undef AT_FUNC_POST_FILE_ARGS |
| 116 | |
| 117 | #endif |
diff --git a/src/Makefile.am b/src/Makefile.am
index 82b2d46..42daaef 100644
a
|
b
|
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS) |
52 | 52 | LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV) |
53 | 53 | |
54 | 54 | tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) $(LIB_SELINUX) |
55 | | |
56 | | if TAR_LIB_ATTR |
57 | | tar_LDADD += -lattr |
58 | | endif |