Lines 21-26
Link Here
|
21 |
#include "rsync.h" |
21 |
#include "rsync.h" |
22 |
#include "popt.h" |
22 |
#include "popt.h" |
23 |
|
23 |
|
|
|
24 |
extern int sanitize_paths; |
25 |
extern char curr_dir[MAXPATHLEN]; |
24 |
extern struct exclude_struct **exclude_list; |
26 |
extern struct exclude_struct **exclude_list; |
25 |
|
27 |
|
26 |
int make_backups = 0; |
28 |
int make_backups = 0; |
Lines 359-365
Link Here
|
359 |
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 }, |
361 |
{"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 }, |
360 |
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 }, |
362 |
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 }, |
361 |
{"compare-dest", 0, POPT_ARG_STRING, &compare_dest, 0, 0, 0 }, |
363 |
{"compare-dest", 0, POPT_ARG_STRING, &compare_dest, 0, 0, 0 }, |
362 |
{"link-dest", 0, POPT_ARG_STRING, 0, OPT_LINK_DEST, 0, 0 }, |
364 |
{"link-dest", 0, POPT_ARG_STRING, &compare_dest, OPT_LINK_DEST, 0, 0 }, |
363 |
/* TODO: Should this take an optional int giving the compression level? */ |
365 |
/* TODO: Should this take an optional int giving the compression level? */ |
364 |
{"compress", 'z', POPT_ARG_NONE, &do_compression, 0, 0, 0 }, |
366 |
{"compress", 'z', POPT_ARG_NONE, &do_compression, 0, 0, 0 }, |
365 |
{"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 }, |
367 |
{"daemon", 0, POPT_ARG_NONE, &daemon_opt, 0, 0, 0 }, |
Lines 469-474
Link Here
|
469 |
{ |
471 |
{ |
470 |
int opt; |
472 |
int opt; |
471 |
char *ref = lp_refuse_options(module_id); |
473 |
char *ref = lp_refuse_options(module_id); |
|
|
474 |
const char *arg; |
472 |
poptContext pc; |
475 |
poptContext pc; |
473 |
|
476 |
|
474 |
if (ref && *ref) |
477 |
if (ref && *ref) |
Lines 517-528
Link Here
|
517 |
break; |
520 |
break; |
518 |
|
521 |
|
519 |
case OPT_EXCLUDE_FROM: |
522 |
case OPT_EXCLUDE_FROM: |
520 |
add_exclude_file(&exclude_list, poptGetOptArg(pc), |
523 |
arg = poptGetOptArg(pc); |
|
|
524 |
if (sanitize_paths) |
525 |
arg = alloc_sanitize_path(arg, curr_dir); |
526 |
add_exclude_file(&exclude_list, arg, |
521 |
MISSING_FATAL, ADD_EXCLUDE); |
527 |
MISSING_FATAL, ADD_EXCLUDE); |
522 |
break; |
528 |
break; |
523 |
|
529 |
|
524 |
case OPT_INCLUDE_FROM: |
530 |
case OPT_INCLUDE_FROM: |
525 |
add_exclude_file(&exclude_list, poptGetOptArg(pc), |
531 |
arg = poptGetOptArg(pc); |
|
|
532 |
if (sanitize_paths) |
533 |
arg = alloc_sanitize_path(arg, curr_dir); |
534 |
add_exclude_file(&exclude_list, arg, |
526 |
MISSING_FATAL, ADD_INCLUDE); |
535 |
MISSING_FATAL, ADD_INCLUDE); |
527 |
break; |
536 |
break; |
528 |
|
537 |
|
Lines 566-572
Link Here
|
566 |
|
575 |
|
567 |
case OPT_LINK_DEST: |
576 |
case OPT_LINK_DEST: |
568 |
#if HAVE_LINK |
577 |
#if HAVE_LINK |
569 |
compare_dest = (char *)poptGetOptArg(pc); |
|
|
570 |
link_dest = 1; |
578 |
link_dest = 1; |
571 |
break; |
579 |
break; |
572 |
#else |
580 |
#else |
Lines 660-665
Link Here
|
660 |
if (relative_paths < 0) |
668 |
if (relative_paths < 0) |
661 |
relative_paths = files_from? 1 : 0; |
669 |
relative_paths = files_from? 1 : 0; |
662 |
|
670 |
|
|
|
671 |
*argv = poptGetArgs(pc); |
672 |
if (*argv) |
673 |
*argc = count_args(*argv); |
674 |
else |
675 |
*argc = 0; |
676 |
|
677 |
if (sanitize_paths) { |
678 |
int i; |
679 |
for (i = *argc; i-- > 0; ) |
680 |
(*argv)[i] = alloc_sanitize_path((*argv)[i], NULL); |
681 |
if (tmpdir) |
682 |
tmpdir = alloc_sanitize_path(tmpdir, curr_dir); |
683 |
if (compare_dest) |
684 |
compare_dest = alloc_sanitize_path(compare_dest, curr_dir); |
685 |
if (backup_dir) |
686 |
backup_dir = alloc_sanitize_path(backup_dir, curr_dir); |
687 |
if (files_from) |
688 |
files_from = alloc_sanitize_path(files_from, curr_dir); |
689 |
} |
690 |
|
663 |
if (!backup_suffix) |
691 |
if (!backup_suffix) |
664 |
backup_suffix = backup_dir ? "" : BACKUP_SUFFIX; |
692 |
backup_suffix = backup_dir ? "" : BACKUP_SUFFIX; |
665 |
backup_suffix_len = strlen(backup_suffix); |
693 |
backup_suffix_len = strlen(backup_suffix); |
Lines 690-701
Link Here
|
690 |
if (do_progress && !verbose) |
718 |
if (do_progress && !verbose) |
691 |
verbose = 1; |
719 |
verbose = 1; |
692 |
|
720 |
|
693 |
*argv = poptGetArgs(pc); |
|
|
694 |
if (*argv) |
695 |
*argc = count_args(*argv); |
696 |
else |
697 |
*argc = 0; |
698 |
|
699 |
if (files_from) { |
721 |
if (files_from) { |
700 |
char *colon; |
722 |
char *colon; |
701 |
if (*argc != 2) { |
723 |
if (*argc != 2) { |
Lines 718-726
Link Here
|
718 |
exit_cleanup(RERR_SYNTAX); |
740 |
exit_cleanup(RERR_SYNTAX); |
719 |
} |
741 |
} |
720 |
} else { |
742 |
} else { |
721 |
extern int sanitize_paths; |
|
|
722 |
if (sanitize_paths) |
723 |
sanitize_path(strdup(files_from), NULL); |
724 |
filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); |
743 |
filesfrom_fd = open(files_from, O_RDONLY|O_BINARY); |
725 |
if (filesfrom_fd < 0) { |
744 |
if (filesfrom_fd < 0) { |
726 |
rsyserr(FERROR, errno, |
745 |
rsyserr(FERROR, errno, |