X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/8dad7fc6eace2c406c279ce98a00653085c700ca..46bffd98cbd32846ed5144e0b5e9ddcd0a19fd04:/clientserver.c diff --git a/clientserver.c b/clientserver.c index 87916017..d354ef74 100644 --- a/clientserver.c +++ b/clientserver.c @@ -87,15 +87,12 @@ int start_socket_client(char *host, char *path, int argc, char *argv[]) return -1; } - if ((p = strchr(host, '@')) != NULL) { + if ((p = strrchr(host, '@')) != NULL) { user = host; host = p+1; *p = '\0'; } - if (rsync_port == 0) - rsync_port = RSYNC_PORT; - fd = open_socket_out_wrapped(host, rsync_port, bind_address, default_af_hint); if (fd == -1) @@ -286,10 +283,10 @@ static int rsync_module(int f_in, int f_out, int i) read_only = 1; if (lp_transfer_logging(i)) { - if (strstr(lp_log_format(i), "%i") != NULL) + if (log_format_has(lp_log_format(i), 'i')) daemon_log_format_has_i = 1; if (daemon_log_format_has_i - || strstr(lp_log_format(i), "%o") != NULL) + || log_format_has(lp_log_format(i), 'o')) daemon_log_format_has_o_or_i = 1; } @@ -324,13 +321,11 @@ static int rsync_module(int f_in, int f_out, int i) /* TODO: Perhaps take a list of gids, and make them into the * supplementary groups. */ - if (use_chroot) { + if (use_chroot || (module_dirlen = strlen(lp_path(i))) == 1) { module_dirlen = 0; set_filter_dir("/", 1); - } else { - module_dirlen = strlen(lp_path(i)); + } else set_filter_dir(lp_path(i), module_dirlen); - } p = lp_filter(i); parse_rule(&server_filter_list, p, MATCHFLG_WORD_SPLIT, @@ -498,8 +493,24 @@ static int rsync_module(int f_in, int f_out, int i) * get the error back to the client. This means getting * the protocol setup finished first in later versions. */ setup_protocol(f_out, f_in); - if (files_from && !am_sender && strcmp(files_from, "-") != 0) - write_byte(f_out, 0); + if (!am_sender) { + /* Since we failed in our option parsing, we may not + * have finished parsing that the client sent us a + * --files-from option, so look for it manually. + * Without this, the socket would be in the wrong + * state for the upcoming error message. */ + if (!files_from) { + int i; + for (i = 0; i < argc; i++) { + if (strncmp(argv[i], "--files-from", 12) == 0) { + files_from = ""; + break; + } + } + } + if (files_from) + write_byte(f_out, 0); + } io_start_multiplex_out(); }