diff -rup coreutils-5.97-orig/configure.ac coreutils-5.97/configure.ac --- coreutils-5.97-orig/configure.ac 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/configure.ac 2006-08-28 03:11:16.000000000 -0400 @@ -41,6 +41,13 @@ AC_ARG_ENABLE(selinux, dnl LIB_SELINUX="-lselinux" AC_SUBST(LIB_SELINUX)]) +dnl Give the chance to enable XATTR support... +AC_ARG_ENABLE(selinux, dnl +[ --enable-xattrs Enable use of the extended attribute library], +[AC_DEFINE(WITH_ATTR, 1, [Define if you want to use ATTR]) +LIB_ATTR="-lattr" +AC_SUBST(LIB_ATTR)]) + gl_DEFAULT_POSIX2_VERSION gl_USE_SYSTEM_EXTENSIONS gl_PERL Only in coreutils-5.97: configure.ac.xattrs diff -rup coreutils-5.97-orig/doc/coreutils.texi coreutils-5.97/doc/coreutils.texi --- coreutils-5.97-orig/doc/coreutils.texi 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/doc/coreutils.texi 2006-08-28 03:43:58.000000000 -0400 @@ -6447,6 +6447,15 @@ If specified, the @var{attribute_list} m of one or more of the following strings: @table @samp +@itemx acls +Preserve the Acess Control Lists. +@itemx context +Preserve the SELinux security context. +@itemx links +Preserve in the destination files +any links between corresponding source files. +@c Give examples illustrating how hard links are preserved. +@c Also, show how soft links map to hard links with -L and -H. @itemx mode Preserve the permission attributes. @itemx ownership @@ -6456,19 +6465,15 @@ may preserve the group ownership of a fi a member of the desired group. @itemx timestamps Preserve the times of last access and last modification. -@itemx links -Preserve in the destination files -any links between corresponding source files. -@c Give examples illustrating how hard links are preserved. -@c Also, show how soft links map to hard links with -L and -H. +@itemx xattrs +Preserve the extended attributes (not including acls and selinux context). @itemx all Preserve all file attributes. Equivalent to specifying all of the above. -@c Mention ACLs here. @end table Using @option{--preserve} with no @var{attribute_list} is equivalent -to @option{--preserve=mode,ownership,timestamps}. +to @option{--preserve=acls,mode,ownership,timestamps,xattrs}. In the absence of this option, each destination file is created with the permissions of the corresponding source file, minus the bits set in the Only in coreutils-5.97/doc: coreutils.texi~ Only in coreutils-5.97/lib: base64.c.newhashes Only in coreutils-5.97/lib: base64.h.newhashes Only in coreutils-5.97/lib: sha256.c.newhashes Only in coreutils-5.97/lib: sha256.h.newhashes Only in coreutils-5.97/lib: sha512.c.newhashes Only in coreutils-5.97/lib: sha512.h.newhashes Only in coreutils-5.97/m4: posix_acl.m4.acl Only in coreutils-5.97/m4: sha256.m4.newhashes Only in coreutils-5.97/m4: sha512.m4.newhashes Only in coreutils-5.97/man: base64.x.newhashes Only in coreutils-5.97/man: chcon.1.selinux Only in coreutils-5.97/man: chcon.x.selinux Only in coreutils-5.97/man: runcon.1.selinux Only in coreutils-5.97/man: runcon.x.selinux Only in coreutils-5.97/man: runuser.1.runuser Only in coreutils-5.97/man: runuser.x.runuser Only in coreutils-5.97/man: sha224sum.x.newhashes Only in coreutils-5.97/man: sha256sum.x.newhashes Only in coreutils-5.97/man: sha384sum.x.newhashes Only in coreutils-5.97/man: sha512sum.x.newhashes Only in coreutils-5.97/src: base64.c.newhashes Only in coreutils-5.97/src: chcon.c.selinux diff -rup coreutils-5.97-orig/src/copy.c coreutils-5.97/src/copy.c --- coreutils-5.97-orig/src/copy.c 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/copy.c 2006-08-28 03:41:09.000000000 -0400 @@ -55,6 +55,10 @@ #include /* for is_selinux_enabled() */ extern int selinux_enabled; #endif +#ifdef WITH_ATTR +# include +# include /* should go away when xattr_delete goes */ +#endif #ifndef HAVE_FCHMOD # define HAVE_FCHMOD false @@ -176,6 +180,72 @@ copy_dir (char const *src_name_in, char return ok; } +#ifdef WITH_ATTR +/* this is mostly taken from attr_copy_*() and should be inside the libattr + library */ +static int xattr_delete(const char *fname, int fd, + int (*check)(const char *, struct error_context *), + struct error_context *ctx) +{ + ssize_t size; + char *names = NULL; + char *end_names; + char *name; + int ret = 0; + int saved_errno = 0; + + /* ignore acls by default */ + if (check == NULL) + check = attr_copy_check_permissions; + + size = flistxattr (fd, NULL, 0); + if (size < 0) + return -1; + + names = xmalloc (size + 1); + + size = flistxattr (fd, names, size); + if (size < 0) + { + saved_errno = errno; + ret = -1; + goto end; + } + + names[size] = '\0'; + end_names = names + size; + + for (name = names; name != end_names; name = strchr (name, '\0') + 1) + { + /* check if this attribute shall be preserved */ + if (!*name || !check (name, ctx)) + continue; + + if (fremovexattr (fd, name) == -1) + { + saved_errno = errno; + ret = -1; + } + } + + end: + free(names); + errno = saved_errno; + + return ret; +} + +static int xattr_chk(const char *xattr, struct error_context *ecntx) +{ /* just do the sutff we aren't doing some other way... */ + if (!strcmp (xattr, "security.selinux")) + return 0; + if (!strncmp (xattr, "system.posix_acl_", strlen ("system.posix_acl_"))) + return 0; + + return 1; +} +#endif + /* Copy a regular file from SRC_NAME to DST_NAME. If the source file contains holes, copies holes and blocks of zeros in the source file as holes in the destination file. @@ -461,7 +531,32 @@ copy_reg (char const *src_name, char con #if HAVE_STRUCT_STAT_ST_AUTHOR /* FIXME: Preserve the st_author field via the file descriptor dest_desc. */ #endif - + +#ifdef WITH_ATTR + if (x->preserve_xattrs) + { + if (attr_copy_fd (src_name, source_desc, dst_name, dest_desc, + xattr_chk, NULL)) + { + error (0, errno, _("preserving xattrs for %s"), quote (dst_name)); + if (x->require_preserve) + { + return_val = false; + goto close_src_and_dst_desc; + } + } + if (*new_dst && xattr_delete (dst_name, dest_desc, xattr_chk, NULL)) + { + error (0, errno, _("preserving xattrs for %s"), quote (dst_name)); + if (x->require_preserve) + { + return_val = false; + goto close_src_and_dst_desc; + } + } + } +#endif + #if HAVE_FCHMOD /* Permissions of newly-created regular files were set upon `open'. But don't return early if there were any special bits and chown @@ -470,7 +565,7 @@ copy_reg (char const *src_name, char con && !(*chown_succeeded && (src_sb->st_mode & ~S_IRWXUGO))) && (x->copy_as_regular || S_ISREG (src_sb->st_mode))) { - if (x->preserve_mode || x->move_mode) + if (x->preserve_acls || x->move_mode) { if (copy_acl (src_name, dst_name, src_sb->st_mode)) { @@ -1794,7 +1889,13 @@ copy_internal (char const *src_name, cha } #endif - if (x->preserve_mode || x->move_mode) +#ifdef WITH_ATTR + if (x->preserve_xattrs + && attr_copy_file (src_name, dst_name, xattr_chk, NULL)) + return false; +#endif + + if (x->preserve_acls || x->move_mode) { if (copy_acl (src_name, dst_name, src_mode) && x->require_preserve) return false; Only in coreutils-5.97/src: copy.c.xattrs diff -rup coreutils-5.97-orig/src/copy.h coreutils-5.97/src/copy.h --- coreutils-5.97-orig/src/copy.h 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/copy.h 2006-08-28 03:37:37.000000000 -0400 @@ -130,6 +130,8 @@ struct cp_options #ifdef WITH_SELINUX bool preserve_security_context; #endif + bool preserve_acls; + bool preserve_xattrs; /* Enabled for mv, and for cp by the --preserve=links option. If true, attempt to preserve in the destination files any Only in coreutils-5.97/src: copy.h~ diff -rup coreutils-5.97-orig/src/cp.c coreutils-5.97/src/cp.c --- coreutils-5.97-orig/src/cp.c 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/cp.c 2006-08-28 03:41:30.000000000 -0400 @@ -198,8 +198,9 @@ Mandatory arguments to long options are fputs (_("\ -p same as --preserve=mode,ownership,timestamps\n\ --preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ - mode,ownership,timestamps), if possible\n\ - additional attributes: links, all\n\ + acls,mode,ownership,timestamps,xattrs), if\n\ + possible.\n\ + additional attributes: context, links, all\n\ "), stdout); fputs (_("\ -c same as --preserve=context\n\ @@ -340,7 +341,7 @@ re_protect (char const *const_dst_name, } } - if (x->preserve_mode) + if (x->preserve_acls) { if (copy_acl (src_name, dst_name, src_sb.st_mode)) return 1; @@ -354,7 +355,7 @@ re_protect (char const *const_dst_name, return false; } } - + dst_name[p->slash_offset] = '/'; } return true; @@ -757,6 +758,9 @@ cp_option_init (struct cp_options *x) x->preserve_security_context = false; #endif + x->preserve_acls = false; + x->preserve_xattrs = false; + x->require_preserve = false; x->recursive = false; x->sparse_mode = SPARSE_AUTO; @@ -780,23 +784,26 @@ decode_preserve_arg (char const *arg, st { enum File_attribute { + PRESERVE_ACLS, PRESERVE_MODE, PRESERVE_TIMESTAMPS, PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, + PRESERVE_XATTRS, PRESERVE_ALL }; static enum File_attribute const preserve_vals[] = { - PRESERVE_MODE, PRESERVE_TIMESTAMPS, - PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL + PRESERVE_ACLS, PRESERVE_MODE, PRESERVE_TIMESTAMPS, + PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_XATTRS, + PRESERVE_ALL }; /* Valid arguments to the `--preserve' option. */ static char const* const preserve_args[] = { - "mode", "timestamps", - "ownership", "links", "context", "all", NULL + "acls", "mode", "timestamps", + "ownership", "links", "context", "xattrs", "all", NULL }; ARGMATCH_VERIFY (preserve_args, preserve_vals); @@ -836,12 +843,22 @@ decode_preserve_arg (char const *arg, st x->preserve_security_context = on_off; break; + case PRESERVE_ACLS: + x->preserve_acls = on_off; + break; + + case PRESERVE_XATTRS: + x->preserve_xattrs = on_off; + break; + case PRESERVE_ALL: x->preserve_mode = on_off; x->preserve_timestamps = on_off; x->preserve_ownership = on_off; x->preserve_links = on_off; x->preserve_security_context = on_off; + x->preserve_acls = on_off; + x->preserve_xattrs = on_off; break; default: @@ -906,6 +923,8 @@ main (int argc, char **argv) x.preserve_ownership = true; x.preserve_mode = true; x.preserve_timestamps = true; + x.preserve_acls = true; + x.preserve_xattrs = true; x.require_preserve = true; x.recursive = true; break; @@ -969,6 +988,8 @@ main (int argc, char **argv) x.preserve_ownership = true; x.preserve_mode = true; x.preserve_timestamps = true; + x.preserve_acls = true; + x.preserve_xattrs = true; x.require_preserve = true; break; Only in coreutils-5.97/src: cp.c~ diff -rup coreutils-5.97-orig/src/install.c coreutils-5.97/src/install.c --- coreutils-5.97-orig/src/install.c 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/install.c 2006-08-28 03:37:52.000000000 -0400 @@ -183,6 +183,8 @@ cp_option_init (struct cp_options *x) x->preserve_links = false; x->preserve_mode = false; x->preserve_timestamps = false; + x->preserve_acls = false; + x->preserve_xattrs = false; x->require_preserve = false; x->recursive = false; x->sparse_mode = SPARSE_AUTO; @@ -310,6 +312,7 @@ main (int argc, char **argv) break; case 'p': x.preserve_timestamps = true; + x.preserve_xattrs = true; break; case 'S': make_backups = true; Only in coreutils-5.97/src: install.c~ diff -rup coreutils-5.97-orig/src/Makefile.am coreutils-5.97/src/Makefile.am --- coreutils-5.97-orig/src/Makefile.am 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/Makefile.am 2006-08-28 03:11:16.000000000 -0400 @@ -52,9 +52,9 @@ AM_CPPFLAGS = -I.. -I$(srcdir) -I$(top_s LDADD = ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a # for eaccess in lib/euidaccess.c. -cp_LDADD = $(LDADD) $(LIB_EACCESS) @LIBACL@ @LIB_SELINUX@ +cp_LDADD = $(LDADD) $(LIB_EACCESS) @LIBACL@ @LIB_SELINUX@ @LIB_ATTR@ ginstall_LDADD = $(LDADD) $(LIB_EACCESS) @LIBACL@ @LIB_SELINUX@ -mv_LDADD = $(LDADD) $(LIB_EACCESS) @LIBACL@ @LIB_SELINUX@ +mv_LDADD = $(LDADD) $(LIB_EACCESS) @LIBACL@ @LIB_SELINUX@ @LIB_ATTR@ pathchk_LDADD = $(LDADD) $(LIB_EACCESS) rm_LDADD = $(LDADD) $(LIB_EACCESS) test_LDADD = $(LDADD) $(LIB_EACCESS) Only in coreutils-5.97/src: Makefile.am.xattrs diff -rup coreutils-5.97-orig/src/mv.c coreutils-5.97/src/mv.c --- coreutils-5.97-orig/src/mv.c 2006-08-15 23:09:19.000000000 -0400 +++ coreutils-5.97/src/mv.c 2006-08-28 03:39:08.000000000 -0400 @@ -135,6 +135,8 @@ cp_option_init (struct cp_options *x) #ifdef WITH_SELINUX x->preserve_security_context = 1; #endif + x->preserve_acls = true; + x->preserve_xattrs = true; x->require_preserve = false; /* FIXME: maybe make this an option */ x->recursive = true; x->sparse_mode = SPARSE_AUTO; /* FIXME: maybe make this an option */ Only in coreutils-5.97/src: mv.c~ Only in coreutils-5.97/src: runcon.c.selinux Only in coreutils-5.97/tests/misc: base64.newhashes Only in coreutils-5.97/tests/misc: sha224sum.newhashes Only in coreutils-5.97/tests/misc: sha256sum.newhashes Only in coreutils-5.97/tests/misc: sha384sum.newhashes Only in coreutils-5.97/tests/misc: sha512sum.newhashes Only in coreutils-5.97/tests/sort: mb1.I.i18n Only in coreutils-5.97/tests/sort: mb1.X.i18n Only in coreutils-5.97/tests/sort: mb2.I.i18n Only in coreutils-5.97/tests/sort: mb2.X.i18n Only in coreutils-5.97/tests/sort: sort-mb-tests.i18n