Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed a problem with --fake-super not getting the fully tweaked new_mode
[rsync/rsync.git]
/
xattrs.c
diff --git
a/xattrs.c
b/xattrs.c
index
23b5faa
..
5e80829
100644
(file)
--- a/
xattrs.c
+++ b/
xattrs.c
@@
-132,7
+132,7
@@
static ssize_t get_xattr_names(const char *fname)
if (errno == ERANGE) {
list_len = sys_llistxattr(fname, NULL, 0);
if (list_len < 0) {
if (errno == ERANGE) {
list_len = sys_llistxattr(fname, NULL, 0);
if (list_len < 0) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"get_xattr_names: llistxattr(\"%s\",0) failed",
fname);
return -1;
"get_xattr_names: llistxattr(\"%s\",0) failed",
fname);
return -1;
@@
-148,7
+148,7
@@
static ssize_t get_xattr_names(const char *fname)
return list_len;
}
return list_len;
}
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"get_xattr_names: llistxattr(\"%s\",%ld) failed",
fname, (long)namebuf_len);
return -1;
"get_xattr_names: llistxattr(\"%s\",%ld) failed",
fname, (long)namebuf_len);
return -1;
@@
-169,7
+169,7
@@
static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
if (datum_len == (size_t)-1) {
if (errno == ENOTSUP || no_missing_error)
return NULL;
if (datum_len == (size_t)-1) {
if (errno == ENOTSUP || no_missing_error)
return NULL;
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"get_xattr_data: lgetxattr(\"%s\",\"%s\",0) failed",
fname, name);
return NULL;
"get_xattr_data: lgetxattr(\"%s\",\"%s\",0) failed",
fname, name);
return NULL;
@@
-185,11
+185,11
@@
static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr
size_t len = sys_lgetxattr(fname, name, ptr, datum_len);
if (len != datum_len) {
if (len == (size_t)-1) {
size_t len = sys_lgetxattr(fname, name, ptr, datum_len);
if (len != datum_len) {
if (len == (size_t)-1) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)"
" failed", fname, name, (long)datum_len);
} else {
"get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)"
" failed", fname, name, (long)datum_len);
} else {
- rprintf(FERROR,
+ rprintf(FERROR
_XFER
,
"get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)"
" returned %ld\n", fname, name,
(long)datum_len, (long)len);
"get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)"
" returned %ld\n", fname, name,
(long)datum_len, (long)len);
@@
-230,7
+230,7
@@
static int rsync_xal_get(const char *fname, item_list *xalp)
#endif
/* No rsync.%FOO attributes are copied w/o 2 -X options. */
#endif
/* No rsync.%FOO attributes are copied w/o 2 -X options. */
- if (preserve_xattrs < 2 && name_len > RPRE_LEN
+ if (
am_sender &&
preserve_xattrs < 2 && name_len > RPRE_LEN
&& name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
continue;
&& name[RPRE_LEN] == '%' && HAS_PREFIX(name, RSYNC_PREFIX))
continue;
@@
-523,12
+523,12
@@
void xattr_clear_locals(struct file_struct *file)
* any needed xattrs with a flag that lets us know they need to be sent to
* the receiver. When called by the receiver, reads the sent data and
* stores it in place of its checksum. */
* any needed xattrs with a flag that lets us know they need to be sent to
* the receiver. When called by the receiver, reads the sent data and
* stores it in place of its checksum. */
-
void
recv_xattr_request(struct file_struct *file, int f_in)
+
int
recv_xattr_request(struct file_struct *file, int f_in)
{
item_list *lst = rsync_xal_l.items;
char *old_datum, *name;
rsync_xa *rxa;
{
item_list *lst = rsync_xal_l.items;
char *old_datum, *name;
rsync_xa *rxa;
- int rel_pos, cnt;
+ int rel_pos, cnt
, got_xattr_data = 0
;
if (F_XATTR(file) < 0) {
rprintf(FERROR, "recv_xattr_request: internal data error!\n");
if (F_XATTR(file) < 0) {
rprintf(FERROR, "recv_xattr_request: internal data error!\n");
@@
-566,7
+566,10
@@
void recv_xattr_request(struct file_struct *file, int f_in)
rxa->name = name;
free(old_datum);
read_buf(f_in, rxa->datum, rxa->datum_len);
rxa->name = name;
free(old_datum);
read_buf(f_in, rxa->datum, rxa->datum_len);
+ got_xattr_data = 1;
}
}
+
+ return got_xattr_data;
}
/* ------------------------------------------------------------------------- */
}
/* ------------------------------------------------------------------------- */
@@
-722,7
+725,7
@@
static int rsync_xal_set(const char *fname, item_list *xalp,
if (fname == fnamecmp)
; /* Value is already set when identical */
else if (sys_lsetxattr(fname, name, ptr, len) < 0) {
if (fname == fnamecmp)
; /* Value is already set when identical */
else if (sys_lsetxattr(fname, name, ptr, len) < 0) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
"rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
@@
-745,7
+748,7
@@
static int rsync_xal_set(const char *fname, item_list *xalp,
}
if (sys_lsetxattr(fname, name, rxas[i].datum, rxas[i].datum_len) < 0) {
}
if (sys_lsetxattr(fname, name, rxas[i].datum, rxas[i].datum_len) < 0) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
"rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
@@
-765,6
+768,9
@@
static int rsync_xal_set(const char *fname, item_list *xalp,
: !HAS_PREFIX(name, USER_PREFIX))
continue;
#endif
: !HAS_PREFIX(name, USER_PREFIX))
continue;
#endif
+ if (am_root < 0 && name_len > RPRE_LEN
+ && name[RPRE_LEN] == '%' && strcmp(name, XSTAT_ATTR) == 0)
+ continue;
for (i = 0; i < xalp->count; i++) {
if (strcmp(name, rxas[i].name) == 0)
for (i = 0; i < xalp->count; i++) {
if (strcmp(name, rxas[i].name) == 0)
@@
-772,7
+778,7
@@
static int rsync_xal_set(const char *fname, item_list *xalp,
}
if (i == xalp->count) {
if (sys_lremovexattr(fname, name) < 0) {
}
if (i == xalp->count) {
if (sys_lremovexattr(fname, name) < 0) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"rsync_xal_clear: lremovexattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
"rsync_xal_clear: lremovexattr(\"%s\",\"%s\") failed",
fname, name);
ret = -1;
@@
-815,7
+821,7
@@
int set_xattr_acl(const char *fname, int is_access_acl, const char *buf, size_t
{
const char *name = is_access_acl ? XACC_ACL_ATTR : XDEF_ACL_ATTR;
if (sys_lsetxattr(fname, name, buf, buf_len) < 0) {
{
const char *name = is_access_acl ? XACC_ACL_ATTR : XDEF_ACL_ATTR;
if (sys_lsetxattr(fname, name, buf, buf_len) < 0) {
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"set_xattr_acl: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
return -1;
"set_xattr_acl: lsetxattr(\"%s\",\"%s\") failed",
fname, name);
return -1;
@@
-860,7
+866,7
@@
int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst
xst->st_gid = 0;
return 0;
}
xst->st_gid = 0;
return 0;
}
- rsyserr(FERROR, errno, "failed to read xattr %s for %s",
+ rsyserr(FERROR
_XFER
, errno, "failed to read xattr %s for %s",
XSTAT_ATTR, full_fname(fname));
return -1;
}
XSTAT_ATTR, full_fname(fname));
return -1;
}
@@
-881,7
+887,7
@@
int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst
return 0;
}
return 0;
}
-int set_stat_xattr(const char *fname, struct file_struct *file)
+int set_stat_xattr(const char *fname, struct file_struct *file
, mode_t new_mode
)
{
STRUCT_STAT fst, xst;
dev_t rdev;
{
STRUCT_STAT fst, xst;
dev_t rdev;
@@
-891,19
+897,19
@@
int set_stat_xattr(const char *fname, struct file_struct *file)
return 0;
if (read_only || list_only) {
return 0;
if (read_only || list_only) {
- rsyserr(FERROR, EROFS, "failed to write xattr %s for %s",
+ rsyserr(FERROR
_XFER
, EROFS, "failed to write xattr %s for %s",
XSTAT_ATTR, full_fname(fname));
return -1;
}
if (x_lstat(fname, &fst, &xst) < 0) {
XSTAT_ATTR, full_fname(fname));
return -1;
}
if (x_lstat(fname, &fst, &xst) < 0) {
- rsyserr(FERROR, errno, "failed to re-stat %s",
+ rsyserr(FERROR
_XFER
, errno, "failed to re-stat %s",
full_fname(fname));
return -1;
}
fst.st_mode &= (_S_IFMT | CHMOD_BITS);
full_fname(fname));
return -1;
}
fst.st_mode &= (_S_IFMT | CHMOD_BITS);
- fmode =
file->
mode & (_S_IFMT | CHMOD_BITS);
+ fmode =
new_
mode & (_S_IFMT | CHMOD_BITS);
if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) {
uint32 *devp = F_RDEV_P(file);
if (IS_DEVICE(fmode) || IS_SPECIAL(fmode)) {
uint32 *devp = F_RDEV_P(file);
@@
-923,7
+929,7
@@
int set_stat_xattr(const char *fname, struct file_struct *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) {
&& 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,
+ rsyserr(FERROR
_XFER
, errno,
"delete of stat xattr failed for %s",
full_fname(fname));
return -1;
"delete of stat xattr failed for %s",
full_fname(fname));
return -1;
@@
-941,7
+947,7
@@
int set_stat_xattr(const char *fname, struct file_struct *file)
if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) {
if (errno == EPERM && S_ISLNK(fst.st_mode))
return 0;
if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) {
if (errno == EPERM && S_ISLNK(fst.st_mode))
return 0;
- rsyserr(FERROR, errno,
+ rsyserr(FERROR
_XFER
, errno,
"failed to write xattr %s for %s",
XSTAT_ATTR, full_fname(fname));
return -1;
"failed to write xattr %s for %s",
XSTAT_ATTR, full_fname(fname));
return -1;