dev-libs/apr: add privsep patch & Multilib Patch

(Portage version: 2.2.0_alpha75-r1/git/Linux x86_64, RepoMan options: --force, unsigned Manifest commit)
This commit is contained in:
Mario Fetka 2011-11-21 20:16:43 +01:00
parent ee1fbc6130
commit 31ea2d3abf
11 changed files with 2638 additions and 0 deletions

13
dev-libs/apr/ChangeLog Normal file
View File

@ -0,0 +1,13 @@
# ChangeLog for dev-libs/apr
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
*apr-1.4.5 (21 Nov 2011)
21 Nov 2011; Mario Fetka <mario.fetka@gmail.com> +apr-1.4.5.ebuild,
+files/apr-1.4.x-apr_common-m4.patch, +files/apr-1.4.5-xattr-build-1.patch,
+files/apr-xattr-build.patch, +files/apr-xattr-headers.patch,
+files/apr-xattr-impl.patch, +files/apr-xattr-tests.patch,
+files/config.layout.patch, +metadata.xml:
add privsep patch & Multilib Patch

11
dev-libs/apr/Manifest Normal file
View File

@ -0,0 +1,11 @@
AUX apr-1.4.5-xattr-build-1.patch 5932 RMD160 c9c33e9f9c13e21a05131c52865f91603e6d6791 SHA1 856d0333c7295c0ff5d80fe3967d678294fb6e7a SHA256 f1d4cfe011c0e0e507f5bda965f78cbe2884249b06f231d8c7b7252be49ab0ff
AUX apr-1.4.x-apr_common-m4.patch 844 RMD160 2e27c63fde2c014379b1a57e84c497d3c00a7acb SHA1 fd9911cfcc18428cc65cd519768372df8268082a SHA256 cc7f7d91bd81753ae77e5807588d205eb7ae647f3ed05e4ce7e5bf9edc0dfa6d
AUX apr-xattr-build.patch 5530 RMD160 f1846815ee32366e51ef7b765f7cb8d1f10642ed SHA1 f61d3f8618e8faf7426125be4147542f2db11787 SHA256 ccda7d84d0a4c95507e82bcbf157dca91e420e7825c80cbd60894d2b047b2b1d
AUX apr-xattr-headers.patch 13791 RMD160 b6a71fcdea238bf8bc10cc43b5d346a6c54f11ae SHA1 431051e2bcc23776786453e329bbfd467fc8da4b SHA256 0d7068d1738dd2bedd8fffe7e95f0089e70b9730a81d35b2688c50e506f718ee
AUX apr-xattr-impl.patch 38289 RMD160 41c2de08ff8ab4e94222ee49679da3a9ae0b78a9 SHA1 143c7054f040acd55ca3bedc9fac410f6ed37204 SHA256 3998baaad273f88bf3d82cf6522d7da88a5d03ffbc75bd5c781e1142b010fa13
AUX apr-xattr-tests.patch 17458 RMD160 b314abc82368a9a69e35082d8117c7361866699a SHA1 ca51974638a1b7cd0e3c1e957dd792c26587a4cb SHA256 14b0b7750c795734a1e71688e084c08e8af6db83acab0f8b135f08cfa92c080e
AUX config.layout.patch 818 RMD160 dada232c8b85e6c3c62fbc6caa1d05f36164dc27 SHA1 3822a0ec508165dd189e1b750bdf4e7778b6c21e SHA256 eeacaf654f23084e842bff02b97c083a8da5b5c056fd086166ba2d250edf3181
DIST apr-1.4.5.tar.bz2 754763 RMD160 d2a966c1b143416cd3655cf849cb5d3cb1ca2c5f SHA1 517de5e3cc1e3be810d9bc95508ab66bb8ebe7cb SHA256 38c61cacb39be649411cdab212979c71ce29495549c249c2e9a1b0d12480c93e
EBUILD apr-1.4.5.ebuild 2369 RMD160 8c916a247bbcb575ea7c82e4c9234a976847aa1e SHA1 c63b2cdfb4b7f0b551c86add38f88aa0da510c08 SHA256 f9da2d933aa22f791dddc4760b500c53e25b6732d4e776efb2437f681e42a621
MISC ChangeLog 495 RMD160 2e037d1d581df1836b2192687df15bc63c7968fb SHA1 823623e6b05563ef89e3c8605e8196c282562f47 SHA256 fa0aab5930faea0e8d567ce5e9981d593240dfdd5734fe603ad2ab6bd192bd08
MISC metadata.xml 453 RMD160 44be42dfd9fe4c26f5655b4a8b78446ae1c073e7 SHA1 d7378602457f126b8448744b2f965853b4a17188 SHA256 c089c114bb8c838899abeb5c1f1c19a495039b30e106363c14e5de83b7e9a1f4

View File

@ -0,0 +1,97 @@
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-libs/apr/apr-1.4.5.ebuild,v 1.8 2011/11/11 19:17:50 hwoarang Exp $
EAPI="4"
inherit autotools eutils libtool multilib
DESCRIPTION="Apache Portable Runtime Library"
HOMEPAGE="http://apr.apache.org/"
SRC_URI="mirror://apache/apr/${P}.tar.bz2"
LICENSE="Apache-2.0"
SLOT="1"
KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
IUSE="doc elibc_FreeBSD older-kernels-compatibility static-libs +urandom +uuid"
RESTRICT="test"
RDEPEND="uuid? ( !elibc_FreeBSD? ( >=sys-apps/util-linux-2.16 ) )"
DEPEND="${RDEPEND}
doc? ( app-doc/doxygen )"
DOCS=(CHANGES NOTICE README)
src_prepare() {
epatch "${FILESDIR}/apr-1.4.x-apr_common-m4.patch"
epatch "${FILESDIR}/apr-1.4.5-xattr-build-1.patch"
epatch "${FILESDIR}/apr-xattr-headers.patch"
epatch "${FILESDIR}/apr-xattr-impl.patch"
epatch "${FILESDIR}/apr-xattr-tests.patch"
# Ensure that system libtool is used.
sed -e 's:${installbuilddir}/libtool:/usr/bin/libtool:' -i apr-config.in || die "sed failed"
sed -e 's:@LIBTOOL@:$(SHELL) /usr/bin/libtool:' -i build/apr_rules.mk.in || die "sed failed"
AT_M4DIR="build" eautoreconf
elibtoolize
epatch "${FILESDIR}/config.layout.patch"
}
src_configure() {
local myconf
if use older-kernels-compatibility; then
local apr_cv_accept4 apr_cv_dup3 apr_cv_epoll_create1 apr_cv_sock_cloexec
export apr_cv_accept4="no"
export apr_cv_dup3="no"
export apr_cv_epoll_create1="no"
export apr_cv_sock_cloexec="no"
fi
if use urandom; then
myconf+=" --with-devrandom=/dev/urandom"
else
myconf+=" --with-devrandom=/dev/random"
fi
if ! use uuid; then
local apr_cv_osuuid
export apr_cv_osuuid="no"
fi
CONFIG_SHELL="/bin/bash" econf \
--enable-layout=gentoo \
--enable-nonportable-atomics \
--enable-threads \
${myconf}
rm -f libtool
}
src_compile() {
emake
if use doc; then
emake dox
fi
}
src_install() {
default
find "${ED}" -name "*.la" -exec rm -f {} +
if use doc; then
dohtml -r docs/dox/html/*
fi
if ! use static-libs; then
find "${ED}" -name "*.a" -exec rm -f {} +
fi
# This file is only used on AIX systems, which Gentoo is not,
# and causes collisions between the SLOTs, so remove it.
rm -f "${ED}usr/$(get_libdir)/apr.exp"
}

View File

@ -0,0 +1,159 @@
Submitted By: Mario Fetka (mario dot fetka at gmail dot com)
Date: 2011-11-21
Initial Package Version: 1.4.5
Origin: http://privsep.org/patches/2.3.0-dev/xattr-patches/apr-xattr-build.patch
Upstream Status: unknown
Description: build infrastructure
diff -Naur apr-1.4.5.orig/build.conf apr-1.4.5/build.conf
--- apr-1.4.5.orig/build.conf 2011-11-21 18:38:28.659217726 +0000
+++ apr-1.4.5/build.conf 2011-11-21 18:39:17.735760998 +0000
@@ -13,7 +13,7 @@
# directories that have platform-specific code in them. the resulting
# pattern will be: SUBDIR/PLATFORM/*.c
platform_dirs =
- dso file_io locks memory misc mmap network_io poll random
+ dso file_io locks memory misc mmap network_io poll random xattr
shmem support threadproc time user atomic
# all the public headers
diff -Naur apr-1.4.5.orig/configure.in apr-1.4.5/configure.in
--- apr-1.4.5.orig/configure.in 2011-11-21 18:38:28.985607639 +0000
+++ apr-1.4.5/configure.in 2011-11-21 18:43:25.981912296 +0000
@@ -197,7 +197,7 @@
DEFAULT_OSDIR="unix"
echo "(Default will be ${DEFAULT_OSDIR})"
-apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random"
+apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random xattr"
dnl Checks for programs.
AC_PROG_MAKE_SET
@@ -1466,7 +1466,9 @@
sys/types.h \
sys/uio.h \
sys/un.h \
- sys/wait.h)
+ sys/wait.h \
+ sys/xattr.h \
+ sys/extattr.h)
# IRIX 6.5 has a problem in <netinet/tcp.h> which prevents it from
# being included by itself. Check for <netinet/tcp.h> manually,
@@ -1518,6 +1520,8 @@
AC_SUBST(unistdh)
AC_SUBST(signalh)
AC_SUBST(sys_waith)
+AC_SUBST(sys_xattrh)
+AC_SUBST(sys_extattrh)
AC_SUBST(processh)
AC_SUBST(pthreadh)
AC_SUBST(semaphoreh)
@@ -2472,6 +2476,87 @@
APR_CHECK_DIRENT_INODE
APR_CHECK_DIRENT_TYPE
+dnl ----------------------------- Checking for Extended Attributes Support
+echo "${nl}Checking for Extended Attributes Support..."
+
+# Check whether Extended Attributes have explicitly been disabled
+AC_ARG_ENABLE(xattr,
+ [ --disable-xattr Disable Extended Attributes support in APR.],
+ [ if test "$enableval" = "no"; then
+ user_disabled_xattr=1
+ fi ],
+ [ user_disabled_xattr=0 ] )
+
+xattrdarwin="0"
+xattrlinux="0"
+xattrfreebsd="0"
+xattrsolaris="0"
+if test "$user_disabled_xattr" = 1; then
+ echo "no -- disabled by user"
+else
+ AC_CHECK_FUNCS([fgetxattr fsetxattr flistxattr fremovexattr lgetxattr \
+ extattr_get_fd extattr_set_fd extattr_list_fd \
+ extattr_delete_fd openat unlinkat])
+ APR_CHECK_DEFINE(O_XATTR, sys/fcntl.h)
+ APR_CHECK_DEFINE(XATTR_NOFOLLOW, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_CREATE, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_REPLACE, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_NAME_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_SIZE_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_LIST_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_MAXNAMELEN, sys/xattr.h)
+ APR_CHECK_DEFINE(EXTATTR_NAMESPACE_USER, sys/extattr.h)
+ APR_CHECK_DEFINE(EXTATTR_NAMESPACE_SYSTEM, sys/extattr.h)
+ APR_CHECK_DEFINE(EXTATTR_MAXNAMELEN, sys/extattr.h)
+
+ APR_BEGIN_DECISION([xattr attribute system interface])
+ APR_IFALLYES(header:sys/xattr.h dnl
+ define:XATTR_NOFOLLOW dnl
+ func:fgetxattr dnl
+ func:fsetxattr dnl
+ func:flistxattr dnl
+ func:fremovexattr,
+ [xattrdarwin="1"
+ APR_DECIDE(USE_XATTR_DARWIN, [xattr (Darwin)])])
+
+ APR_IFALLYES(header:sys/xattr.h dnl
+ func:lgetxattr dnl
+ func:fgetxattr dnl
+ func:fsetxattr dnl
+ func:flistxattr dnl
+ func:fremovexattr,
+ [xattrlinux="1"
+ APR_DECIDE(USE_XATTR_LINUX, [xattr (Linux)])])
+
+ APR_IFALLYES(header:sys/extattr.h dnl
+ func:extattr_set_fd dnl
+ func:func:extattr_get_fd dnl
+ func:extattr_list_fd dnl
+ func:func:extattr_delete_fd,
+ [xattrfreebsd="1"
+ APR_DECIDE(USE_XATTR_FREEBSD, [extattr (FreeBSD)])])
+
+ APR_IFALLYES(define:O_XATTR dnl
+ func:openat dnl
+ func:unlinkat,
+ [xattrsolaris="1"
+ APR_DECIDE(USE_XATTR_SOLARIS, [attropen (Solaris)])])
+
+ if test "x$ac_decision" = "x"; then
+ ac_decision="USE_XATTR_NONE"
+ ac_decision_msg="no xattr interface available"
+ fi
+ APR_END_DECISION
+ AC_DEFINE_UNQUOTED($ac_decision)
+fi
+
+if test "$xattrdarwin$xattrlinux$xattrfreebsd$xattrsolaris" = "0000"; then
+ xattr="0"
+else
+ xattr="1"
+fi
+AC_SUBST(xattr)
+
dnl ----------------------------- Checking for UUID Support
echo "${nl}Checking for OS UUID Support..."
diff -Naur apr-1.4.5.orig/include/apr.h.in apr-1.4.5/include/apr.h.in
--- apr-1.4.5.orig/include/apr.h.in 2011-11-21 18:38:28.661532544 +0000
+++ apr-1.4.5/include/apr.h.in 2011-11-21 18:40:23.666523955 +0000
@@ -104,6 +104,8 @@
#define APR_HAVE_SYS_UIO_H @sys_uioh@
#define APR_HAVE_SYS_UN_H @sys_unh@
#define APR_HAVE_SYS_WAIT_H @sys_waith@
+#define APR_HAVE_SYS_XATTR_H @sys_xattrh@
+#define APR_HAVE_SYS_EXTATTR_H @sys_extattrh@
#define APR_HAVE_TIME_H @timeh@
#define APR_HAVE_UNISTD_H @unistdh@
#define APR_HAVE_WINDOWS_H @windowsh@
@@ -276,6 +278,7 @@
#define APR_HAS_UNICODE_FS @have_unicode_fs@
#define APR_HAS_PROC_INVOKED @have_proc_invoked@
#define APR_HAS_USER @apr_has_user@
+#define APR_HAS_XATTR @xattr@
#define APR_HAS_LARGE_FILES @aprlfs@
#define APR_HAS_XTHREAD_FILES @apr_has_xthread_files@
#define APR_HAS_OS_UUID @osuuid@

View File

@ -0,0 +1,24 @@
diff -uNr apr-1.4.5.orig/build/apr_common.m4 apr-1.4.5/build/apr_common.m4
--- apr-1.4.5.orig/build/apr_common.m4 2011-11-21 19:58:38.341263862 +0100
+++ apr-1.4.5/build/apr_common.m4 2011-11-21 20:07:28.368394177 +0100
@@ -202,14 +202,18 @@
dnl for a user to override configure when it does something stupid.
dnl
AC_DEFUN([APR_RESTORE_THE_ENVIRONMENT], [
-if test "x$apr_ste_save_$1" = "x"; then
+dnl Check whether $apr_ste_save_$1 is empty or
+dnl only whitespace. The verbatim "X" is token number 1,
+dnl the following whitespace will be ignored.
+set X $apr_ste_save_$1
+if test ${#} -eq 1; then
$2$1="$$1"
$1=
else
if test "x$apr_ste_save_$1" = "x$$1"; then
$2$1=
else
- $2$1=`echo $$1 | sed -e "s%${apr_ste_save_$1}%%"`
+ $2$1=`echo "$$1" | sed -e "s%${apr_ste_save_$1}%%"`
$1="$apr_ste_save_$1"
fi
fi

View File

@ -0,0 +1,155 @@
Index: include/apr.h.in
===================================================================
--- include/apr.h.in (revision 606453)
+++ include/apr.h.in (working copy)
@@ -103,6 +103,8 @@
#define APR_HAVE_SYS_UIO_H @sys_uioh@
#define APR_HAVE_SYS_UN_H @sys_unh@
#define APR_HAVE_SYS_WAIT_H @sys_waith@
+#define APR_HAVE_SYS_XATTR_H @sys_xattrh@
+#define APR_HAVE_SYS_EXTATTR_H @sys_extattrh@
#define APR_HAVE_TIME_H @timeh@
#define APR_HAVE_UNISTD_H @unistdh@
#define APR_HAVE_WINDOWS_H @windowsh@
@@ -238,6 +240,7 @@
#define APR_HAS_UNICODE_FS @have_unicode_fs@
#define APR_HAS_PROC_INVOKED @have_proc_invoked@
#define APR_HAS_USER 1
+#define APR_HAS_XATTR @xattr@
#define APR_HAS_LARGE_FILES @aprlfs@
#define APR_HAS_XTHREAD_FILES 0
#define APR_HAS_OS_UUID @osuuid@
Index: configure.in
===================================================================
--- configure.in (revision 606453)
+++ configure.in (working copy)
@@ -124,7 +124,7 @@
DEFAULT_OSDIR="unix"
echo "(Default will be ${DEFAULT_OSDIR})"
-apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random"
+apr_modules="file_io network_io threadproc misc locks time mmap shmem user memory atomic poll support random xattr"
dnl Checks for programs.
AC_PROG_MAKE_SET
@@ -1135,7 +1135,9 @@
sys/types.h \
sys/uio.h \
sys/un.h \
- sys/wait.h)
+ sys/wait.h \
+ sys/xattr.h \
+ sys/extattr.h)
# IRIX 6.5 has a problem in <netinet/tcp.h> which prevents it from
# being included by itself. Check for <netinet/tcp.h> manually,
@@ -1187,6 +1189,8 @@
AC_SUBST(unistdh)
AC_SUBST(signalh)
AC_SUBST(sys_waith)
+AC_SUBST(sys_xattrh)
+AC_SUBST(sys_extattrh)
AC_SUBST(pthreadh)
AC_SUBST(semaphoreh)
AC_SUBST(windowsh)
@@ -2030,6 +2034,87 @@
APR_CHECK_DIRENT_INODE
APR_CHECK_DIRENT_TYPE
+dnl ----------------------------- Checking for Extended Attributes Support
+echo "${nl}Checking for Extended Attributes Support..."
+
+# Check whether Extended Attributes have explicitly been disabled
+AC_ARG_ENABLE(xattr,
+ [ --disable-xattr Disable Extended Attributes support in APR.],
+ [ if test "$enableval" = "no"; then
+ user_disabled_xattr=1
+ fi ],
+ [ user_disabled_xattr=0 ] )
+
+xattrdarwin="0"
+xattrlinux="0"
+xattrfreebsd="0"
+xattrsolaris="0"
+if test "$user_disabled_xattr" = 1; then
+ echo "no -- disabled by user"
+else
+ AC_CHECK_FUNCS([fgetxattr fsetxattr flistxattr fremovexattr lgetxattr \
+ extattr_get_fd extattr_set_fd extattr_list_fd \
+ extattr_delete_fd openat unlinkat])
+ APR_CHECK_DEFINE(O_XATTR, sys/fcntl.h)
+ APR_CHECK_DEFINE(XATTR_NOFOLLOW, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_CREATE, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_REPLACE, sys/xattr.h)
+ APR_CHECK_DEFINE(XATTR_NAME_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_SIZE_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_LIST_MAX, linux/limits.h)
+ APR_CHECK_DEFINE(XATTR_MAXNAMELEN, sys/xattr.h)
+ APR_CHECK_DEFINE(EXTATTR_NAMESPACE_USER, sys/extattr.h)
+ APR_CHECK_DEFINE(EXTATTR_NAMESPACE_SYSTEM, sys/extattr.h)
+ APR_CHECK_DEFINE(EXTATTR_MAXNAMELEN, sys/extattr.h)
+
+ APR_BEGIN_DECISION([xattr attribute system interface])
+ APR_IFALLYES(header:sys/xattr.h dnl
+ define:XATTR_NOFOLLOW dnl
+ func:fgetxattr dnl
+ func:fsetxattr dnl
+ func:flistxattr dnl
+ func:fremovexattr,
+ [xattrdarwin="1"
+ APR_DECIDE(USE_XATTR_DARWIN, [xattr (Darwin)])])
+
+ APR_IFALLYES(header:sys/xattr.h dnl
+ func:lgetxattr dnl
+ func:fgetxattr dnl
+ func:fsetxattr dnl
+ func:flistxattr dnl
+ func:fremovexattr,
+ [xattrlinux="1"
+ APR_DECIDE(USE_XATTR_LINUX, [xattr (Linux)])])
+
+ APR_IFALLYES(header:sys/extattr.h dnl
+ func:extattr_set_fd dnl
+ func:func:extattr_get_fd dnl
+ func:extattr_list_fd dnl
+ func:func:extattr_delete_fd,
+ [xattrfreebsd="1"
+ APR_DECIDE(USE_XATTR_FREEBSD, [extattr (FreeBSD)])])
+
+ APR_IFALLYES(define:O_XATTR dnl
+ func:openat dnl
+ func:unlinkat,
+ [xattrsolaris="1"
+ APR_DECIDE(USE_XATTR_SOLARIS, [attropen (Solaris)])])
+
+ if test "x$ac_decision" = "x"; then
+ ac_decision="USE_XATTR_NONE"
+ ac_decision_msg="no xattr interface available"
+ fi
+ APR_END_DECISION
+ AC_DEFINE_UNQUOTED($ac_decision)
+fi
+
+if test "$xattrdarwin$xattrlinux$xattrfreebsd$xattrsolaris" = "0000"; then
+ xattr="0"
+else
+ xattr="1"
+fi
+AC_SUBST(xattr)
+
dnl ----------------------------- Checking for UUID Support
echo "${nl}Checking for OS UUID Support..."
Index: build.conf
===================================================================
--- build.conf (revision 606453)
+++ build.conf (working copy)
@@ -13,7 +13,7 @@
# directories that have platform-specific code in them. the resulting
# pattern will be: SUBDIR/PLATFORM/*.c
platform_dirs =
- dso file_io locks memory misc mmap network_io poll random
+ dso file_io locks memory misc mmap network_io poll random xattr
shmem support threadproc time user atomic
# all the public headers

View File

@ -0,0 +1,366 @@
Index: include/apr_file_xattr.h
===================================================================
--- include/apr_file_xattr.h (revision 0)
+++ include/apr_file_xattr.h (revision 0)
@@ -0,0 +1,249 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef APR_FILE_XATTR_H
+#define APR_FILE_XATTR_H
+
+/**
+ * @file apr_file_xattr.h
+ * @brief APR File Extended Attributes
+ */
+
+#include "apr.h"
+#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_file_io.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_xattr File Extended Attribute Functions
+ * @ingroup APR
+ * @{
+ */
+
+/** When setting values, fail if the attribute already exists */
+#define APR_XATTR_CREATE 1
+
+/** When setting values, fail if the attribute does not already exist */
+#define APR_XATTR_REPLACE 2
+
+typedef struct apr_xattr_t apr_xattr_t;
+
+/**
+ * Open a context for access to the extended attributes of a file or
+ * directory specified by a path name
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param pathname the path name of the file or directory
+ * @param p the pool to allocate any memory from
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the path was opened for attribute access
+ * APR_STATUS_IS_ENOENT() the file or directory does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_path(apr_xattr_t **new,
+ const char *pathname,
+ apr_pool_t *p);
+
+/**
+ * Open a context for access to the extended attributes of an open file
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param file the open file to access the extended attributes on
+ * @param p the pool to allocate any memory from
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the file was opened for attribute access
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_file(apr_xattr_t **new,
+ apr_file_t *file,
+ apr_pool_t *p);
+
+/**
+ * Open a context for access to the extended attributes of an open directory
+ *
+ * @param new the context allocated for access to extended attributes
+ * @param dir the open directory to access the extended attributes on
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the directory was opened for attribute access
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_open_dir(apr_xattr_t **new,
+ apr_dir_t *dir,
+ apr_pool_t *p);
+
+/**
+ * Destroy a context used for access to extended attributes
+ *
+ * @param xattr the context to destroy
+ * <PRE>
+ * APR_SUCCESS the context was destroyed
+ * </PRE>
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_destroy(apr_xattr_t *xattr);
+
+/**
+ * Set an extended attribute on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the attribute name to set
+ * @param value the attribute value
+ * @param size the size in bytes of the attribute value
+ * @param flags to control how the attribute is set
+ * <PRE>
+ * APR_XATTR_CREATE return an error if the attribute name
+ * already exists.
+ * APR_XATTR_REPLACE return an error if the attribute name
+ * does not already exist.
+ * </PRE>
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was set
+ * APR_STATUS_IS_EEXIST() create flag and the attribute exists
+ * APR_STATUS_IS_ENOATTR() replace flag and the attribute doesn't exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @remark if neither flag APR_XATTR_CREATE or APR_XATTR_REPLACE are
+ * given then the attribute will either be created if it does not
+ * already exist or replaced if it does exist.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_set(const apr_xattr_t *xattr,
+ const char *name,
+ const void *value,
+ apr_size_t size,
+ apr_uint32_t flags);
+
+/**
+ * Get an extended attribute from a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the name of the attribute to get
+ * @param value the returned attribute value allocated from the pool
+ * @param size the returned size of the attribute value
+ * @param flags to control how the attribute is got (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was retrieved
+ * APR_STATUS_IS_ENOATTR() the attribute does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_get(const apr_xattr_t *xattr,
+ const char *name,
+ void **value,
+ apr_size_t *size,
+ apr_uint32_t flags);
+
+/**
+ * Check for the existence of an extended attribute on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the name of the attribute to get
+ * @param exists the returned value indicating whether the attribute exists
+ * @param flags to control how the attribute is got (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the existence was successfully tested
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_exists(const apr_xattr_t *xattr,
+ const char *name,
+ int *exists,
+ apr_uint32_t flags);
+
+/**
+ * List the extended attributes on a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param list the returned array of attributes names
+ * @param flags to control how the file is listed (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attributes were listed
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @remark list is an array containing simple null terminated strings.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_list(const apr_xattr_t *xattr,
+ apr_array_header_t **list,
+ apr_uint32_t flags);
+
+/**
+ * Remove an extended attribute from a file or directory
+ * @param xattr the opened extended attribute file or directory context
+ * @param name the attribute name to remove
+ * @param flags to control how the attribute is removed (reserved for future use)
+ * @param p the pool to allocate any memory from if required
+ * @return the status of the operation:
+ * <PRE>
+ * APR_SUCCESS the attribute was removed
+ * APR_STATUS_IS_ENOATTR() the attribute does not exist
+ * </PRE>
+ * Other operating system dependant error codes may be returned
+ * in the cases not listed above.
+ *
+ * @warning Platforms which do not implement this feature will return
+ * APR_ENOTIMPL.
+ */
+APR_DECLARE(apr_status_t) apr_xattr_remove(const apr_xattr_t *xattr,
+ const char *name,
+ apr_uint32_t flags);
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ! APR_FILE_XATTR_H */
Index: include/arch/unix/apr_arch_xattr.h
===================================================================
--- include/arch/unix/apr_arch_xattr.h (revision 0)
+++ include/arch/unix/apr_arch_xattr.h (revision 0)
@@ -0,0 +1,51 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FILE_XATTR_H
+#define FILE_XATTR_H
+
+#if APR_HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if APR_HAVA_ERRNO_H
+#include <errno.h>
+#endif
+#if APR_HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
+#endif
+#if APR_HAVE_SYS_EXTATTR_H
+#include <sys/extattr.h>
+#endif
+#if APR_HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if APR_HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+
+#ifdef _LARGEFILE64_SOURCE
+#define XATTR_OPEN_FLAGS O_RDONLY | O_LARGEFILE
+#else
+#define XATTR_OPEN_FLAGS O_RDONLY
+#endif
+
+struct apr_xattr_t {
+ int fd;
+ apr_uint32_t flags;
+ apr_pool_t *pool;
+};
+
+#endif
Index: include/apr_errno.h
===================================================================
--- include/apr_errno.h (revision 606453)
+++ include/apr_errno.h (working copy)
@@ -851,6 +851,13 @@
#define APR_EAFNOSUPPORT (APR_OS_START_CANONERR + 27)
#endif
+/** @see APR_STATUS_IS_ENOATTR */
+#ifdef ENOATTR
+#define APR_ENOATTR ENOATTR
+#else
+#define APR_ENOATTR (APR_OS_START_CANONERR + 28)
+#endif
+
/** @} */
#if defined(OS2) && !defined(DOXYGEN)
@@ -995,6 +1002,7 @@
|| (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_AFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
/*
Sorry, too tired to wrap this up for OS2... feel free to
@@ -1139,6 +1147,7 @@
|| (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2) && !defined(WIN32) */
@@ -1200,6 +1209,7 @@
#define APR_STATUS_IS_ENOTEMPTY(s) ((s) == APR_ENOTEMPTY)
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT \
|| (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
#else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
@@ -1319,6 +1329,13 @@
(s) == APR_EEXIST)
/** Address Family not supported */
#define APR_STATUS_IS_EAFNOSUPPORT(s) ((s) == APR_EAFNOSUPPORT)
+/** Attribute does not exists */
+#ifdef ENODATA
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR \
+ || (s) == ENODATA)
+#else
+#define APR_STATUS_IS_ENOATTR(s) ((s) == APR_ENOATTR)
+#endif
/** @} */
#endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,542 @@
Index: test/Makefile.in
===================================================================
--- test/Makefile.in (revision 606453)
+++ test/Makefile.in (working copy)
@@ -28,7 +28,7 @@
testhash.lo testargs.lo testnames.lo testuser.lo testpath.lo \
testenv.lo testprocmutex.lo testfnmatch.lo testatomic.lo testflock.lo \
testsock.lo testglobalmutex.lo teststrnatcmp.lo testfilecopy.lo \
- testtemp.lo testlfs.lo testcond.lo
+ testtemp.lo testlfs.lo testcond.lo testxattr.lo
OTHER_PROGRAMS = \
sendfile@EXEEXT@ \
Index: test/testxattr.c
===================================================================
--- test/testxattr.c (revision 0)
+++ test/testxattr.c (revision 0)
@@ -0,0 +1,499 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_file_io.h"
+#include "apr_file_xattr.h"
+#include "apr_errno.h"
+#include "apr_general.h"
+#include "testutil.h"
+
+#if APR_HAS_XATTR
+
+#define DIRNAME "data"
+#define FNAME DIRNAME "/file_xattrfile.txt"
+#define DNAME DIRNAME "/dir_xattrdir"
+
+#define TESTKEY1 "testkey1"
+#define TESTVAL1 "testval1"
+#define TESTKEY2 "testkey2"
+#define TESTVAL2 "testval2"
+
+/* test solaris subfilename escaping */
+#define TESTKEYSPECIAL1 "/testkey2"
+#define TESTKEYSPECIAL2 "%testkey2"
+
+static void test_xattr_file_set(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_set_create(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1),
+ APR_XATTR_CREATE);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1),
+ APR_XATTR_CREATE);
+ ABTS_TRUE(tc, APR_STATUS_IS_EEXIST(rv));
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_set_replace(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1),
+ APR_XATTR_REPLACE);
+ ABTS_TRUE(tc, APR_STATUS_IS_ENOATTR(rv));
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1),
+ APR_XATTR_CREATE);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1),
+ APR_XATTR_REPLACE);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_get(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, TESTKEY1, (void**)&val, &size, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_INT_EQUAL(tc, strlen(TESTVAL1), size);
+ ABTS_PTR_NOTNULL(tc, val);
+ ABTS_TRUE(tc, strncmp(TESTVAL1, val, strlen(TESTVAL1)) == 0);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_get_enoattr(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, TESTKEY1, (void**)&val, &size, 0);
+ ABTS_TRUE(tc, APR_STATUS_IS_ENOATTR(rv));
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_exists(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ int exists;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_exists(xattr, TESTKEY1, &exists, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_TRUE(tc, !exists);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_exists(xattr, TESTKEY1, &exists, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_TRUE(tc, exists);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_list(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_array_header_t *list = NULL;
+ int cmp1, cmp2;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_xattr_set(xattr, TESTKEY2, TESTVAL2, strlen(TESTVAL2), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_list(xattr, &list, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, list);
+ ABTS_INT_EQUAL(tc, 2, list->nelts);
+ cmp1 = (strcmp(APR_ARRAY_IDX(list, 0, char*), TESTKEY1) == 0) &&
+ (strcmp(APR_ARRAY_IDX(list, 1, char*), TESTKEY2) == 0);
+ cmp2 = (strcmp(APR_ARRAY_IDX(list, 0, char*), TESTKEY2) == 0) &&
+ (strcmp(APR_ARRAY_IDX(list, 1, char*), TESTKEY1) == 0);
+ ABTS_TRUE(tc, cmp1 || cmp2 );
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_remove(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_remove(xattr, TESTKEY1, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, TESTKEY1, (void**)&val, &size, 0);
+ ABTS_INT_NEQUAL(tc, APR_SUCCESS, rv);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_file_remove_enoattr(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_remove(xattr, TESTKEY1, 0);
+ ABTS_TRUE(tc, APR_STATUS_IS_ENOATTR(rv));
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+static void test_xattr_dir_set(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+
+ rv = apr_dir_make(DNAME, APR_OS_DEFAULT, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, DNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ apr_xattr_destroy(xattr);
+ apr_dir_remove(DNAME, p);
+}
+
+static void test_xattr_dir_get(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_dir_make(DNAME, APR_OS_DEFAULT, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, DNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, TESTKEY1, (void**)&val, &size, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_INT_EQUAL(tc, strlen(TESTVAL1), size);
+ ABTS_PTR_NOTNULL(tc, val);
+ ABTS_TRUE(tc, strncmp(TESTVAL1, val, strlen(TESTVAL1)) == 0);
+
+ apr_xattr_destroy(xattr);
+ apr_dir_remove(DNAME, p);
+}
+
+static void test_xattr_dir_exists(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ int exists;
+
+ rv = apr_dir_make(DNAME, APR_OS_DEFAULT, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, DNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_exists(xattr, TESTKEY1, &exists, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_TRUE(tc, !exists);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_exists(xattr, TESTKEY1, &exists, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_TRUE(tc, exists);
+
+ apr_xattr_destroy(xattr);
+ apr_dir_remove(DNAME, p);
+}
+
+static void test_xattr_dir_list(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_array_header_t *list = NULL;
+ int cmp1, cmp2;
+
+ rv = apr_dir_make(DNAME, APR_OS_DEFAULT, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, DNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ rv = apr_xattr_set(xattr, TESTKEY2, TESTVAL2, strlen(TESTVAL2), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_list(xattr, &list, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, list);
+ ABTS_INT_EQUAL(tc, 2, list->nelts);
+ cmp1 = (strcmp(APR_ARRAY_IDX(list, 0, char*), TESTKEY1) == 0) &&
+ (strcmp(APR_ARRAY_IDX(list, 1, char*), TESTKEY2) == 0);
+ cmp2 = (strcmp(APR_ARRAY_IDX(list, 0, char*), TESTKEY2) == 0) &&
+ (strcmp(APR_ARRAY_IDX(list, 1, char*), TESTKEY1) == 0);
+ ABTS_TRUE(tc, cmp1 || cmp2 );
+
+ apr_xattr_destroy(xattr);
+ apr_dir_remove(DNAME, p);
+}
+
+static void test_xattr_dir_remove(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_size_t size;
+ char *val = NULL;
+
+ rv = apr_dir_make(DNAME, APR_OS_DEFAULT, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, DNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, TESTKEY1, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_remove(xattr, TESTKEY1, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, TESTKEY1, (void**)&val, &size, 0);
+ ABTS_INT_NEQUAL(tc, APR_SUCCESS, rv);
+
+ apr_xattr_destroy(xattr);
+ apr_dir_remove(DNAME, p);
+}
+
+static void test_xattr_open_path_enoent(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_TRUE(tc, APR_STATUS_IS_ENOENT(rv));
+}
+
+static void test_xattr_file_special_chars(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_xattr_t *xattr;
+ apr_file_t *filetest = NULL;
+ apr_size_t size;
+ const char *name = (const char*)data;
+ char *val = NULL;
+ apr_array_header_t *list = NULL;
+ int cmp1, cmp2;
+
+ rv = apr_file_open(&filetest, FNAME,
+ APR_WRITE | APR_CREATE | APR_DELONCLOSE,
+ APR_UREAD | APR_UWRITE | APR_GREAD, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_open_path(&xattr, FNAME, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_set(xattr, name, TESTVAL1, strlen(TESTVAL1), 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_xattr_get(xattr, name, (void**)&val, &size, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_INT_EQUAL(tc, strlen(TESTVAL1), size);
+ ABTS_PTR_NOTNULL(tc, val);
+ ABTS_TRUE(tc, strncmp(TESTVAL1, val, strlen(TESTVAL1)) == 0);
+
+ rv = apr_xattr_list(xattr, &list, 0);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, list);
+ ABTS_INT_EQUAL(tc, 1, list->nelts);
+ ABTS_TRUE(tc, strcmp(name, APR_ARRAY_IDX(list, 0, char*)) == 0);
+
+ apr_xattr_destroy(xattr);
+ apr_file_close(filetest);
+}
+
+#else
+
+static void test_xattr_not_impl(abts_case *tc, void *data)
+{
+ ABTS_NOT_IMPL(tc, "xattr not implemented on this platform");
+}
+
+#endif /* APR_HAS_XATTR */
+
+abts_suite *testxattr(abts_suite *suite)
+{
+ suite = ADD_SUITE(suite)
+
+#if !APR_HAS_XATTR
+ abts_run_test(suite, test_xattr_not_impl, NULL);
+#else
+ abts_run_test(suite, test_xattr_file_set, NULL);
+ abts_run_test(suite, test_xattr_file_set_create, NULL);
+ abts_run_test(suite, test_xattr_file_set_replace, NULL);
+ abts_run_test(suite, test_xattr_file_get, NULL);
+ abts_run_test(suite, test_xattr_file_get_enoattr, NULL);
+ abts_run_test(suite, test_xattr_file_exists, NULL);
+ abts_run_test(suite, test_xattr_file_list, NULL);
+ abts_run_test(suite, test_xattr_file_remove, NULL);
+ abts_run_test(suite, test_xattr_file_remove_enoattr, NULL);
+ abts_run_test(suite, test_xattr_dir_set, NULL);
+ abts_run_test(suite, test_xattr_dir_get, NULL);
+ abts_run_test(suite, test_xattr_dir_exists, NULL);
+ abts_run_test(suite, test_xattr_dir_list, NULL);
+ abts_run_test(suite, test_xattr_dir_remove, NULL);
+ abts_run_test(suite, test_xattr_open_path_enoent, NULL);
+ abts_run_test(suite, test_xattr_file_special_chars, TESTKEYSPECIAL1);
+ abts_run_test(suite, test_xattr_file_special_chars, TESTKEYSPECIAL2);
+#endif
+
+ return suite;
+}
Index: test/abts_tests.h
===================================================================
--- test/abts_tests.h (revision 606453)
+++ test/abts_tests.h (working copy)
@@ -66,7 +66,8 @@
{testtime},
{testud},
{testuser},
- {testvsn}
+ {testvsn},
+ {testxattr}
};
#endif /* APR_TEST_INCLUDES */
Index: test/testutil.h
===================================================================
--- test/testutil.h (revision 606453)
+++ test/testutil.h (working copy)
@@ -102,5 +102,6 @@
abts_suite *testud(abts_suite *suite);
abts_suite *testuser(abts_suite *suite);
abts_suite *testvsn(abts_suite *suite);
+abts_suite *testxattr(abts_suite *suite);
#endif /* APR_TEST_INCLUDES */

View File

@ -0,0 +1,25 @@
--- config.layout.orig 2006-07-06 21:44:41.000000000 -0700
+++ config.layout 2006-07-06 21:46:26.000000000 -0700
@@ -229,3 +229,22 @@
infodir: ${exec_prefix}/share/info
libsuffix: -${APR_MAJOR_VERSION}
</Layout>
+
+# Gentoo layout
+<Layout gentoo>
+ prefix: /usr
+ exec_prefix: ${prefix}
+ bindir: ${exec_prefix}/bin
+ sbindir: ${exec_prefix}/bin
+ libdir: ${exec_prefix}/lib
+ libexecdir: ${exec_prefix}/modules
+ mandir: ${prefix}/man
+ sysconfdir: ${prefix}/conf
+ datadir: /usr/share/apr-${APR_MAJOR_VERSION}
+ installbuilddir: ${datadir}/build-${APR_MAJOR_VERSION}
+ includedir: ${prefix}/include/apr-${APR_MAJOR_VERSION}
+ localstatedir: ${prefix}
+ libsuffix: -${APR_MAJOR_VERSION}
+</Layout>
+
+

13
dev-libs/apr/metadata.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<herd>apache</herd>
<maintainer>
<email>apache-bugs@gentoo.org</email>
</maintainer>
<use>
<flag name='older-kernels-compatibility'>Enable binary compatibility with older kernels</flag>
<flag name='urandom'>Use /dev/urandom instead of /dev/random</flag>
<flag name='uuid'>Enable UUID support</flag>
</use>
</pkgmetadata>