/** Do not go into the background when run as --daemon. Good
* for debugging and required for running as a service on W32,
* or under Unix process-monitors. **/
/** Do not go into the background when run as --daemon. Good
* for debugging and required for running as a service on W32,
* or under Unix process-monitors. **/
-static int refused_verbose, refused_delete, refused_archive_part;
-static int refused_partial, refused_progress;
-static char *dest_option = NULL;
+static int itemize_changes = 0;
+static int refused_delete, refused_archive_part;
+static int refused_partial, refused_progress, refused_delete_before;
rprintf(F,"\nrsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n");
rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
rprintf(F,"\nrsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n");
rprintf(F,"Usage: rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST\n");
rprintf(F," or rsync [OPTION]... SRC [SRC]... DEST\n");
rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\n");
rprintf(F," or rsync [OPTION]... SRC [SRC]... DEST\n");
rprintf(F," or rsync [OPTION]... [USER@]HOST::SRC [DEST]\n");
rprintf(F," or rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST\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");
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");
rprintf(F," --existing only update files that already exist on receiver\n");
rprintf(F," --ignore-existing ignore files that already exist on receiving side\n");
rprintf(F," --existing only update files that already exist on receiver\n");
rprintf(F," --ignore-existing ignore files that already exist on receiving side\n");
rprintf(F," --del an alias for --delete-during\n");
rprintf(F," --delete delete files that don't exist on the sending side\n");
rprintf(F," --delete-before receiver deletes before transfer (default)\n");
rprintf(F," --del an alias for --delete-during\n");
rprintf(F," --delete delete files that don't exist on the sending side\n");
rprintf(F," --delete-before receiver deletes before transfer (default)\n");
rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n");
rprintf(F," --include-from=FILE read include patterns from FILE\n");
rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
rprintf(F," --include=PATTERN don't exclude files matching PATTERN\n");
rprintf(F," --include-from=FILE read include patterns from FILE\n");
rprintf(F," --files-from=FILE read list of source-file names from FILE\n");
- rprintf(F," -0, --from0 all *-from file lists are delimited by nulls\n");
- rprintf(F," --version print version number\n");
+ rprintf(F," -0, --from0 all *-from/filter files are delimited by 0s\n");
+ rprintf(F," --address=ADDRESS bind address for outgoing socket to daemon\n");
rprintf(F," --port=PORT specify double-colon alternate port number\n");
rprintf(F," --blocking-io use blocking I/O for the remote shell\n");
rprintf(F," --no-blocking-io turn off blocking I/O when it is the default\n");
rprintf(F," --stats give some file-transfer stats\n");
rprintf(F," --progress show progress during transfer\n");
rprintf(F," -P same as --partial --progress\n");
rprintf(F," --port=PORT specify double-colon alternate port number\n");
rprintf(F," --blocking-io use blocking I/O for the remote shell\n");
rprintf(F," --no-blocking-io turn off blocking I/O when it is the default\n");
rprintf(F," --stats give some file-transfer stats\n");
rprintf(F," --progress show progress during transfer\n");
rprintf(F," -P same as --partial --progress\n");
- rprintf(F," -w, --what-has-changed output a change summary for all updates\n");
- rprintf(F," --log-format=FORMAT log file-transfers using specified format\n");
+ rprintf(F," -i, --itemize-changes output a change-summary for all updates\n");
+ rprintf(F," --log-format=FORMAT output filenames using the specified format\n");
rprintf(F," --password-file=FILE read password from FILE\n");
rprintf(F," --list-only list the files instead of copying them\n");
rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
rprintf(F," --write-batch=FILE write a batched update to FILE\n");
rprintf(F," --password-file=FILE read password from FILE\n");
rprintf(F," --list-only list the files instead of copying them\n");
rprintf(F," --bwlimit=KBPS limit I/O bandwidth; KBytes per second\n");
rprintf(F," --write-batch=FILE write a batched update to FILE\n");
#ifdef INET6
rprintf(F," -4, --ipv4 prefer IPv4\n");
rprintf(F," -6, --ipv6 prefer IPv6\n");
#endif
#ifdef INET6
rprintf(F," -4, --ipv4 prefer IPv4\n");
rprintf(F," -6, --ipv6 prefer IPv6\n");
#endif
rprintf(F," -h, --help show this help screen\n");
rprintf(F,"\nUse \"rsync --daemon --help\" to see the daemon-mode command-line options.\n");
rprintf(F," -h, --help show this help screen\n");
rprintf(F,"\nUse \"rsync --daemon --help\" to see the daemon-mode command-line options.\n");
enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
enum {OPT_VERSION = 1000, OPT_DAEMON, OPT_SENDER, OPT_EXCLUDE, OPT_EXCLUDE_FROM,
OPT_FILTER, OPT_COMPARE_DEST, OPT_COPY_DEST, OPT_LINK_DEST,
OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_MODIFY_WINDOW,
{"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 },
{"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 },
{"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 },
{"delete-during", 0, POPT_ARG_NONE, &delete_during, 0, 0, 0 },
{"delete-after", 0, POPT_ARG_NONE, &delete_after, 0, 0, 0 },
{"delete-excluded", 0, POPT_ARG_NONE, &delete_excluded, 0, 0, 0 },
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
{"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
{"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 },
{"force", 0, POPT_ARG_NONE, &force_delete, 0, 0, 0 },
{"numeric-ids", 0, POPT_ARG_NONE, &numeric_ids, 0, 0, 0 },
{"filter", 'f', POPT_ARG_STRING, 0, OPT_FILTER, 0, 0 },
{"keep-dirlinks", 'K', POPT_ARG_NONE, &keep_dirlinks, 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 },
{"keep-dirlinks", 'K', POPT_ARG_NONE, &keep_dirlinks, 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 },
- {"copy-unsafe-links", 0, POPT_ARG_NONE, ©_unsafe_links, 0, 0, 0 },
+ {"copy-unsafe-links",0, POPT_ARG_NONE, ©_unsafe_links, 0, 0, 0 },
{"perms", 'p', POPT_ARG_NONE, &preserve_perms, 0, 0, 0 },
{"owner", 'o', POPT_ARG_NONE, &preserve_uid, 0, 0, 0 },
{"group", 'g', POPT_ARG_NONE, &preserve_gid, 0, 0, 0 },
{"devices", 'D', POPT_ARG_NONE, &preserve_devices, 0, 0, 0 },
{"times", 't', POPT_ARG_NONE, &preserve_times, 0, 0, 0 },
{"perms", 'p', POPT_ARG_NONE, &preserve_perms, 0, 0, 0 },
{"owner", 'o', POPT_ARG_NONE, &preserve_uid, 0, 0, 0 },
{"group", 'g', POPT_ARG_NONE, &preserve_gid, 0, 0, 0 },
{"devices", 'D', POPT_ARG_NONE, &preserve_devices, 0, 0, 0 },
{"times", 't', POPT_ARG_NONE, &preserve_times, 0, 0, 0 },
- {"omit-dir-times", 'O', POPT_ARG_NONE, &omit_dir_times, 0, 0, 0 },
+ {"omit-dir-times", 'O', POPT_ARG_VAL, &omit_dir_times, 2, 0, 0 },
{"checksum", 'c', POPT_ARG_NONE, &always_checksum, 0, 0, 0 },
{"verbose", 'v', POPT_ARG_NONE, 0, 'v', 0, 0 },
{"quiet", 'q', POPT_ARG_NONE, 0, 'q', 0, 0 },
{"archive", 'a', POPT_ARG_NONE, &archive_mode, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 },
{"sender", 0, POPT_ARG_NONE, 0, OPT_SENDER, 0, 0 },
{"checksum", 'c', POPT_ARG_NONE, &always_checksum, 0, 0, 0 },
{"verbose", 'v', POPT_ARG_NONE, 0, 'v', 0, 0 },
{"quiet", 'q', POPT_ARG_NONE, 0, 'q', 0, 0 },
{"archive", 'a', POPT_ARG_NONE, &archive_mode, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 },
{"sender", 0, POPT_ARG_NONE, 0, OPT_SENDER, 0, 0 },
- {"recursive", 'r', POPT_ARG_VAL, &recurse, -1, 0, 0 },
+ {"recursive", 'r', POPT_ARG_NONE, &recurse, 0, 0, 0 },
{"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 },
{"relative", 'R', POPT_ARG_VAL, &relative_paths, 1, 0, 0 },
{"no-relative", 0, POPT_ARG_VAL, &relative_paths, 0, 0, 0 },
{"list-only", 0, POPT_ARG_VAL, &list_only, 2, 0, 0 },
{"relative", 'R', POPT_ARG_VAL, &relative_paths, 1, 0, 0 },
{"no-relative", 0, POPT_ARG_VAL, &relative_paths, 0, 0, 0 },
{"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 },
{"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 },
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
{"block-size", 'B', POPT_ARG_LONG, &block_size, 0, 0, 0 },
{"max-delete", 0, POPT_ARG_INT, &max_delete, 0, 0, 0 },
{"max-size", 0, POPT_ARG_STRING, &max_size_arg, OPT_MAX_SIZE, 0, 0 },
- {"timeout", 0, POPT_ARG_INT, &io_timeout, OPT_TIMEOUT, 0, 0 },
+ {"timeout", 0, POPT_ARG_INT, &io_timeout, 0, 0, 0 },
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"temp-dir", 'T', POPT_ARG_STRING, &tmpdir, 0, 0, 0 },
{"compare-dest", 0, POPT_ARG_STRING, 0, OPT_COMPARE_DEST, 0, 0 },
{"copy-dest", 0, POPT_ARG_STRING, 0, OPT_COPY_DEST, 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
{0, 'F', POPT_ARG_NONE, 0, 'F', 0, 0 },
{0, 'P', POPT_ARG_NONE, 0, 'P', 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
{0, 'F', POPT_ARG_NONE, 0, 'F', 0, 0 },
{0, 'P', POPT_ARG_NONE, 0, 'P', 0, 0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
{"log-format", 0, POPT_ARG_STRING, &log_format, 0, 0, 0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
{"log-format", 0, POPT_ARG_STRING, &log_format, 0, 0, 0 },
- {"what-has-changed",'w', POPT_ARG_NONE, &what_has_changed, 0, 0, 0 },
+ {"itemize-changes", 'i', POPT_ARG_NONE, &itemize_changes, 0, 0, 0 },
{"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
{"hard-links", 'H', POPT_ARG_NONE, &preserve_hard_links, 0, 0, 0 },
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
{"bwlimit", 0, POPT_ARG_INT, &bwlimit, 0, 0, 0 },
{"backup-dir", 0, POPT_ARG_STRING, &backup_dir, 0, 0, 0 },
{"hard-links", 'H', POPT_ARG_NONE, &preserve_hard_links, 0, 0, 0 },
{"read-batch", 0, POPT_ARG_STRING, &batch_name, OPT_READ_BATCH, 0, 0 },
{"write-batch", 0, POPT_ARG_STRING, &batch_name, OPT_WRITE_BATCH, 0, 0 },
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_NONE, &eol_nulls, 0, 0, 0},
{"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 },
{"files-from", 0, POPT_ARG_STRING, &files_from, 0, 0, 0 },
{"from0", '0', POPT_ARG_NONE, &eol_nulls, 0, 0, 0},
{"no-implied-dirs", 0, POPT_ARG_VAL, &implied_dirs, 0, 0, 0 },
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
#endif
/* All these options switch us into daemon-mode option-parsing. */
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
#endif
/* All these options switch us into daemon-mode option-parsing. */
{"config", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
{"daemon", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
{"config", 0, POPT_ARG_STRING, 0, OPT_DAEMON, 0, 0 },
{"daemon", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
{"no-detach", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
{0,0,0,0, 0, 0, 0}
};
{"no-detach", 0, POPT_ARG_NONE, 0, OPT_DAEMON, 0, 0 },
{0,0,0,0, 0, 0, 0}
};
{"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 },
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
#endif
{"ipv4", '4', POPT_ARG_VAL, &default_af_hint, AF_INET, 0, 0 },
{"ipv6", '6', POPT_ARG_VAL, &default_af_hint, AF_INET6, 0, 0 },
#endif
- {"no-detach", 0, POPT_ARG_NONE, &no_detach, 0, 0, 0 },
+ {"detach", 0, POPT_ARG_VAL, &no_detach, 0, 0, 0 },
+ {"no-detach", 0, POPT_ARG_VAL, &no_detach, 1, 0, 0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
{"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 },
{"port", 0, POPT_ARG_INT, &rsync_port, 0, 0, 0 },
{"protocol", 0, POPT_ARG_INT, &protocol_version, 0, 0, 0 },
{"server", 0, POPT_ARG_NONE, &am_server, 0, 0, 0 },
else if (wildmatch("partial", op->longName))
refused_partial = op->val;
else if (wildmatch("progress", op->longName))
else if (wildmatch("partial", op->longName))
refused_partial = op->val;
else if (wildmatch("progress", op->longName))
+
+ for (op = long_options; ; op++) {
+ *shortname = op->shortName;
+ if (!op->longName && !*shortname)
+ break;
+ if (op->val == OPT_DAEMON) {
+ if (op->argInfo == POPT_ARG_VAL)
+ op->argInfo = POPT_ARG_NONE;
+ op->val = (op - long_options) + OPT_REFUSED_BASE;
+ }
+ }
- for (arg = max_size_arg; isdigit(*(uchar*)arg); arg++) {}
- if (*arg == '.')
- for (arg++; isdigit(*(uchar*)arg); arg++) {}
- switch (*arg) {
- case 'k': case 'K':
- max_size = atof(max_size_arg) * 1024;
- break;
- case 'm': case 'M':
- max_size = atof(max_size_arg) * 1024*1024;
- break;
- case 'g': case 'G':
- max_size = atof(max_size_arg) * 1024*1024*1024;
- break;
- case '\0':
- max_size = atof(max_size_arg);
- break;
- default:
- max_size = 0;
- break;
- }
- if (max_size <= 0) {
+ if ((max_size = parse_size_arg(max_size_arg)) <= 0) {
snprintf(err_buf, sizeof err_buf,
"--max-size value is invalid: %s\n",
max_size_arg);
snprintf(err_buf, sizeof err_buf,
"--max-size value is invalid: %s\n",
max_size_arg);
- if (write_batch || read_batch) {
- if (dry_run) {
- snprintf(err_buf, sizeof err_buf,
- "--%s-batch cannot be used with --dry_run (-n)\n",
- write_batch ? "write" : "read");
- return 0;
- }
+ if (write_batch > 0 || read_batch) {
+ if (remove_sent_files) {
+ /* We only want to infer this refusal of --remove-sent-files
+ * via the refusal of "delete", not any of the "delete-FOO"
+ * options. */
+ if (refused_delete && am_sender) {
+ create_refuse_error(refused_delete);
+ return 0;
+ }
+ need_messages_from_generator = 1;
+ }
+
partial_dir = sanitize_path(NULL, partial_dir, NULL, 0);
if (backup_dir)
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
partial_dir = sanitize_path(NULL, partial_dir, NULL, 0);
if (backup_dir)
backup_dir = sanitize_path(NULL, backup_dir, NULL, 0);
- if (check_filter(elp, backup_dir, 1) < 0)
- goto options_rejected;
- }
- }
- if (server_filter_list.head && files_from) {
- if (!*files_from)
- goto options_rejected;
- clean_fname(files_from, 1);
- if (check_filter(&server_filter_list, files_from, 0) < 0) {
- options_rejected:
- snprintf(err_buf, sizeof err_buf,
- "Your options have been rejected by the server.\n");
- return 0;
+ if (check_filter(elp, backup_dir, 1) < 0) {
+ options_rejected:
+ snprintf(err_buf, sizeof err_buf,
+ "Your options have been rejected by the server.\n");
+ return 0;
+ }
+ if (make_backups && !backup_dir)
+ omit_dir_times = 1;
+
+ if (log_format) {
+ if (log_format_has(log_format, 'i'))
+ log_format_has_i = 1;
+ if (!log_format_has(log_format, 'b')
+ && !log_format_has(log_format, 'c'))
+ log_before_transfer = !am_server;
+ } else if (itemize_changes) {
+ log_format = "%i %n%L";
+ log_format_has_i = 1;
+ log_before_transfer = !am_server;
+ }
+ if (sanitize_paths)
+ files_from = sanitize_path(NULL, files_from, NULL, 0);
+ if (server_filter_list.head) {
+ if (!*files_from)
+ goto options_rejected;
+ clean_fname(files_from, 1);
+ if (check_filter(&server_filter_list, files_from, 0) < 0)
+ goto options_rejected;
+ }
filesfrom_fd = open(files_from, O_RDONLY|O_BINARY);
if (filesfrom_fd < 0) {
snprintf(err_buf, sizeof err_buf,
filesfrom_fd = open(files_from, O_RDONLY|O_BINARY);
if (filesfrom_fd < 0) {
snprintf(err_buf, sizeof err_buf,
/* This is a complete hack - blame Rusty. FIXME!
* This hack is only needed for older rsync versions that
* don't understand the --list-only option. */
/* This is a complete hack - blame Rusty. FIXME!
* This hack is only needed for older rsync versions that
* don't understand the --list-only option. */
+ /* The server side doesn't use our log-format, but in certain
+ * circumstances they need to know a little about the option. */
+ if (log_format && am_sender) {
+ if (log_format_has_i)
+ args[ac++] = "--log-format=%i";
+ else if (log_format_has_o_or_i)
+ args[ac++] = "--log-format=%o";
+ else if (!verbose)
+ args[ac++] = "--log-format=X";
+ }
+
-/**
- * Return the position of a ':' IF it is not part of a filename (i.e. as
- * long as it doesn't occur after a slash.
- */
-char *find_colon(char *s)
+/* Look for a HOST specfication of the form "HOST:PATH", "HOST::PATH", or
+ * "rsync://HOST:PORT/PATH". If found, *host_ptr will be set to some allocated
+ * memory with the HOST. If a daemon-accessing spec was specified, the value
+ * of *port_ptr will contain a non-0 port number, otherwise it will be set to
+ * 0. The return value is a pointer to the PATH. Note that the HOST spec can
+ * be an IPv6 literal address enclosed in '[' and ']' (such as "[::1]" or
+ * "[::ffff:127.0.0.1]") which is returned without the '[' and ']'. */
+char *check_for_hostspec(char *s, char **host_ptr, int *port_ptr)
+ char *p;
+ int not_host;
+
+ if (port_ptr && strncasecmp(URL_PREFIX, s, strlen(URL_PREFIX)) == 0) {
+ char *path;
+ int hostlen;
+ s += strlen(URL_PREFIX);
+ if ((p = strchr(s, '/')) != NULL) {
+ hostlen = p - s;
+ path = p + 1;
+ } else {
+ hostlen = strlen(s);
+ path = "";
+ }
+ if (*s == '[' && (p = strchr(s, ']')) != NULL) {
+ s++;
+ hostlen = p - s;
+ if (p[1] == ':')
+ *port_ptr = atoi(p+2);
+ } else {
+ if ((p = strchr(s, ':')) != NULL) {
+ hostlen = p - s;
+ *port_ptr = atoi(p+1);
+ }
+ }
+ if (!*port_ptr)
+ *port_ptr = RSYNC_PORT;
+ *host_ptr = new_array(char, hostlen + 1);
+ strlcpy(*host_ptr, s, hostlen + 1);
+ return path;
+ }
- /* now check to see if there is a / in the string before the : - if there is then
- discard the colon on the assumption that the : is part of a filename */
- p2 = strchr(s,'/');
- if (p2 && p2 < p)
- return NULL;
+ *host_ptr = new_array(char, p - s + 1);
+ strlcpy(*host_ptr, s, p - s + 1);
+
+ if (p[1] == ':') {
+ if (port_ptr && !*port_ptr)
+ *port_ptr = RSYNC_PORT;
+ return p + 2;
+ }
+ if (port_ptr)
+ *port_ptr = 0;