From 46f8b6da280ab62338c90d9ee6eb7f831ba6cf0f Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 23 2020 06:11:08 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/acls.c b/acls.c index 24e8cf6..8d97df6 100644 --- a/acls.c +++ b/acls.c @@ -31,7 +31,6 @@ extern int list_only; extern int orig_umask; extern int numeric_ids; extern int inc_recurse; -extern int protocol_version; extern int preserve_devices; extern int preserve_specials; @@ -113,18 +112,6 @@ static const char *str_acl_type(SMB_ACL_TYPE_T type) return "unknown ACL type!"; } -#define OTHER_TYPE(t) (SMB_ACL_TYPE_ACCESS+SMB_ACL_TYPE_DEFAULT-(t)) -#define BUMP_TYPE(t) ((t = OTHER_TYPE(t)) == SMB_ACL_TYPE_DEFAULT) - -static int old_count_racl_entries(const rsync_acl *racl) -{ - return racl->names.count - + (racl->user_obj != NO_ENTRY) - + (racl->group_obj != NO_ENTRY) - + (racl->mask_obj != NO_ENTRY) - + (racl->other_obj != NO_ENTRY); -} - static int calc_sacl_entries(const rsync_acl *racl) { /* A System ACL always gets user/group/other permission entries. */ @@ -594,96 +581,6 @@ int get_acl(const char *fname, stat_x *sxp) return 0; } -/* === OLD Send functions === */ - -/* Send the ida list over the file descriptor. */ -static void old_send_ida_entries(int f, const ida_entries *idal, char tag_char) -{ - id_access *ida; - size_t count = idal->count; - for (ida = idal->idas; count--; ida++) { - if (tag_char == 'U') { - if (!(ida->access & NAME_IS_USER)) - continue; - add_uid(ida->id); - } else { - if (ida->access & NAME_IS_USER) - continue; - add_gid(ida->id); - } - write_byte(f, tag_char); - write_byte(f, ida->access); - write_int(f, ida->id); - } -} - -/* Send an rsync ACL over the file descriptor. */ -static void old_send_rsync_acl(int f, const rsync_acl *racl) -{ - size_t count = old_count_racl_entries(racl); - write_int(f, count); - if (racl->user_obj != NO_ENTRY) { - write_byte(f, 'u'); - write_byte(f, racl->user_obj); - } - old_send_ida_entries(f, &racl->names, 'U'); - if (racl->group_obj != NO_ENTRY) { - write_byte(f, 'g'); - write_byte(f, racl->group_obj); - } - old_send_ida_entries(f, &racl->names, 'G'); - if (racl->mask_obj != NO_ENTRY) { - write_byte(f, 'm'); - write_byte(f, racl->mask_obj); - } - if (racl->other_obj != NO_ENTRY) { - write_byte(f, 'o'); - write_byte(f, racl->other_obj); - } -} - -/* Send the ACL from the stat_x structure down the indicated file descriptor. - * This also frees the ACL data. */ -void old_send_acl(stat_x *sxp, int f) -{ - SMB_ACL_TYPE_T type; - rsync_acl *racl, *new_racl; - item_list *racl_list; - int ndx; - - type = SMB_ACL_TYPE_ACCESS; - racl = sxp->acc_acl; - racl_list = &access_acl_list; - do { - if (!racl) { - racl = new(rsync_acl); - if (!racl) - out_of_memory("send_acl"); - *racl = empty_rsync_acl; - if (type == SMB_ACL_TYPE_ACCESS) { - rsync_acl_fake_perms(racl, sxp->st.st_mode); - sxp->acc_acl = racl; - } else - sxp->def_acl = racl; - } - - if ((ndx = find_matching_rsync_acl(racl, type, racl_list)) != -1) { - write_byte(f, type == SMB_ACL_TYPE_ACCESS ? 'a' : 'd'); - write_int(f, ndx); - } else { - new_racl = EXPAND_ITEM_LIST(racl_list, rsync_acl, 1000); - write_byte(f, type == SMB_ACL_TYPE_ACCESS ? 'A' : 'D'); - old_send_rsync_acl(f, racl); - *new_racl = *racl; - *racl = empty_rsync_acl; - } - racl = sxp->def_acl; - racl_list = &default_acl_list; - } while (BUMP_TYPE(type) && S_ISDIR(sxp->st.st_mode)); - - free_acl(sxp); -} - /* === Send functions === */ /* Send the ida list over the file descriptor. */ @@ -759,11 +656,6 @@ static void send_rsync_acl(int f, rsync_acl *racl, SMB_ACL_TYPE_T type, * This also frees the ACL data. */ void send_acl(int f, stat_x *sxp) { - if (protocol_version < 30) { - old_send_acl(sxp, f); - return; - } - if (!sxp->acc_acl) { sxp->acc_acl = create_racl(); rsync_acl_fake_perms(sxp->acc_acl, sxp->st.st_mode); @@ -781,160 +673,6 @@ void send_acl(int f, stat_x *sxp) } } -/* === OLD Receive functions */ - -static void old_recv_rsync_acl(rsync_acl *racl, int f) -{ - static item_list temp_ida_list = EMPTY_ITEM_LIST; - SMB_ACL_TAG_T tag_type = 0; - uchar computed_mask_bits = 0; - id_access *ida; - size_t count; - - if (!(count = read_int(f))) - return; - - while (count--) { - char tag = read_byte(f); - uchar access = read_byte(f); - if (access & ~ (4 | 2 | 1)) { - rprintf(FERROR, "old_recv_rsync_acl: bogus permset %o\n", - access); - exit_cleanup(RERR_STREAMIO); - } - switch (tag) { - case 'u': - if (racl->user_obj != NO_ENTRY) { - rprintf(FERROR, "old_recv_rsync_acl: error: duplicate USER_OBJ entry\n"); - exit_cleanup(RERR_STREAMIO); - } - racl->user_obj = access; - continue; - case 'U': - tag_type = SMB_ACL_USER; - break; - case 'g': - if (racl->group_obj != NO_ENTRY) { - rprintf(FERROR, "old_recv_rsync_acl: error: duplicate GROUP_OBJ entry\n"); - exit_cleanup(RERR_STREAMIO); - } - racl->group_obj = access; - continue; - case 'G': - tag_type = SMB_ACL_GROUP; - break; - case 'm': - if (racl->mask_obj != NO_ENTRY) { - rprintf(FERROR, "old_recv_rsync_acl: error: duplicate MASK entry\n"); - exit_cleanup(RERR_STREAMIO); - } - racl->mask_obj = access; - continue; - case 'o': - if (racl->other_obj != NO_ENTRY) { - rprintf(FERROR, "old_recv_rsync_acl: error: duplicate OTHER entry\n"); - exit_cleanup(RERR_STREAMIO); - } - racl->other_obj = access; - continue; - default: - rprintf(FERROR, "old_recv_rsync_acl: unknown tag %c\n", - tag); - exit_cleanup(RERR_STREAMIO); - } - ida = EXPAND_ITEM_LIST(&temp_ida_list, id_access, -10); - ida->access = access | (tag_type == SMB_ACL_USER ? NAME_IS_USER : 0); - ida->id = read_int(f); - computed_mask_bits |= access; - } - - /* Transfer the count id_access items out of the temp_ida_list - * into the names ida_entries list in racl. */ - if (temp_ida_list.count) { -#ifdef SMB_ACL_NEED_SORT - if (temp_ida_list.count > 1) { - qsort(temp_ida_list.items, temp_ida_list.count, - sizeof (id_access), id_access_sorter); - } -#endif - if (!(racl->names.idas = new_array(id_access, temp_ida_list.count))) - out_of_memory("unpack_smb_acl"); - memcpy(racl->names.idas, temp_ida_list.items, - temp_ida_list.count * sizeof (id_access)); - } else - racl->names.idas = NULL; - - racl->names.count = temp_ida_list.count; - - /* Truncate the temporary list now that its idas have been saved. */ - temp_ida_list.count = 0; - - if (!racl->names.count) { - /* If we received a superfluous mask, throw it away. */ - if (racl->mask_obj != NO_ENTRY) { - /* Mask off the group perms with it first. */ - racl->group_obj &= racl->mask_obj | NO_ENTRY; - racl->mask_obj = NO_ENTRY; - } - } else if (racl->mask_obj == NO_ENTRY) /* Must be non-empty with lists. */ - racl->mask_obj = (computed_mask_bits | racl->group_obj) & 7; -} - -/* Receive the ACL info the sender has included for this file-list entry. */ -void old_recv_acl(struct file_struct *file, int f) -{ - SMB_ACL_TYPE_T type; - item_list *racl_list; - - if (S_ISLNK(file->mode)) - return; - - type = SMB_ACL_TYPE_ACCESS; - racl_list = &access_acl_list; - do { - char tag = read_byte(f); - int ndx; - - if (tag == 'A' || tag == 'a') { - if (type != SMB_ACL_TYPE_ACCESS) { - rprintf(FERROR, "receive_acl %s: duplicate access ACL\n", - f_name(file, NULL)); - exit_cleanup(RERR_STREAMIO); - } - } else if (tag == 'D' || tag == 'd') { - if (type == SMB_ACL_TYPE_ACCESS) { - rprintf(FERROR, "receive_acl %s: expecting access ACL; got default\n", - f_name(file, NULL)); - exit_cleanup(RERR_STREAMIO); - } - } else { - rprintf(FERROR, "receive_acl %s: unknown ACL type tag: %c\n", - f_name(file, NULL), tag); - exit_cleanup(RERR_STREAMIO); - } - if (tag == 'A' || tag == 'D') { - acl_duo *duo_item; - ndx = racl_list->count; - duo_item = EXPAND_ITEM_LIST(racl_list, acl_duo, 1000); - duo_item->racl = empty_rsync_acl; - old_recv_rsync_acl(&duo_item->racl, f); - duo_item->sacl = NULL; - } else { - ndx = read_int(f); - if (ndx < 0 || (size_t)ndx >= racl_list->count) { - rprintf(FERROR, "receive_acl %s: %s ACL index %d out of range\n", - f_name(file, NULL), str_acl_type(type), ndx); - exit_cleanup(RERR_STREAMIO); - } - } - if (type == SMB_ACL_TYPE_ACCESS) - F_ACL(file) = ndx; - else - F_DIR_DEFACL(file) = ndx; - racl_list = &default_acl_list; - } while (BUMP_TYPE(type) && S_ISDIR(file->mode)); -} - /* === Receive functions === */ static uint32 recv_acl_access(int f, uchar *name_follows_ptr) @@ -1056,11 +794,6 @@ static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type, mode /* Receive the ACL info the sender has included for this file-list entry. */ void receive_acl(int f, struct file_struct *file) { - if (protocol_version < 30) { - old_recv_acl(file, f); - return; - } - F_ACL(file) = recv_rsync_acl(f, &access_acl_list, SMB_ACL_TYPE_ACCESS, file->mode); if (S_ISDIR(file->mode)) diff --git a/batch.c b/batch.c index 1ab66e9..21c632f 100644 --- a/batch.c +++ b/batch.c @@ -216,7 +216,7 @@ static void write_filter_rules(int fd) void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt) { int fd, i, len, err = 0; - char *p, *p2, filename[MAXPATHLEN]; + char *p, filename[MAXPATHLEN]; stringjoin(filename, sizeof filename, batch_name, ".sh", NULL); @@ -267,7 +267,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt) err = 1; } } - if (!(p = check_for_hostspec(argv[argc - 1], &p2, &i))) + if (!(p = check_for_hostspec(argv[argc - 1], &p, &i))) p = argv[argc - 1]; if (write(fd, " ${1:-", 6) != 6 || write_arg(fd, p) < 0) diff --git a/compat.c b/compat.c index 627c520..8d755c6 100644 --- a/compat.c +++ b/compat.c @@ -205,6 +205,20 @@ void setup_protocol(int f_out,int f_in) if (protocol_version < 30) { if (append_mode == 1) append_mode = 2; + if (preserve_acls && !local_server) { + rprintf(FERROR, + "--acls requires protocol 30 or higher" + " (negotiated %d).\n", + protocol_version); + exit_cleanup(RERR_PROTOCOL); + } + if (preserve_xattrs && !local_server) { + rprintf(FERROR, + "--xattrs requires protocol 30 or higher" + " (negotiated %d).\n", + protocol_version); + exit_cleanup(RERR_PROTOCOL); + } } if (delete_mode && !(delete_before+delete_during+delete_after)) { diff --git a/generator.c b/generator.c index 578669f..a112da6 100644 --- a/generator.c +++ b/generator.c @@ -39,7 +39,6 @@ extern int preserve_acls; extern int preserve_xattrs; extern int preserve_links; extern int preserve_devices; -extern int copy_devices; extern int preserve_specials; extern int preserve_hard_links; extern int preserve_executability; @@ -1272,16 +1271,10 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, && (*dn != '.' || dn[1]) /* Avoid an issue with --relative and the "." dir. */ && (!prior_dir_file || strcmp(dn, f_name(prior_dir_file, NULL)) != 0) && flist_find_name(cur_flist, dn, 1) < 0) { - /* The --delete-missing-args option can actually put invalid entries into - * the file list, so if that option was specified, we'll just complain about - * it and allow it. */ - if (missing_args == 2 && file->mode == 0) - rprintf(FERROR, "WARNING: parent dir is absent in the file list: %s\n", dn); - else { - rprintf(FERROR, "ABORTING due to invalid path from sender: %s/%s\n", - dn, file->basename); - exit_cleanup(RERR_PROTOCOL); - } + rprintf(FERROR, + "ABORTING due to invalid path from sender: %s/%s\n", + dn, file->basename); + exit_cleanup(RERR_PROTOCOL); } if (relative_paths && !implied_dirs && do_stat(dn, &sx.st) < 0) { @@ -1384,7 +1377,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, added_perms = 0; if (is_dir < 0) { if (!(preserve_times & PRESERVE_DIR_TIMES)) - goto cleanup; + return; /* In inc_recurse mode we want to make sure any missing * directories get created while we're still processing * the parent dir (which allows us to touch the parent @@ -1526,7 +1519,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, "ignoring unsafe symlink \"%s\" -> \"%s\"\n", fname, sl); } - goto cleanup; + return; } if (statret == 0) { char lnk[MAXPATHLEN]; @@ -1664,7 +1657,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, goto cleanup; } - if (!(S_ISREG(file->mode) || (copy_devices && IS_DEVICE(file->mode)))) { + if (!S_ISREG(file->mode)) { if (solo_file) fname = f_name(file, NULL); rprintf(FINFO, "skipping non-regular file \"%s\"\n", fname); diff --git a/io.c b/io.c index 59105ba..c04dbd5 100644 --- a/io.c +++ b/io.c @@ -954,17 +954,8 @@ int send_msg(enum msgcode code, const char *buf, size_t len, int convert) } else #endif needed = len + 4 + 3; - if (iobuf.msg.len + needed > iobuf.msg.size) { - if (!am_receiver) - perform_io(needed, PIO_NEED_MSGROOM); - else { /* We allow the receiver to increase their iobuf.msg size to avoid a deadlock. */ - size_t old_size = iobuf.msg.size; - restore_iobuf_size(&iobuf.msg); - realloc_xbuf(&iobuf.msg, iobuf.msg.size * 2); - if (iobuf.msg.pos + iobuf.msg.len > old_size) - memcpy(iobuf.msg.buf + old_size, iobuf.msg.buf, iobuf.msg.pos + iobuf.msg.len - old_size); - } - } + if (iobuf.msg.len + needed > iobuf.msg.size) + perform_io(needed, PIO_NEED_MSGROOM); pos = iobuf.msg.pos + iobuf.msg.len; /* Must be set after any flushing. */ if (pos >= iobuf.msg.size) @@ -1185,7 +1176,7 @@ int read_line(int fd, char *buf, size_t bufsiz, int flags) #ifdef ICONV_OPTION if (flags & RL_CONVERT && iconv_buf.size < bufsiz) - realloc_xbuf(&iconv_buf, ROUND_UP_1024(bufsiz) + 1024); + realloc_xbuf(&iconv_buf, bufsiz + 1024); #endif start: diff --git a/lib/pool_alloc.c b/lib/pool_alloc.c index a70a3f1..5856d59 100644 --- a/lib/pool_alloc.c +++ b/lib/pool_alloc.c @@ -49,15 +49,15 @@ pool_create(size_t size, size_t quantum, void (*bomb)(const char *), int flags) { struct alloc_pool *pool; + if (!(pool = new0(struct alloc_pool))) + return NULL; + if ((MINALIGN & (MINALIGN - 1)) != 0) { if (bomb) (*bomb)("Compiler error: MINALIGN is not a power of 2\n"); return NULL; } - if (!(pool = new0(struct alloc_pool))) - return NULL; - if (!size) size = POOL_DEF_EXTENT; if (!quantum) diff --git a/log.c b/log.c index 1215cc0..6143349 100644 --- a/log.c +++ b/log.c @@ -378,13 +378,10 @@ output_msg: filtered_fwrite(f, convbuf, outbuf.len, 0); outbuf.len = 0; } - /* Log one byte of illegal/incomplete sequence and continue with - * the next character. Check that the buffer is non-empty for the - * sake of robustness. */ - if ((ierrno == EILSEQ || ierrno == EINVAL) && inbuf.len) { - fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++)); - inbuf.len--; - } + if (!ierrno || ierrno == E2BIG) + continue; + fprintf(f, "\\#%03o", CVAL(inbuf.buf, inbuf.pos++)); + inbuf.len--; } } else #endif diff --git a/options.c b/options.c index 195672e..1c5b42d 100644 --- a/options.c +++ b/options.c @@ -50,7 +50,6 @@ int append_mode = 0; int keep_dirlinks = 0; int copy_dirlinks = 0; int copy_links = 0; -int copy_devices = 0; int preserve_links = 0; int preserve_hard_links = 0; int preserve_acls = 0; @@ -706,7 +705,6 @@ void usage(enum logcode F) rprintf(F," -o, --owner preserve owner (super-user only)\n"); rprintf(F," -g, --group preserve group\n"); rprintf(F," --devices preserve device files (super-user only)\n"); - rprintf(F," --copy-devices copy device contents as regular file\n"); rprintf(F," --specials preserve special files\n"); rprintf(F," -D same as --devices --specials\n"); rprintf(F," -t, --times preserve modification times\n"); @@ -889,7 +887,6 @@ static struct poptOption long_options[] = { {"no-D", 0, POPT_ARG_NONE, 0, OPT_NO_D, 0, 0 }, {"devices", 0, POPT_ARG_VAL, &preserve_devices, 1, 0, 0 }, {"no-devices", 0, POPT_ARG_VAL, &preserve_devices, 0, 0, 0 }, - {"copy-devices", 0, POPT_ARG_NONE, ©_devices, 0, 0, 0 }, {"specials", 0, POPT_ARG_VAL, &preserve_specials, 1, 0, 0 }, {"no-specials", 0, POPT_ARG_VAL, &preserve_specials, 0, 0, 0 }, {"links", 'l', POPT_ARG_VAL, &preserve_links, 1, 0, 0 }, @@ -2800,9 +2797,6 @@ void server_options(char **args, int *argc_p) else if (remove_source_files) args[ac++] = "--remove-sent-files"; - if (copy_devices) - args[ac++] = "--copy-devices"; - if (preallocate_files && am_sender) args[ac++] = "--preallocate"; diff --git a/proto.h b/proto.h index a21f39a..1753f61 100644 --- a/proto.h +++ b/proto.h @@ -3,9 +3,7 @@ int allow_access(const char *addr, const char **host_ptr, int i); void free_acl(stat_x *sxp); int get_acl(const char *fname, stat_x *sxp); -void old_send_acl(stat_x *sxp, int f); void send_acl(int f, stat_x *sxp); -void old_recv_acl(struct file_struct *file, int f); void receive_acl(int f, struct file_struct *file); void cache_tmp_acl(struct file_struct *file, stat_x *sxp); void uncache_tmp_acls(void); diff --git a/rsync.1 b/rsync.1 index 855dd47..c11c02a 100644 --- a/rsync.1 +++ b/rsync.1 @@ -445,7 +445,6 @@ to the detailed description below for a complete description. \-o, \-\-owner preserve owner (super\-user only) \-g, \-\-group preserve group \-\-devices preserve device files (super\-user only) - \-\-copy-devices copy device contents as regular file \-\-specials preserve special files \-D same as \-\-devices \-\-specials \-t, \-\-times preserve modification times @@ -1004,10 +1003,8 @@ This causes rsync to update a file by appending data onto the end of the file, which presumes that the data that already exists on the receiving side is identical with the start of the file on the sending side. If a file needs to be transferred and its size on the receiver is -the same or longer than the size on the sender, the file is skipped. It -also skips any files whose size on the sending side gets shorter during -the send negotiations (rsync warns about a "diminished" file when this -happens). This does not interfere with the updating of a file\(cq\&s non\-content attributes +the same or longer than the size on the sender, the file is skipped. This +does not interfere with the updating of a file\(cq\&s non\-content attributes (e.g. permissions, ownership, etc.) when the file does not need to be transferred, nor does it affect the updating of any non\-regular files. Implies \fB\-\-inplace\fP. diff --git a/rsync.c b/rsync.c index ff761c0..a0b948d 100644 --- a/rsync.c +++ b/rsync.c @@ -33,7 +33,6 @@ extern int preserve_xattrs; extern int preserve_perms; extern int preserve_executability; extern int preserve_times; -extern int copy_devices; extern int am_root; extern int am_server; extern int am_daemon; @@ -411,8 +410,7 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, if (iflags & ITEM_TRANSFER) { int i = ndx - cur_flist->ndx_start; - struct file_struct *file = cur_flist->files[i]; - if (i < 0 || !(S_ISREG(file->mode) || (copy_devices && IS_DEVICE(file->mode)))) { + if (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) { rprintf(FERROR, "received request to transfer non-regular file: %d [%s]\n", ndx, who_am_i()); diff --git a/sender.c b/sender.c index e22eadd..03e4aad 100644 --- a/sender.c +++ b/sender.c @@ -32,7 +32,6 @@ extern int logfile_format_has_i; extern int want_xattr_optim; extern int csum_length; extern int append_mode; -extern int copy_links; extern int io_error; extern int flist_eof; extern int allowed_lull; @@ -139,16 +138,17 @@ void successful_send(int ndx) return; f_name(file, fname); - if ((copy_links ? do_stat(fname, &st) : do_lstat(fname, &st)) < 0) { + if (do_lstat(fname, &st) < 0) { failed_op = "re-lstat"; goto failed; } - if (st.st_size != F_LENGTH(file) || st.st_mtime != file->modtime + if (S_ISREG(file->mode) /* Symlinks & devices don't need this check: */ + && (st.st_size != F_LENGTH(file) || st.st_mtime != file->modtime #ifdef ST_MTIME_NSEC || (NSEC_BUMP(file) && (uint32)st.ST_MTIME_NSEC != F_MOD_NSEC(file)) #endif - ) { + )) { rprintf(FERROR_XFER, "ERROR: Skipping sender remove for changed file: %s\n", fname); return; } @@ -365,30 +365,6 @@ void send_files(int f_in, int f_out) exit_cleanup(RERR_FILEIO); } - /* On Matt's computer, st_size is falsely 0 for most devices. - * If this happens, try harder to determine the actual device size. */ - if (IS_DEVICE(st.st_mode) && st.st_size == 0) { - OFF_T off = lseek(fd, 0, SEEK_END); - if (off == (OFF_T) -1) - rsyserr(FERROR, errno, "failed to seek to end of %s to determine size", fname); - else { - st.st_size = off; - off = lseek(fd, 0, SEEK_SET); - if (off != 0) - rsyserr(FERROR, errno, "failed to seek back to beginning of %s to read it", fname); - } - } - - if (append_mode > 0 && st.st_size < F_LENGTH(file)) { - rprintf(FWARNING, "skipped diminished file: %s\n", - full_fname(fname)); - free_sums(s); - close(fd); - if (protocol_version >= 30) - send_msg_int(MSG_NO_SEND, ndx); - continue; - } - if (st.st_size) { int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE); mbuf = map_file(fd, st.st_size, read_size, s->blength); diff --git a/util.c b/util.c index 24d4c1f..8723248 100644 --- a/util.c +++ b/util.c @@ -346,7 +346,6 @@ int copy_file(const char *source, const char *dest, int ofd, mode_t mode) if (robust_unlink(dest) && errno != ENOENT) { int save_errno = errno; rsyserr(FERROR_XFER, errno, "unlink %s", full_fname(dest)); - close(ifd); errno = save_errno; return -1; } diff --git a/xattrs.c b/xattrs.c index 0c7db2e..5daef62 100644 --- a/xattrs.c +++ b/xattrs.c @@ -22,7 +22,6 @@ #include "rsync.h" #include "ifuncs.h" #include "inums.h" -#include "io.h" #include "lib/sysxattrs.h" #ifdef SUPPORT_XATTRS @@ -39,7 +38,6 @@ extern int preserve_devices; extern int preserve_specials; extern int checksum_seed; extern int saw_xattr_filter; -extern int protocol_version; #define RSYNC_XAL_INITIAL 5 #define RSYNC_XAL_LIST_INITIAL 100 @@ -276,7 +274,7 @@ static int rsync_xal_get(const char *fname, item_list *xalp) if (!(ptr = get_xattr_data(fname, name, &datum_len, 0))) return -1; - if (datum_len > MAX_FULL_DATUM && protocol_version >= 30) { + if (datum_len > MAX_FULL_DATUM) { /* For large datums, we store a flag and a checksum. */ name_offset = 1 + MAX_DIGEST_LEN; sum_init(-1, checksum_seed); @@ -442,7 +440,7 @@ static int find_matching_xattr(const item_list *xalp) || rxas1[j].datum_len != rxas2[j].datum_len || strcmp(rxas1[j].name, rxas2[j].name)) break; - if (rxas1[j].datum_len > MAX_FULL_DATUM && protocol_version >= 30) { + if (rxas1[j].datum_len > MAX_FULL_DATUM) { if (memcmp(rxas1[j].datum + 1, rxas2[j].datum + 1, MAX_DIGEST_LEN) != 0) @@ -517,22 +515,13 @@ int send_xattr(int f, stat_x *sxp) { int ndx = find_matching_xattr(sxp->xattr); - if (protocol_version < 30) { - if (ndx < 0) - write_byte(f, 'X'); - else { - write_byte(f, 'x'); - write_int(f, ndx); - } - } else { - /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */ - write_varint(f, ndx + 1); - } + /* Send 0 (-1 + 1) to indicate that literal xattr data follows. */ + write_varint(f, ndx + 1); if (ndx < 0) { rsync_xa *rxa; int count = sxp->xattr->count; - write_varint30(f, count); + write_varint(f, count); for (rxa = sxp->xattr->items; count--; rxa++) { size_t name_len = rxa->name_len; const char *name = rxa->name; @@ -551,8 +540,8 @@ int send_xattr(int f, stat_x *sxp) name_len += UPRE_LEN; } #endif - write_varint30(f, name_len); - write_varint30(f, rxa->datum_len); + write_varint(f, name_len); + write_varint(f, rxa->datum_len); #ifndef HAVE_LINUX_XATTRS if (name_len > rxa->name_len) { write_buf(f, USER_PREFIX, UPRE_LEN); @@ -560,7 +549,7 @@ int send_xattr(int f, stat_x *sxp) } #endif write_buf(f, name, name_len); - if (rxa->datum_len > MAX_FULL_DATUM && protocol_version >= 30) + if (rxa->datum_len > MAX_FULL_DATUM) write_buf(f, rxa->datum + 1, MAX_DIGEST_LEN); else write_bigbuf(f, rxa->datum, rxa->datum_len); @@ -611,7 +600,7 @@ int xattr_diff(struct file_struct *file, stat_x *sxp, int find_all) cmp = rec_cnt ? strcmp(snd_rxa->name, rec_rxa->name) : -1; if (cmp > 0) same = 0; - else if (snd_rxa->datum_len > MAX_FULL_DATUM && protocol_version >= 30) { + else if (snd_rxa->datum_len > MAX_FULL_DATUM) { same = cmp == 0 && snd_rxa->datum_len == rec_rxa->datum_len && memcmp(snd_rxa->datum + 1, rec_rxa->datum + 1, MAX_DIGEST_LEN) == 0; @@ -657,9 +646,6 @@ void send_xattr_request(const char *fname, struct file_struct *file, int f_out) int cnt, prior_req = 0; rsync_xa *rxa; - if (protocol_version < 30) - return; - glst += F_XATTR(file); lst = &glst->xa_items; @@ -719,9 +705,6 @@ int recv_xattr_request(struct file_struct *file, int f_in) rsync_xa *rxa; int rel_pos, cnt, num, got_xattr_data = 0; - if (protocol_version < 30) - return 0; - if (F_XATTR(file) < 0) { rprintf(FERROR, "recv_xattr_request: internal data error!\n"); exit_cleanup(RERR_PROTOCOL); @@ -808,22 +791,7 @@ void receive_xattr(int f, struct file_struct *file) #else int need_sort = 1; #endif - int ndx; - - if (protocol_version >= 30) - ndx = read_varint(f); - else { - int tag = read_byte(f); - if (tag == 'x') - ndx = read_int(f) + 1; - else if (tag == 'X') - ndx = 0; - else { - rprintf(FERROR, "receive_xattr: unknown extended attribute" - " type tag (%02x) for %s\n", tag, f_name(file, NULL)); - exit_cleanup(RERR_STREAMIO); - } - } + int ndx = read_varint(f); if (ndx < 0 || (size_t)ndx > rsync_xal_l.count) { rprintf(FERROR, "receive_xattr: xa index %d out of" @@ -836,7 +804,7 @@ void receive_xattr(int f, struct file_struct *file) return; } - if ((count = read_varint30(f)) != 0) { + if ((count = read_varint(f)) != 0) { (void)EXPAND_ITEM_LIST(&temp_xattr, rsync_xa, count); temp_xattr.count = 0; } @@ -844,10 +812,9 @@ void receive_xattr(int f, struct file_struct *file) for (num = 1; num <= count; num++) { char *ptr, *name; rsync_xa *rxa; - size_t name_len = read_varint30(f); - size_t datum_len = read_varint30(f); - size_t dget_len = datum_len > MAX_FULL_DATUM && protocol_version >= 30 - ? 1 + MAX_DIGEST_LEN : datum_len; + size_t name_len = read_varint(f); + size_t datum_len = read_varint(f); + size_t dget_len = datum_len > MAX_FULL_DATUM ? 1 + MAX_DIGEST_LEN : datum_len; size_t extra_len = MIGHT_NEED_RPRE ? RPRE_LEN : 0; if ((dget_len + extra_len < dget_len) || (dget_len + extra_len + name_len < dget_len + extra_len))