summaryrefslogtreecommitdiff
path: root/libattr
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2003-02-26 06:27:13 +0000
committerNathan Scott <nathans@sgi.com>2003-02-26 06:27:13 +0000
commit79989b25c65ea0b8352fcd0bfc15461af09251b3 (patch)
treed993baa3d0be95f4978ffe1ab2d765d993b743c5 /libattr
parent7b33ebd60e68795347c2c844d81d90e38fd9091e (diff)
downloadattr-79989b25c65ea0b8352fcd0bfc15461af09251b3.tar.gz
Another extended attributes userspace patch from AndreasG - several small
incremental fixes from last set, and addition of symbol versioning.
Diffstat (limited to 'libattr')
-rw-r--r--libattr/Makefile10
-rw-r--r--libattr/attr_copy_check.c51
-rw-r--r--libattr/attr_copy_fd.c13
-rw-r--r--libattr/attr_copy_file.c13
-rw-r--r--libattr/libattr.h1
5 files changed, 68 insertions, 20 deletions
diff --git a/libattr/Makefile b/libattr/Makefile
index f9f9e14..2d33d03 100644
--- a/libattr/Makefile
+++ b/libattr/Makefile
@@ -32,14 +32,16 @@
#
TOPDIR = ..
+
+LTLDFLAGS = -Wl,--version-script,$(TOPDIR)/exports
include $(TOPDIR)/include/builddefs
LTLIBRARY = libattr.la
-LT_CURRENT = 1
-LT_REVISION = 2
-LT_AGE = 0
+LT_CURRENT = 2
+LT_REVISION = 0
+LT_AGE = 1
-CFILES = libattr.c syscalls.c attr_copy_fd.c attr_copy_file.c
+CFILES = libattr.c syscalls.c attr_copy_fd.c attr_copy_file.c attr_copy_check.c
HFILES = libattr.h
LCFLAGS = -include libattr.h
diff --git a/libattr/attr_copy_check.c b/libattr/attr_copy_check.c
new file mode 100644
index 0000000..049ae0b
--- /dev/null
+++ b/libattr/attr_copy_check.c
@@ -0,0 +1,51 @@
+/* Copy extended attributes between files - default check callback */
+
+/* Copyright (C) 2003 Andreas Gruenbacher <agruen@suse.de>, SuSE Linux AG.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <string.h>
+
+struct error_context;
+
+int
+attr_copy_check_permissions(const char *name, struct error_context *ctx)
+{
+ /* Skip POSIX ACLs. */
+ if (strncmp(name, "system.posix_acl_", 17) == 0 &&
+ (strcmp(name, "access") == 0 ||
+ strcmp(name, "default") == 0))
+ return 0;
+
+ /* Skip permissions attributes which are used on IRIX, and
+ hence are part of the XFS ondisk format (incl. ACLs). */
+ if (strncmp(name, "trusted.SGI_", 12) == 0 &&
+ (strcmp(name, "ACL_DEFAULT") == 0 ||
+ strcmp(name, "ACL_FILE") == 0 ||
+ strcmp(name, "CAP_FILE") == 0 ||
+ strcmp(name, "MAC_FILE") == 0))
+ return 0;
+
+ /* The xfsroot namespace mirrored attributes, some of which
+ are also also available via the system.* and trusted.*
+ namespaces. To avoid the problems this would cause,
+ we skip xfsroot altogether.
+ Note: xfsroot namespace has now been removed from XFS. */
+ if (strncmp(name, "xfsroot.", 8) == 0)
+ return 0;
+
+ return 1;
+}
+
diff --git a/libattr/attr_copy_fd.c b/libattr/attr_copy_fd.c
index 78e6383..4898121 100644
--- a/libattr/attr_copy_fd.c
+++ b/libattr/attr_copy_fd.c
@@ -33,6 +33,10 @@
# include <attr/xattr.h>
#endif
+#if defined(HAVE_ATTR_LIBATTR_H)
+# include "attr/libattr.h"
+#endif
+
#define ERROR_CONTEXT_MACROS
#include "error_context.h"
@@ -48,13 +52,6 @@
# define my_free(ptr) free (ptr)
#endif
-static int
-check_no_acl(const char *name, struct error_context *ctx)
-{
- return strcmp(name, "system.posix_acl_access") &&
- strcmp(name, "system.posix_acl_default");
-}
-
/* Copy extended attributes from src_path to dst_path. If the file
has an extended Access ACL (system.posix_acl_access) and that is
copied successfully, the file mode permission bits are copied as
@@ -74,7 +71,7 @@ attr_copy_fd(const char *src_path, int src_fd,
/* ignore acls by default */
if (check == NULL)
- check = check_no_acl;
+ check = attr_copy_check_permissions;
size = flistxattr (src_fd, NULL, 0);
if (size < 0) {
diff --git a/libattr/attr_copy_file.c b/libattr/attr_copy_file.c
index 98296ed..ad0045d 100644
--- a/libattr/attr_copy_file.c
+++ b/libattr/attr_copy_file.c
@@ -33,6 +33,10 @@
# include <attr/xattr.h>
#endif
+#if defined(HAVE_ATTR_LIBATTR_H)
+# include "attr/libattr.h"
+#endif
+
#define ERROR_CONTEXT_MACROS
#include "error_context.h"
@@ -48,13 +52,6 @@
# define my_free(ptr) free (ptr)
#endif
-static int
-check_no_acl(const char *name, struct error_context *ctx)
-{
- return strcmp(name, "system.posix_acl_access") &&
- strcmp(name, "system.posix_acl_default");
-}
-
/* Copy extended attributes from src_path to dst_path. If the file
has an extended Access ACL (system.posix_acl_access) and that is
copied successfully, the file mode permission bits are copied as
@@ -72,7 +69,7 @@ attr_copy_file(const char *src_path, const char *dst_path,
/* ignore acls by default */
if (check == NULL)
- check = check_no_acl;
+ check = attr_copy_check_permissions;
size = listxattr (src_path, NULL, 0);
if (size < 0) {
diff --git a/libattr/libattr.h b/libattr/libattr.h
index 316c1db..8973b00 100644
--- a/libattr/libattr.h
+++ b/libattr/libattr.h
@@ -1,6 +1,7 @@
/* Features we provide ourself. */
#define HAVE_ATTR_XATTR_H 1
+#define HAVE_ATTR_LIBATTR_H 1
#define HAVE_CONFIG_H 1
#define HAVE_FGETXATTR 1