* Copyright (C) 2006, 2007 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, 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
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ * with this program; if not, visit the http://fsf.org website.
*/
#include "rsync.h"
extern int am_generator;
extern int read_only;
extern int list_only;
+extern int preserve_xattrs;
extern int checksum_seed;
#define RSYNC_XAL_INITIAL 5
#define RPRE_LEN ((int)sizeof RSYNC_PREFIX - 1)
#define XSTAT_ATTR RSYNC_PREFIX "%stat"
-#define XSTAT_LEN ((int)sizeof XSTAT_ATTR - 1)
typedef struct {
char *datum, *name;
continue;
#endif
- if (am_root < 0 && name_len == XSTAT_LEN + 1
- && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
+ /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+ if (preserve_xattrs < 2 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
continue;
datum_len = name_len; /* Pass extra size to get_xattr_data() */
continue;
}
#endif
- if (am_root < 0 && name_len == XSTAT_LEN + 1
- && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0) {
+ /* No rsync.%FOO attributes are copied w/o 2 -X options. */
+ if (preserve_xattrs < 2 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX)) {
free(ptr);
continue;
}
fst.st_rdev = 0; /* just in case */
if (mode == fmode && fst.st_rdev == rdev
- && fst.st_uid == F_UID(file) && fst.st_gid == F_GID(file)) {
+ && fst.st_uid == F_OWNER(file) && fst.st_gid == F_GROUP(file)) {
/* xst.st_mode will be 0 if there's no current stat xattr */
if (xst.st_mode && sys_lremovexattr(fname, XSTAT_ATTR) < 0) {
rsyserr(FERROR, errno,
}
if (xst.st_mode != fmode || xst.st_rdev != rdev
- || xst.st_uid != F_UID(file) || xst.st_gid != F_GID(file)) {
+ || xst.st_uid != F_OWNER(file) || xst.st_gid != F_GROUP(file)) {
char buf[256];
int len = snprintf(buf, sizeof buf, "%o %u,%u %u:%u",
to_wire_mode(fmode),
(int)major(rdev), (int)minor(rdev),
- (int)F_UID(file), (int)F_GID(file));
+ F_OWNER(file), F_GROUP(file));
if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) {
if (errno == EPERM && S_ISLNK(fst.st_mode))
return 0;