version 1.1.1.2, 2013/10/14 07:51:14
|
version 1.1.1.3, 2016/11/01 09:54:32
|
Line 3
|
Line 3
|
* |
* |
* Copyright (C) 1996 Andrew Tridgell |
* Copyright (C) 1996 Andrew Tridgell |
* Copyright (C) 1996 Paul Mackerras |
* Copyright (C) 1996 Paul Mackerras |
* Copyright (C) 2003-2013 Wayne Davison | * Copyright (C) 2003-2015 Wayne Davison |
* |
* |
* This program is free software; you can redistribute it and/or modify |
* 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 |
* it under the terms of the GNU General Public License as published by |
Line 364 int read_ndx_and_attrs(int f_in, int f_out, int *iflag
|
Line 364 int read_ndx_and_attrs(int f_in, int f_out, int *iflag
|
} |
} |
/* Send all the data we read for this flist to the generator. */ |
/* Send all the data we read for this flist to the generator. */ |
start_flist_forward(ndx); |
start_flist_forward(ndx); |
flist = recv_file_list(f_in); | flist = recv_file_list(f_in, ndx); |
flist->parent_ndx = ndx; |
flist->parent_ndx = ndx; |
stop_flist_forward(); |
stop_flist_forward(); |
} |
} |
Line 489 int set_file_attrs(const char *fname, struct file_stru
|
Line 489 int set_file_attrs(const char *fname, struct file_stru
|
get_acl(fname, sxp); |
get_acl(fname, sxp); |
#endif |
#endif |
|
|
#ifdef SUPPORT_XATTRS |
|
if (am_root < 0) |
|
set_stat_xattr(fname, file, new_mode); |
|
if (preserve_xattrs && fnamecmp) |
|
set_xattr(fname, file, fnamecmp, sxp); |
|
#endif |
|
|
|
if (!preserve_times |
|
|| (!(preserve_times & PRESERVE_DIR_TIMES) && S_ISDIR(sxp->st.st_mode)) |
|
|| (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode))) |
|
flags |= ATTRS_SKIP_MTIME; |
|
if (!(flags & ATTRS_SKIP_MTIME) |
|
&& cmp_time(sxp->st.st_mtime, file->modtime) != 0) { |
|
int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode); |
|
if (ret < 0) { |
|
rsyserr(FERROR_XFER, errno, "failed to set times on %s", |
|
full_fname(fname)); |
|
goto cleanup; |
|
} |
|
if (ret == 0) /* ret == 1 if symlink could not be set */ |
|
updated = 1; |
|
else |
|
file->flags |= FLAG_TIME_FAILED; |
|
} |
|
|
|
change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file); |
change_uid = am_root && uid_ndx && sxp->st.st_uid != (uid_t)F_OWNER(file); |
change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP) |
change_gid = gid_ndx && !(file->flags & FLAG_SKIP_GROUP) |
&& sxp->st.st_gid != (gid_t)F_GROUP(file); |
&& sxp->st.st_gid != (gid_t)F_GROUP(file); |
Line 561 int set_file_attrs(const char *fname, struct file_stru
|
Line 536 int set_file_attrs(const char *fname, struct file_stru
|
updated = 1; |
updated = 1; |
} |
} |
|
|
#ifdef SUPPORT_ACLS | #ifdef SUPPORT_XATTRS |
/* It's OK to call set_acl() now, even for a dir, as the generator | if (am_root < 0) |
* will enable owner-writability using chmod, if necessary. | set_stat_xattr(fname, file, new_mode); |
* | if (preserve_xattrs && fnamecmp) |
* If set_acl() changes permission bits in the process of setting | set_xattr(fname, file, fnamecmp, sxp); |
* an access ACL, it changes sxp->st.st_mode so we know whether we | #endif |
* need to chmod(). */ | |
if (preserve_acls && !S_ISLNK(new_mode)) { | if (!preserve_times |
if (set_acl(fname, file, sxp, new_mode) > 0) | || (!(preserve_times & PRESERVE_DIR_TIMES) && S_ISDIR(sxp->st.st_mode)) |
| || (!(preserve_times & PRESERVE_LINK_TIMES) && S_ISLNK(sxp->st.st_mode))) |
| flags |= ATTRS_SKIP_MTIME; |
| if (!(flags & ATTRS_SKIP_MTIME) |
| && (sxp->st.st_mtime != file->modtime |
| #ifdef ST_MTIME_NSEC |
| || (NSEC_BUMP(file) && (uint32)sxp->st.ST_MTIME_NSEC != F_MOD_NSEC(file)) |
| #endif |
| )) { |
| int ret = set_modtime(fname, file->modtime, F_MOD_NSEC(file), sxp->st.st_mode); |
| if (ret < 0) { |
| rsyserr(FERROR_XFER, errno, "failed to set times on %s", |
| full_fname(fname)); |
| goto cleanup; |
| } |
| if (ret == 0) /* ret == 1 if symlink could not be set */ |
updated = 1; |
updated = 1; |
|
else |
|
file->flags |= FLAG_TIME_FAILED; |
} |
} |
#endif |
|
|
|
#ifdef HAVE_CHMOD |
#ifdef HAVE_CHMOD |
if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) { |
if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) { |
Line 588 int set_file_attrs(const char *fname, struct file_stru
|
Line 579 int set_file_attrs(const char *fname, struct file_stru
|
} |
} |
#endif |
#endif |
|
|
|
#ifdef SUPPORT_ACLS |
|
/* It's OK to call set_acl() now, even for a dir, as the generator |
|
* will enable owner-writability using chmod, if necessary. |
|
* |
|
* If set_acl() changes permission bits in the process of setting |
|
* an access ACL, it changes sxp->st.st_mode so we know whether we |
|
* need to chmod(). */ |
|
if (preserve_acls && !S_ISLNK(new_mode)) { |
|
if (set_acl(fname, file, sxp, new_mode) > 0) |
|
updated = 1; |
|
} |
|
#endif |
|
|
if (INFO_GTE(NAME, 2) && flags & ATTRS_REPORT) { |
if (INFO_GTE(NAME, 2) && flags & ATTRS_REPORT) { |
if (updated) |
if (updated) |
rprintf(FCLIENT, "%s\n", fname); |
rprintf(FCLIENT, "%s\n", fname); |
Line 601 int set_file_attrs(const char *fname, struct file_stru
|
Line 605 int set_file_attrs(const char *fname, struct file_stru
|
} |
} |
|
|
/* This is only called for SIGINT, SIGHUP, and SIGTERM. */ |
/* This is only called for SIGINT, SIGHUP, and SIGTERM. */ |
RETSIGTYPE sig_int(int sig_num) | void sig_int(int sig_num) |
{ |
{ |
/* KLUGE: if the user hits Ctrl-C while ssh is prompting |
/* KLUGE: if the user hits Ctrl-C while ssh is prompting |
* for a password, then our cleanup's sending of a SIGUSR1 |
* for a password, then our cleanup's sending of a SIGUSR1 |