summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-06-01 13:29:38 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-06-02 02:13:49 +0200
commitc290cdb9349220ba70b54143e1432da0230e2cee (patch)
tree4ebf0aa557376557eaec362eaa14f587c53ea1ec /lib
parent664af060ac9ea83b565fbb817bb63d67d83843ef (diff)
downloadsamba-c290cdb9349220ba70b54143e1432da0230e2cee.tar.gz
samba-c290cdb9349220ba70b54143e1432da0230e2cee.tar.bz2
samba-c290cdb9349220ba70b54143e1432da0230e2cee.zip
lib/replace: xattr wrappers in lib/replace rather than source3/lib/system.c
This also moves all the still-used configure tests etc. The unused OSF API is also removed at this time. Andrew Bartlett
Diffstat (limited to 'lib')
-rw-r--r--lib/replace/libreplace.m447
-rw-r--r--lib/replace/replace.h40
-rw-r--r--lib/replace/system/filesys.h56
-rw-r--r--lib/replace/wscript30
4 files changed, 172 insertions, 1 deletions
diff --git a/lib/replace/libreplace.m4 b/lib/replace/libreplace.m4
index 7335c98a59..8176a000b3 100644
--- a/lib/replace/libreplace.m4
+++ b/lib/replace/libreplace.m4
@@ -144,6 +144,53 @@ AC_CHECK_FUNCS(clock_gettime,libreplace_cv_have_clock_gettime=yes,[
libreplace_cv_have_clock_gettime=yes
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, Define to 1 if there is support for clock_gettime)])
])
+
+AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h)
+AC_CHECK_HEADERS(sys/ea.h sys/proplist.h)
+
+############################################
+# Check for EA implementations
+case "$host_os" in
+ *freebsd4* | *dragonfly* )
+ AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
+ ;;
+ *)
+ AC_SEARCH_LIBS(getxattr, [attr])
+ AC_CHECK_FUNCS(attr_get attr_getf attr_list attr_listf attropen attr_remove)
+ AC_CHECK_FUNCS(attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file)
+ AC_CHECK_FUNCS(extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file)
+ AC_CHECK_FUNCS(extattr_set_fd extattr_set_file fgetea fgetxattr flistea flistxattr)
+ AC_CHECK_FUNCS(fremoveea fremovexattr fsetea fsetxattr getea getxattr listea)
+ AC_CHECK_FUNCS(listxattr removeea removexattr setea setxattr)
+
+ ;;
+esac
+
+
+########################################################
+# Do xattr functions take additional options like on Darwin?
+if test x"$ac_cv_func_getxattr" = x"yes" ; then
+ AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
+ old_LIBS=$LIBS
+ LIBS="$LIBS $ACL_LIBS"
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #if HAVE_ATTR_XATTR_H
+ #include <attr/xattr.h>
+ #elif HAVE_SYS_XATTR_H
+ #include <sys/xattr.h>
+ #endif
+ ],[
+ getxattr(0, 0, 0, 0, 0, 0);
+ ],
+ [smb_attr_cv_xattr_add_opt=yes],
+ [smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
+ ])
+ if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
+ AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
+ fi
+fi
+
AC_CHECK_FUNCS(get_current_dir_name)
AC_HAVE_DECL(setresuid, [#include <unistd.h>])
AC_HAVE_DECL(setresgid, [#include <unistd.h>])
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 776da8aa4a..fe3ef3dcfd 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -543,6 +543,46 @@ ssize_t rep_pwrite(int __fd, const void *__buf, size_t __nbytes, off_t __offset)
/* prototype is in "system/network.h" */
#endif
+#if !defined(HAVE_GETXATTR) || defined(XATTR_ADD_OPT)
+#define getxattr rep_getxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_FGETXATTR) || defined(XATTR_ADD_OPT)
+#define fgetxattr rep_fgetxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_LISTXATTR) || defined(XATTR_ADD_OPT)
+#define listxattr rep_listxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADD_OPT)
+#define flistxattr rep_flistxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADD_OPT)
+#define removexattr rep_removexattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADD_OPT)
+#define fremovexattr rep_fremovexattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_SETXATTR) || defined(XATTR_ADD_OPT)
+#define setxattr rep_setxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
+#if !defined(HAVE_FSETXATTR) || defined(XATTR_ADD_OPT)
+#define fsetxattr rep_fsetxattr
+/* prototype is in "system/filesys.h" */
+#endif
+
#ifndef HAVE_GET_CURRENT_DIR_NAME
#define get_current_dir_name rep_get_current_dir_name
char *rep_get_current_dir_name(void);
diff --git a/lib/replace/system/filesys.h b/lib/replace/system/filesys.h
index 2393068b4f..cf8b36b53f 100644
--- a/lib/replace/system/filesys.h
+++ b/lib/replace/system/filesys.h
@@ -123,11 +123,26 @@
#include <sys/xattr.h>
#endif
+#ifdef HAVE_SYS_EA_H
+#include <sys/ea.h>
+#endif
+
+#ifdef HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
+#ifndef XATTR_CREATE
+#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
+#endif
+
+#ifndef XATTR_REPLACE
+#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
+#endif
+
/* Some POSIX definitions for those without */
#ifndef S_IFDIR
@@ -208,4 +223,45 @@
#define ENOATTR ENODATA
#endif
+
+#if !defined(HAVE_GETXATTR) || defined(XATTR_ADD_OPT)
+ssize_t rep_getxattr (const char *path, const char *name, void *value, size_t size);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FGETXATTR) || defined(XATTR_ADD_OPT)
+ssize_t rep_fgetxattr (int filedes, const char *name, void *value, size_t size);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_LISTXATTR) || defined(XATTR_ADD_OPT)
+ssize_t rep_listxattr (const char *path, char *list, size_t size);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FLISTXATTR) || defined(XATTR_ADD_OPT)
+ssize_t rep_flistxattr (int filedes, char *list, size_t size);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_REMOVEXATTR) || defined(XATTR_ADD_OPT)
+int rep_removexattr (const char *path, const char *name);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FREMOVEXATTR) || defined(XATTR_ADD_OPT)
+int rep_fremovexattr (int filedes, const char *name);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_SETXATTR) || defined(XATTR_ADD_OPT)
+int rep_setxattr (const char *path, const char *name, const void *value, size_t size, int flags);
+/* define is in "replace.h" */
+#endif
+
+#if !defined(HAVE_FSETXATTR) || defined(XATTR_ADD_OPT)
+int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags);
+/* define is in "replace.h" */
+#endif
+
#endif
diff --git a/lib/replace/wscript b/lib/replace/wscript
index d7b0634f3f..fc0cb00ae2 100644
--- a/lib/replace/wscript
+++ b/lib/replace/wscript
@@ -211,6 +211,32 @@ def configure(conf):
conf.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
conf.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
+ conf.SET_TARGET_TYPE('attr', 'EMPTY')
+
+ conf.CHECK_FUNCS_IN('''
+fgetxattr flistea flistxattr
+fremovexattr fsetxattr getxattr
+listxattr removexattr setxattr
+''', 'attr', checklibc=True)
+
+ # We need to check for linux xattrs first, as we do not wish to link to -lattr
+ # (the XFS compat API) on Linux systems with the native xattr API
+ if not conf.CONFIG_SET('HAVE_GETXATTR'):
+ conf.CHECK_FUNCS_IN('''
+attr_get attr_getf attr_list attr_listf attropen attr_remove
+attr_removef attr_set attr_setf extattr_delete_fd extattr_delete_file
+extattr_get_fd extattr_get_file extattr_list_fd extattr_list_file
+extattr_set_fd extattr_set_file fgetea flistea
+fremoveea fsetea getea listea
+removeea setea
+''', 'attr', checklibc=True)
+
+ # Darwin has extra options to xattr-family functions
+ conf.CHECK_CODE('getxattr(0, 0, 0, 0, 0, 0);',
+ 'XATTR_ADD_OPT',
+ msg="Checking whether xattr interface takes additional options",
+ headers='sys/types.h attr/xattr.h sys/xattr.h')
+
conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
checklibc=True, headers='dlfcn.h dl.h')
@@ -474,6 +500,8 @@ def build(bld):
if not bld.CONFIG_SET('HAVE_INET_ATON'): REPLACE_SOURCE += ' inet_aton.c'
if not bld.CONFIG_SET('HAVE_INET_NTOP'): REPLACE_SOURCE += ' inet_ntop.c'
if not bld.CONFIG_SET('HAVE_INET_PTON'): REPLACE_SOURCE += ' inet_pton.c'
+ if not bld.CONFIG_SET('HAVE_GETXATTR') or bld.CONFIG_SET('XATTR_ADD_OPT'):
+ REPLACE_SOURCE += ' xattr.c'
bld.SAMBA_LIBRARY('replace',
source=REPLACE_SOURCE,
@@ -484,7 +512,7 @@ def build(bld):
# at the moment:
# hide_symbols=bld.BUILTIN_LIBRARY('replace'),
private_library=True,
- deps='crypt dl nsl socket rt' + extra_libs)
+ deps='crypt dl nsl socket rt attr' + extra_libs)
bld.SAMBA_SUBSYSTEM('replace-test',
source='''test/testsuite.c test/strptime.c