BUG FIXES:
- - ...
+ - Don't output about a new backup dir with appropriate info verbosity.
+ - Fixed some issues with the sort functions in support/rsyncstats.
+ - Added a way to specify group names that contain spaces in daemon config.
+ - If a backup fails (e.g. full disk) rsync exits with an error.
+ - Avoid invalid output in the summary if either the start or end time had
+ an error.
ENHANCEMENTS:
- - Add the ability for rsync to compare nanosecond times in its file-check
+ - Added the ability for rsync to compare nanosecond times in its file-check
comparisons. Also added a short-option (-@) for --modify-window.
+ - Added the --checksum-choice=NAME[,NAME] option to choose the checksum
+ algorithms.
+
+ DEVELOPER RELATED:
+
+ - Tweak the "make" output when yodl isn't around to create the man pages.
+ - Changed an obsolete compile macro in configure.
SIVAL(input, 20, tv.tv_usec);
SIVAL(input, 24, getpid());
- sum_init(0);
+ sum_init(-1, 0);
sum_update(input, sizeof input);
len = sum_end(digest);
char buf[MAX_DIGEST_LEN];
int len;
- sum_init(0);
+ sum_init(-1, 0);
sum_update(in, strlen(in));
sum_update(challenge, strlen(challenge));
len = sum_end(buf);
extern int checksum_seed;
extern int protocol_version;
extern int proper_seed_order;
+extern char *checksum_choice;
+
+#define CSUM_NONE 0
+#define CSUM_ARCHAIC 1
+#define CSUM_MD4_BUSTED 2
+#define CSUM_MD4_OLD 3
+#define CSUM_MD4 4
+#define CSUM_MD5 5
+
+int xfersum_type = 0; /* used for the file transfer checksums */
+int checksum_type = 0; /* used for the pre-transfer (--checksum) checksums */
+
+/* Returns 1 if --whole-file must be enabled. */
+int parse_checksum_choice(void)
+{
+ char *cp = checksum_choice ? strchr(checksum_choice, ',') : NULL;
+ if (cp) {
+ xfersum_type = parse_csum_name(checksum_choice, cp - checksum_choice);
+ checksum_type = parse_csum_name(cp+1, -1);
+ } else
+ xfersum_type = checksum_type = parse_csum_name(checksum_choice, -1);
+ return xfersum_type == CSUM_NONE;
+}
+
+int parse_csum_name(const char *name, int len)
+{
+ if (len < 0 && name)
+ len = strlen(name);
+
+ if (!name || (len == 4 && strncasecmp(name, "auto", 4) == 0)) {
+ if (protocol_version >= 30)
+ return CSUM_MD5;
+ if (protocol_version >= 27)
+ return CSUM_MD4_OLD;
+ if (protocol_version >= 21)
+ return CSUM_MD4_BUSTED;
+ return CSUM_ARCHAIC;
+ }
+ if (len == 3 && strncasecmp(name, "md4", 3) == 0)
+ return CSUM_MD4;
+ if (len == 3 && strncasecmp(name, "md5", 3) == 0)
+ return CSUM_MD5;
+ if (len == 4 && strncasecmp(name, "none", 4) == 0)
+ return CSUM_NONE;
+
+ rprintf(FERROR, "unknown checksum name: %s\n", name);
+ exit_cleanup(RERR_UNSUPPORTED);
+}
+
+int csum_len_for_type(int cst)
+{
+ switch (cst) {
+ case CSUM_NONE:
+ return 1;
+ case CSUM_ARCHAIC:
+ return 2;
+ case CSUM_MD4:
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED:
+ return MD4_DIGEST_LEN;
+ case CSUM_MD5:
+ return MD5_DIGEST_LEN;
+ }
+ return 0;
+}
+
+int canonical_checksum(int csum_type)
+{
+ return csum_type >= CSUM_MD4 ? 1 : 0;
+}
/*
a simple 32 bit checksum that can be upadted from either end
return (s1 & 0xffff) + (s2 << 16);
}
-
void get_checksum2(char *buf, int32 len, char *sum)
{
md_context m;
- if (protocol_version >= 30) {
+ switch (xfersum_type) {
+ case CSUM_MD5: {
uchar seedbuf[4];
md5_begin(&m);
if (proper_seed_order) {
}
}
md5_result(&m, (uchar *)sum);
- } else {
+ break;
+ }
+ case CSUM_MD4:
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED: {
int32 i;
static char *buf1;
static int32 len1;
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes.
*/
- if (len - i > 0 || protocol_version >= 27)
+ if (len - i > 0 || xfersum_type != CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)(buf1+i), len-i);
mdfour_result(&m, (uchar *)sum);
+ break;
+ }
}
}
buf = map_file(fd, len, MAX_MAP_SIZE, CSUM_CHUNK);
- if (protocol_version >= 30) {
+ switch (checksum_type) {
+ case CSUM_MD5:
md5_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
md5_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
md5_result(&m, (uchar *)sum);
- } else {
+ break;
+ case CSUM_MD4:
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED:
mdfour_begin(&m);
for (i = 0; i + CSUM_CHUNK <= len; i += CSUM_CHUNK) {
* are multiples of 64. This is fixed by calling mdfour_update()
* even when there are no more bytes. */
remainder = (int32)(len - i);
- if (remainder > 0 || protocol_version >= 27)
+ if (remainder > 0 || checksum_type != CSUM_MD4_BUSTED)
mdfour_update(&m, (uchar *)map_ptr(buf, i, remainder), remainder);
mdfour_result(&m, (uchar *)sum);
+ break;
+ default:
+ rprintf(FERROR, "invalid checksum-choice for the --checksum option (%d)\n", checksum_type);
+ exit_cleanup(RERR_UNSUPPORTED);
}
close(fd);
static int32 sumresidue;
static md_context md;
+static int cursum_type;
-void sum_init(int seed)
+void sum_init(int csum_type, int seed)
{
char s[4];
- if (protocol_version >= 30)
+ if (csum_type < 0)
+ csum_type = parse_csum_name(NULL, 0);
+ cursum_type = csum_type;
+
+ switch (csum_type) {
+ case CSUM_MD5:
md5_begin(&md);
- else {
+ break;
+ case CSUM_MD4:
+ mdfour_begin(&md);
+ sumresidue = 0;
+ break;
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED:
mdfour_begin(&md);
sumresidue = 0;
SIVAL(s, 0, seed);
sum_update(s, 4);
+ break;
+ case CSUM_NONE:
+ break;
}
}
**/
void sum_update(const char *p, int32 len)
{
- if (protocol_version >= 30) {
+ switch (cursum_type) {
+ case CSUM_MD5:
md5_update(&md, (uchar *)p, len);
- } else {
+ break;
+ case CSUM_MD4:
+ case CSUM_MD4_OLD:
+ case CSUM_MD4_BUSTED:
if (len + sumresidue < CSUM_CHUNK) {
memcpy(md.buffer + sumresidue, p, len);
sumresidue += len;
- return;
+ break;
}
if (sumresidue) {
sumresidue = len;
if (sumresidue)
memcpy(md.buffer, p, sumresidue);
+ break;
+ case CSUM_NONE:
+ break;
}
}
int sum_end(char *sum)
{
- if (protocol_version >= 30) {
+ switch (cursum_type) {
+ case CSUM_MD5:
md5_result(&md, (uchar *)sum);
- return MD5_DIGEST_LEN;
- } else {
- if (sumresidue || protocol_version >= 27)
+ break;
+ case CSUM_MD4:
+ case CSUM_MD4_OLD:
+ mdfour_update(&md, (uchar *)md.buffer, sumresidue);
+ mdfour_result(&md, (uchar *)sum);
+ break;
+ case CSUM_MD4_BUSTED:
+ if (sumresidue)
mdfour_update(&md, (uchar *)md.buffer, sumresidue);
-
mdfour_result(&md, (uchar *)sum);
-
- return MD4_DIGEST_LEN;
+ break;
+ case CSUM_NONE:
+ *sum = '\0';
+ break;
}
+
+ return csum_len_for_type(cursum_type);
}
} else {
checksum_seed = read_int(f_in);
}
+
+ init_flist();
}
extern int am_generator;
extern int inc_recurse;
extern int always_checksum;
+extern int checksum_type;
extern int module_id;
extern int ignore_errors;
extern int numeric_ids;
rprintf(FINFO, "FILE_STRUCT_LEN=%d, EXTRA_LEN=%d\n",
(int)FILE_STRUCT_LEN, (int)EXTRA_LEN);
}
- checksum_len = protocol_version < 21 ? 2
- : protocol_version < 30 ? MD4_DIGEST_LEN
- : MD5_DIGEST_LEN;
+ parse_checksum_choice(); /* Sets checksum_type && xfersum_type */
+ checksum_len = csum_len_for_type(checksum_type);
}
static int show_filelist_p(void)
extern int local_server;
extern int quiet;
extern int module_id;
-extern int checksum_len;
extern int allow_8bit_chars;
extern int protocol_version;
extern int always_checksum;
extern int preserve_times;
extern int msgs2stderr;
+extern int xfersum_type;
+extern int checksum_type;
extern int stdout_format_has_i;
extern int stdout_format_has_o_or_i;
extern int logfile_format_has_i;
extern int64 total_data_read;
extern mode_t orig_umask;
extern char *auth_user;
+extern char *checksum_choice;
extern char *stdout_format;
extern char *logfile_format;
extern char *logfile_name;
n = buf2;
break;
case 'C':
- if (protocol_version >= 30
- && (iflags & ITEM_TRANSFER
- || (always_checksum && S_ISREG(file->mode)))) {
- const char *sum = iflags & ITEM_TRANSFER
- ? sender_file_sum : F_SUM(file);
- n = sum_as_hex(sum);
- } else {
+ n = NULL;
+ if (S_ISREG(file->mode)) {
+ if (always_checksum && canonical_checksum(checksum_type))
+ n = sum_as_hex(checksum_type, F_SUM(file));
+ else if (iflags & ITEM_TRANSFER && canonical_checksum(xfersum_type))
+ n = sum_as_hex(xfersum_type, sender_file_sum);
+ }
+ if (!n) {
+ int checksum_len = csum_len_for_type(always_checksum ? checksum_type : xfersum_type);
memset(buf2, ' ', checksum_len*2);
buf2[checksum_len*2] = '\0';
n = buf2;
* that implement getcwd that way "pwd" can't be found after chroot. */
change_dir(NULL, CD_NORMAL);
- init_flist();
-
if ((write_batch || read_batch) && !am_server) {
if (write_batch)
write_batch_shell_file(orig_argc, orig_argv, argc);
extern int checksum_seed;
extern int append_mode;
-extern int checksum_len;
+extern int xfersum_type;
int updating_basis_file;
char sender_file_sum[MAX_DIGEST_LEN];
**/
void match_sums(int f, struct sum_struct *s, struct map_struct *buf, OFF_T len)
{
+ int checksum_len;
+
last_match = 0;
false_alarms = 0;
hash_hits = 0;
matches = 0;
data_transfer = 0;
- sum_init(checksum_seed);
+ sum_init(xfersum_type, checksum_seed);
if (append_mode > 0) {
if (append_mode == 2) {
matched(f, s, buf, len, -1);
}
- if (sum_end(sender_file_sum) != checksum_len)
- overflow_exit("checksum_len"); /* Impossible... */
+ checksum_len = sum_end(sender_file_sum);
/* If we had a read error, send a bad checksum. We use all bits
* off as long as the checksum doesn't happen to be that, in
static int remote_option_alloc = 0;
int remote_option_cnt = 0;
const char **remote_options = NULL;
+const char *checksum_choice = NULL;
int quiet = 0;
int output_motd = 1;
#endif
rprintf(F," -n, --dry-run perform a trial run with no changes made\n");
rprintf(F," -W, --whole-file copy files whole (without delta-xfer algorithm)\n");
+ rprintf(F," --checksum-choice=STR choose the checksum algorithms\n");
rprintf(F," -x, --one-file-system don't cross filesystem boundaries\n");
rprintf(F," -B, --block-size=SIZE force a fixed checksum block-size\n");
rprintf(F," -e, --rsh=COMMAND specify the remote shell to use\n");
{"cvs-exclude", 'C', POPT_ARG_NONE, &cvs_exclude, 0, 0, 0 },
{"whole-file", 'W', POPT_ARG_VAL, &whole_file, 1, 0, 0 },
{"no-whole-file", 0, POPT_ARG_VAL, &whole_file, 0, 0, 0 },
+ {"checksum-choice", 0, POPT_ARG_STRING, &checksum_choice, 0, 0, 0 },
{"no-W", 0, POPT_ARG_VAL, &whole_file, 0, 0, 0 },
{"checksum", 'c', POPT_ARG_VAL, &always_checksum, 1, 0, 0 },
{"no-checksum", 0, POPT_ARG_VAL, &always_checksum, 0, 0, 0 },
}
}
+ if (checksum_choice && strcmp(checksum_choice, "auto") != 0 && strcmp(checksum_choice, "auto,auto") != 0) {
+ /* Call this early to verify the args and figure out if we need to force
+ * --whole-file. Note that the parse function will get called again later,
+ * just in case an "auto" choice needs to know the protocol_version. */
+ if (parse_checksum_choice())
+ whole_file = 1;
+ } else
+ checksum_choice = NULL;
+
if (human_readable > 1 && argc == 2 && !am_server) {
/* Allow the old meaning of 'h' (--help) on its own. */
usage(FINFO);
args[ac++] = arg;
}
+ if (checksum_choice) {
+ if (asprintf(&arg, "--checksum-choice=%s", checksum_choice) < 0)
+ goto oom;
+ args[ac++] = arg;
+ }
+
if (am_sender) {
if (max_delete > 0) {
if (asprintf(&arg, "--max-delete=%d", max_delete) < 0)
extern int sparse_files;
extern int preallocate_files;
extern int keep_partial;
-extern int checksum_len;
extern int checksum_seed;
extern int inplace;
extern int allowed_lull;
extern int delay_updates;
+extern int xfersum_type;
extern mode_t orig_umask;
extern struct stats stats;
extern char *tmpdir;
static char file_sum1[MAX_DIGEST_LEN];
struct map_struct *mapbuf;
struct sum_struct sum;
+ int checksum_len;
int32 len;
OFF_T offset = 0;
OFF_T offset2;
} else
mapbuf = NULL;
- sum_init(checksum_seed);
+ sum_init(xfersum_type, checksum_seed);
if (append_mode > 0) {
OFF_T j;
exit_cleanup(RERR_FILEIO);
}
- if (sum_end(file_sum1) != checksum_len)
- overflow_exit("checksum_len"); /* Impossible... */
+ checksum_len = sum_end(file_sum1);
if (mapbuf)
unmap_file(mapbuf);
--preallocate allocate dest files before writing
-n, --dry-run perform a trial run with no changes made
-W, --whole-file copy files whole (w/o delta-xfer algorithm)
+ --checksum-choice=STR choose the checksum algorithms
-x, --one-file-system don't cross filesystem boundaries
-B, --block-size=SIZE force a fixed checksum block-size
-e, --rsh=COMMAND specify the remote shell to use
statistics are too small, and the "speedup" value is equivalent to a run
where no file transfers were needed.
-dit(bf(-W, --whole-file)) With this option rsync's delta-transfer algorithm
-is not used and the whole file is sent as-is instead. The transfer may be
+dit(bf(-W, --whole-file)) This option disables rsync's delta-transfer algorithm,
+which causes all transferred files to be sent whole. The transfer may be
faster if this option is used when the bandwidth between the source and
destination machines is higher than the bandwidth to disk (especially when the
"disk" is actually a networked filesystem). This is the default when both
the source and destination are specified as local paths, but only if no
batch-writing option is in effect.
+dit(bf(--checksum-choice=STR)) This option overrides the checksum algoriths.
+If one algorithm name is specified, it is used for both the transfer checksums
+and (assuming bf(--checksum) is specifed) the pre-transfer checksumming. If two
+comma-separated names are supplied, the first name affects the transfer
+checksums, and the second name affects the pre-transfer checksumming.
+
+The algorithm choices are "auto", "md4", "md5", and "none". If "none" is
+specified for the first name, the bf(--whole-file) option is forced on and no
+checksum verification is performed on the transferred data. If "none" is
+specified for the second name, the bf(--checksum) option cannot be used. The
+"auto" option is the default, where rsync bases its algorithm choice on the
+protocol version (for backward compatibility with older rsync versions).
+
dit(bf(-x, --one-file-system)) This tells rsync to avoid crossing a
filesystem boundary when recursing. This does not limit the user's ability
to specify items to copy from multiple filesystems, just rsync's recursion
it() %b the number of bytes actually transferred
it() %B the permission bits of the file (e.g. rwxrwxrwt)
it() %c the total size of the block checksums received for the basis file (only when sending)
- it() %C the full-file MD5 checksum if bf(--checksum) is enabled or a file was transferred (only for protocol 30 or above).
+ it() %C the full-file checksum if it is known for the file. For older rsync protocols/versions, the checksum was salted, and is thus not a useful value (and is not displayed when that is the case). For the checksum to output for a file, either the bf(--checksum) option must be in-effect or the file must have been transferred without a salted checksum being used. See the bf(--checksum-choice) option for a way to choose the algorithm.
it() %f the filename (long form on sender; no trailing "/")
it() %G the gid of the file (decimal) or "DEFAULT"
it() %h the remote host name (only available for a daemon)
int preallocate_files = 0;
int protect_args = 0;
int module_id = -1;
-int checksum_len = 0;
int relative_paths = 0;
int module_dirlen = 0;
int preserve_acls = 0;
{
return "tester";
}
+
+ int csum_len_for_type(int cst)
+{
+ return cst ? 16 : 1;
+}
#include "itypes.h"
#include "inums.h"
-extern int checksum_len;
-
/**
* Sleep for a specified number of milliseconds.
*
return realloc(ptr, size * num);
}
-const char *sum_as_hex(const char *sum)
+const char *sum_as_hex(int csum_type, const char *sum)
{
static char buf[MAX_DIGEST_LEN*2+1];
int i, x1, x2;
+ int checksum_len = csum_len_for_type(csum_type);
char *c = buf + checksum_len*2;
assert(c - buf < (int)sizeof buf);
if (datum_len > MAX_FULL_DATUM) {
/* For large datums, we store a flag and a checksum. */
name_offset = 1 + MAX_DIGEST_LEN;
- sum_init(checksum_seed);
+ sum_init(-1, checksum_seed);
sum_update(ptr, datum_len);
free(ptr);
goto still_abbrev;
}
- sum_init(checksum_seed);
+ sum_init(-1, checksum_seed);
sum_update(ptr, len);
sum_end(sum);
if (memcmp(sum, rxas[i].datum + 1, MAX_DIGEST_LEN) != 0) {