Line
Link Here
|
0 |
-- coreutils-6.11/configure.ac |
0 |
++ coreutils-6.11/configure.ac |
Lines 249-254
Link Here
|
249 |
AC_SUBST([CONFIG_STATUS_DEPENDENCIES]) |
249 |
AC_SUBST([CONFIG_STATUS_DEPENDENCIES]) |
250 |
############################################################################ |
250 |
############################################################################ |
251 |
|
251 |
|
|
|
252 |
# Extended attribute copying. |
253 |
AC_FUNC_XATTR |
254 |
|
252 |
AM_GNU_GETTEXT([external], [need-formatstring-macros]) |
255 |
AM_GNU_GETTEXT([external], [need-formatstring-macros]) |
253 |
AM_GNU_GETTEXT_VERSION([0.15]) |
256 |
AM_GNU_GETTEXT_VERSION([0.15]) |
254 |
|
257 |
|
255 |
-- coreutils-6.11/m4/xattr.m4 |
258 |
++ coreutils-6.11/m4/xattr.m4 |
Line 0
Link Here
|
0 |
-- coreutils-6.11/src/copy.c |
1 |
# xattr.m4 - check for Extended Attributes (Linux) |
|
|
2 |
|
3 |
# Copyright (C) 2003 Free Software Foundation, Inc. |
4 |
|
5 |
# This program is free software; you can redistribute it and/or modify |
6 |
# it under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 2, or (at your option) |
8 |
# any later version. |
9 |
|
10 |
# This program is distributed in the hope that it will be useful, |
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
|
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with this program; if not, write to the Free Software Foundation, |
17 |
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
18 |
|
19 |
# Written by Andreas Gruenbacher. |
20 |
|
21 |
AC_DEFUN([AC_FUNC_XATTR], |
22 |
[ |
23 |
AC_ARG_ENABLE(xattr, |
24 |
[ --disable-xattr turn off support for extended attributes], |
25 |
use_xattr=$enableval, use_xattr=yes) |
26 |
|
27 |
if test "$use_xattr" = "yes"; then |
28 |
AC_CHECK_HEADERS(attr/error_context.h attr/libattr.h) |
29 |
if test "$ac_cv_header_attr_libattr_h" = yes \ |
30 |
&& test "$ac_cv_header_attr_error_context_h" = yes; then |
31 |
use_xattr=1 |
32 |
else |
33 |
use_xattr=0 |
34 |
fi |
35 |
AC_DEFINE_UNQUOTED(USE_XATTR, $use_xattr, |
36 |
[Define if you want extended attribute support.]) |
37 |
xattr_saved_LIBS=$LIBS |
38 |
AC_SEARCH_LIBS(attr_copy_file, attr, |
39 |
[test "$ac_cv_search_attr_copy_file" = "none required" || LIB_XATTR=$ac_cv_search_attr_copy_file]) |
40 |
AC_SUBST(LIB_XATTR) |
41 |
AC_CHECK_FUNCS(attr_copy_file) |
42 |
LIBS=$xattr_saved_LIBS |
43 |
fi |
44 |
]) |
|
|
45 |
++ coreutils-6.11/src/copy.c |
Lines 53-58
Link Here
|
53 |
#include "areadlink.h" |
53 |
#include "areadlink.h" |
54 |
#include "yesno.h" |
54 |
#include "yesno.h" |
55 |
|
55 |
|
|
|
56 |
#if USE_XATTR |
57 |
# include <stdarg.h> |
58 |
# include <attr/error_context.h> |
59 |
# include <attr/libattr.h> |
60 |
#endif |
61 |
|
56 |
#ifndef HAVE_FCHOWN |
62 |
#ifndef HAVE_FCHOWN |
57 |
# define HAVE_FCHOWN false |
63 |
# define HAVE_FCHOWN false |
58 |
# define fchown(fd, uid, gid) (-1) |
64 |
# define fchown(fd, uid, gid) (-1) |
Lines 118-123
is_ancestor (const struct stat *sb, cons
Link Here
|
118 |
return false; |
124 |
return false; |
119 |
} |
125 |
} |
120 |
|
126 |
|
|
|
127 |
#if USE_XATTR |
128 |
static void |
129 |
copy_xattr_error (struct error_context *ctx, const char *fmt, ...) |
130 |
{ |
131 |
int err = errno; |
132 |
va_list ap; |
133 |
int len; |
134 |
char *buffer; |
135 |
|
136 |
/* There is no error function that takes a va_list argument, |
137 |
so we print the message in a buffer first. */ |
138 |
|
139 |
va_start (ap, fmt); |
140 |
len = vsnprintf (NULL, 0, fmt, ap); |
141 |
va_end (ap); |
142 |
if (len > 0) |
143 |
{ |
144 |
buffer = xmalloc (len + 1); |
145 |
va_start (ap, fmt); |
146 |
vsnprintf (buffer, len + 1, fmt, ap); |
147 |
va_end (ap); |
148 |
error (0, err, "%s", buffer); |
149 |
free (buffer); |
150 |
} |
151 |
} |
152 |
|
153 |
static const char * |
154 |
copy_xattr_quote (struct error_context *ctx, const char *str) |
155 |
{ |
156 |
return xstrdup (quote (str)); |
157 |
} |
158 |
|
159 |
static void |
160 |
copy_xattr_free (struct error_context *ctx, const char *str) |
161 |
{ |
162 |
free ((void *) str); |
163 |
} |
164 |
|
165 |
struct copy_xattr_context { |
166 |
struct error_context ctx; |
167 |
struct cp_options *x; |
168 |
}; |
169 |
|
170 |
static int |
171 |
copy_xattr_filter (const char *name, struct error_context *ctx) |
172 |
{ |
173 |
struct copy_xattr_context *copy_ctx = (struct copy_xattr_context *) ctx; |
174 |
int action; |
175 |
|
176 |
/* We handle POSIX ACLs separately. */ |
177 |
if (!strcmp(name, "system.posix_acl_access") |
178 |
|| !strcmp(name, "system.posix_acl_default")) |
179 |
return 0; |
180 |
|
181 |
action = attr_copy_action(name, ctx); |
182 |
return (action != ATTR_ACTION_SKIP && |
183 |
(!copy_ctx->x->preserve_mode |
184 |
|| action != ATTR_ACTION_PERMISSIONS)); |
185 |
} |
186 |
#endif /* USE_XATTR */ |
187 |
|
188 |
static bool |
189 |
copy_xattrs (const char *src_path, int source_desc, const char *dst_path, |
190 |
int dest_desc, const struct cp_options *x) |
191 |
{ |
192 |
struct copy_xattr_context copy_xattr_ctx = { |
193 |
{ copy_xattr_error, |
194 |
copy_xattr_quote, |
195 |
copy_xattr_free }, |
196 |
x |
197 |
}; |
198 |
|
199 |
#if USE_XATTR |
200 |
if (x->preserve_xattrs) |
201 |
{ |
202 |
int ret; |
203 |
|
204 |
if (source_desc != -1 && dest_desc != -1) |
205 |
ret = attr_copy_fd(src_path, source_desc, dst_path, dest_desc, |
206 |
copy_xattr_filter, ©_xattr_ctx.ctx); |
207 |
else |
208 |
ret = attr_copy_file (src_path, dst_path, |
209 |
copy_xattr_filter, ©_xattr_ctx.ctx); |
210 |
return ret == 0 || !x->require_preserve; |
211 |
} |
212 |
else |
213 |
return true; |
214 |
#else /* USE_XATTR */ |
215 |
return true; |
216 |
#endif /* USE_XATTR */ |
217 |
} |
218 |
|
121 |
/* Read the contents of the directory SRC_NAME_IN, and recursively |
219 |
/* Read the contents of the directory SRC_NAME_IN, and recursively |
122 |
copy the contents to DST_NAME_IN. NEW_DST is true if |
220 |
copy the contents to DST_NAME_IN. NEW_DST is true if |
123 |
DST_NAME_IN is a directory that was created previously in the |
221 |
DST_NAME_IN is a directory that was created previously in the |
Lines 509-514
copy_reg (char const *src_name, char con
Link Here
|
509 |
} |
607 |
} |
510 |
} |
608 |
} |
511 |
|
609 |
|
|
|
610 |
if (!copy_xattrs (src_name, source_desc, dst_name, dest_desc, x)) |
611 |
return_val = false; |
612 |
|
512 |
set_author (dst_name, dest_desc, src_sb); |
613 |
set_author (dst_name, dest_desc, src_sb); |
513 |
|
614 |
|
514 |
if (x->preserve_mode || x->move_mode) |
615 |
if (x->preserve_mode || x->move_mode) |
Lines 1755-1760
copy_internal (char const *src_name, cha
Link Here
|
1755 |
} |
1856 |
} |
1756 |
} |
1857 |
} |
1757 |
|
1858 |
|
|
|
1859 |
if (!copy_xattrs (src_name, -1, dst_name, -1, x)) |
1860 |
delayed_ok = false; |
1861 |
|
1758 |
set_author (dst_name, -1, &src_sb); |
1862 |
set_author (dst_name, -1, &src_sb); |
1759 |
|
1863 |
|
1760 |
if (x->preserve_mode || x->move_mode) |
1864 |
if (x->preserve_mode || x->move_mode) |
1761 |
-- coreutils-6.11/src/copy.h |
1865 |
++ coreutils-6.11/src/copy.h |
Lines 128-133
struct cp_options
Link Here
|
128 |
bool preserve_mode; |
128 |
bool preserve_mode; |
129 |
bool preserve_timestamps; |
129 |
bool preserve_timestamps; |
130 |
|
130 |
|
|
|
131 |
/* If true, attempt to copy extended attributes. */ |
132 |
bool preserve_xattrs; |
133 |
|
131 |
/* Enabled for mv, and for cp by the --preserve=links option. |
134 |
/* Enabled for mv, and for cp by the --preserve=links option. |
132 |
If true, attempt to preserve in the destination files any |
135 |
If true, attempt to preserve in the destination files any |
133 |
logical hard links between the source files. If used with cp's |
136 |
logical hard links between the source files. If used with cp's |
134 |
-- coreutils-6.11/src/cp.c |
137 |
++ coreutils-6.11/src/cp.c |
Lines 191-197
Mandatory arguments to long options are
Link Here
|
191 |
-p same as --preserve=mode,ownership,timestamps\n\ |
191 |
-p same as --preserve=mode,ownership,timestamps\n\ |
192 |
--preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ |
192 |
--preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ |
193 |
mode,ownership,timestamps), if possible\n\ |
193 |
mode,ownership,timestamps), if possible\n\ |
194 |
additional attributes: context, links, all\n\ |
194 |
additional attributes: context, links, xattrs, all\n\ |
195 |
"), stdout); |
195 |
"), stdout); |
196 |
fputs (_("\ |
196 |
fputs (_("\ |
197 |
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\ |
197 |
--no-preserve=ATTR_LIST don't preserve the specified attributes\n\ |
Lines 724-729
cp_option_init (struct cp_options *x)
Link Here
|
724 |
x->preserve_timestamps = false; |
724 |
x->preserve_timestamps = false; |
725 |
x->preserve_security_context = false; |
725 |
x->preserve_security_context = false; |
726 |
x->require_preserve_context = false; |
726 |
x->require_preserve_context = false; |
|
|
727 |
x->preserve_xattrs = false; |
727 |
|
728 |
|
728 |
x->require_preserve = false; |
729 |
x->require_preserve = false; |
729 |
x->recursive = false; |
730 |
x->recursive = false; |
Lines 752-769
decode_preserve_arg (char const *arg, st
Link Here
|
752 |
PRESERVE_OWNERSHIP, |
753 |
PRESERVE_OWNERSHIP, |
753 |
PRESERVE_LINK, |
754 |
PRESERVE_LINK, |
754 |
PRESERVE_CONTEXT, |
755 |
PRESERVE_CONTEXT, |
|
|
756 |
PRESERVE_XATTRS, |
755 |
PRESERVE_ALL |
757 |
PRESERVE_ALL |
756 |
}; |
758 |
}; |
757 |
static enum File_attribute const preserve_vals[] = |
759 |
static enum File_attribute const preserve_vals[] = |
758 |
{ |
760 |
{ |
759 |
PRESERVE_MODE, PRESERVE_TIMESTAMPS, |
761 |
PRESERVE_MODE, PRESERVE_TIMESTAMPS, |
760 |
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL |
762 |
PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, |
|
|
763 |
PRESERVE_XATTRS, PRESERVE_ALL |
761 |
}; |
764 |
}; |
762 |
/* Valid arguments to the `--preserve' option. */ |
765 |
/* Valid arguments to the `--preserve' option. */ |
763 |
static char const* const preserve_args[] = |
766 |
static char const* const preserve_args[] = |
764 |
{ |
767 |
{ |
765 |
"mode", "timestamps", |
768 |
"mode", "timestamps", |
766 |
"ownership", "links", "context", "all", NULL |
769 |
"ownership", "links", "context", |
|
|
770 |
"xattrs", "all", NULL |
767 |
}; |
771 |
}; |
768 |
ARGMATCH_VERIFY (preserve_args, preserve_vals); |
772 |
ARGMATCH_VERIFY (preserve_args, preserve_vals); |
769 |
|
773 |
|
Lines 799-811
decode_preserve_arg (char const *arg, st
Link Here
|
799 |
x->require_preserve_context = on_off; |
803 |
x->require_preserve_context = on_off; |
800 |
break; |
804 |
break; |
801 |
|
805 |
|
|
|
806 |
case PRESERVE_XATTRS: |
807 |
x->preserve_xattrs = on_off; |
808 |
break; |
809 |
|
802 |
case PRESERVE_ALL: |
810 |
case PRESERVE_ALL: |
803 |
x->preserve_mode = on_off; |
811 |
x->preserve_mode = on_off; |
804 |
x->preserve_timestamps = on_off; |
812 |
x->preserve_timestamps = on_off; |
805 |
x->preserve_ownership = on_off; |
813 |
x->preserve_ownership = on_off; |
806 |
x->preserve_links = on_off; |
814 |
x->preserve_links = on_off; |
807 |
if (selinux_enabled) |
815 |
if (selinux_enabled) |
808 |
x->preserve_security_context = on_off; |
816 |
x->preserve_security_context = on_off; |
|
|
817 |
x->preserve_xattrs = on_off; |
809 |
break; |
818 |
break; |
810 |
|
819 |
|
811 |
default: |
820 |
default: |
812 |
-- coreutils-6.11/src/install.c |
821 |
++ coreutils-6.11/src/install.c |
Lines 154-159
cp_option_init (struct cp_options *x)
Link Here
|
154 |
x->preserve_links = false; |
154 |
x->preserve_links = false; |
155 |
x->preserve_mode = false; |
155 |
x->preserve_mode = false; |
156 |
x->preserve_timestamps = false; |
156 |
x->preserve_timestamps = false; |
|
|
157 |
x->preserve_xattrs = false; |
157 |
x->require_preserve = false; |
158 |
x->require_preserve = false; |
158 |
x->require_preserve_context = false; |
159 |
x->require_preserve_context = false; |
159 |
x->recursive = false; |
160 |
x->recursive = false; |
160 |
-- coreutils-6.11/src/mv.c |
161 |
++ coreutils-6.11/src/mv.c |
Lines 125-130
cp_option_init (struct cp_options *x)
Link Here
|
125 |
x->preserve_mode = true; |
125 |
x->preserve_mode = true; |
126 |
x->preserve_timestamps = true; |
126 |
x->preserve_timestamps = true; |
127 |
x->preserve_security_context = selinux_enabled; |
127 |
x->preserve_security_context = selinux_enabled; |
|
|
128 |
x->preserve_xattrs = true; |
128 |
x->require_preserve = false; /* FIXME: maybe make this an option */ |
129 |
x->require_preserve = false; /* FIXME: maybe make this an option */ |
129 |
x->require_preserve_context = false; |
130 |
x->require_preserve_context = false; |
130 |
x->recursive = true; |
131 |
x->recursive = true; |
131 |
-- coreutils-6.11/doc/coreutils.texi |
132 |
++ coreutils-6.11/doc/coreutils.texi |
Lines 6948-6953
Preserve in the destination files
Link Here
|
6948 |
any links between corresponding source files. |
6948 |
any links between corresponding source files. |
6949 |
@c Give examples illustrating how hard links are preserved. |
6949 |
@c Give examples illustrating how hard links are preserved. |
6950 |
@c Also, show how soft links map to hard links with -L and -H. |
6950 |
@c Also, show how soft links map to hard links with -L and -H. |
|
|
6951 |
@itemx xattrs |
6952 |
Preserve extended attributes. (See /etc/xattr.conf.) |
6951 |
@itemx all |
6953 |
@itemx all |
6952 |
Preserve all file attributes. |
6954 |
Preserve all file attributes. |
6953 |
Equivalent to specifying all of the above. |
6955 |
Equivalent to specifying all of the above. |
6954 |
-- coreutils-6.11/src/Makefile.am |
6956 |
++ coreutils-6.11/src/Makefile.am |
Lines 107-115
Link Here
|
107 |
dir_LDADD += $(LIB_ACL) |
107 |
dir_LDADD += $(LIB_ACL) |
108 |
ls_LDADD += $(LIB_ACL) |
108 |
ls_LDADD += $(LIB_ACL) |
109 |
vdir_LDADD += $(LIB_ACL) |
109 |
vdir_LDADD += $(LIB_ACL) |
110 |
cp_LDADD += $(LIB_ACL) |
110 |
cp_LDADD += $(LIB_ACL) $(LIB_XATTR) |
111 |
mv_LDADD += $(LIB_ACL) |
111 |
mv_LDADD += $(LIB_ACL) $(LIB_XATTR) |
112 |
ginstall_LDADD += $(LIB_ACL) |
112 |
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR) |
113 |
|
113 |
|
114 |
stat_LDADD = $(LDADD) $(LIB_SELINUX) |
114 |
stat_LDADD = $(LDADD) $(LIB_SELINUX) |
115 |
|
115 |
|