X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/d3d07a5e860f1cde0e234ec7a1aff7111a2c514f..e9489cd6cb380b30727bd3d074eacc59abca080e:/rsync.c diff --git a/rsync.c b/rsync.c index 827e8d89..9921da04 100644 --- a/rsync.c +++ b/rsync.c @@ -41,7 +41,6 @@ extern int am_generator; extern int am_starting_up; extern int allow_8bit_chars; extern int protocol_version; -extern int receiver_symlink_times; extern int uid_ndx; extern int gid_ndx; extern int inc_recurse; @@ -206,6 +205,42 @@ int iconvbufs(iconv_t ic, xbuf *in, xbuf *out, int flags) } #endif +void send_protected_args(int fd, char *args[]) +{ + int i; +#ifdef ICONV_OPTION + int convert = ic_send != (iconv_t)-1; + xbuf outbuf, inbuf; + + if (convert) + alloc_xbuf(&outbuf, 1024); +#endif + + for (i = 0; args[i]; i++) {} /* find first NULL */ + args[i] = "rsync"; /* set a new arg0 */ + if (verbose > 1) + print_child_argv("protected args:", args + i + 1); + do { +#ifdef ICONV_OPTION + if (convert) { + INIT_XBUF_STRLEN(inbuf, args[i]); + iconvbufs(ic_send, &inbuf, &outbuf, + ICB_EXPAND_OUT | ICB_INCLUDE_BAD | ICB_INCLUDE_INCOMPLETE); + outbuf.buf[outbuf.len] = '\0'; + write_buf(fd, outbuf.buf, outbuf.len + 1); + outbuf.len = 0; + } else +#endif + write_buf(fd, args[i], strlen(args[i]) + 1); + } while (args[++i]); + write_byte(fd, 0); + +#ifdef ICONV_OPTION + if (convert) + free(outbuf.buf); +#endif +} + int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, char *buf, int *len_ptr) { @@ -400,7 +435,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, } if (ret == 0) /* ret == 1 if symlink could not be set */ updated = 1; - else if (receiver_symlink_times) + else file->flags |= FLAG_TIME_FAILED; } @@ -526,8 +561,11 @@ int finish_transfer(const char *fname, const char *fnametmp, goto do_set_file_attrs; } - if (make_backups > 0 && overwriting_basis && !make_backup(fname)) - return 1; + if (make_backups > 0 && overwriting_basis) { + if (!make_backup(fname)) + return 1; + fnamecmp = get_backup_name(fname); + } /* Change permissions before putting the file into place. */ set_file_attrs(fnametmp, file, NULL, fnamecmp,