X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/34937987a6ec0ab6d0585c650c2d7114f8929b4b..f041b025573c494d19215134fe4f39e729a59d76:/clientserver.c diff --git a/clientserver.c b/clientserver.c index 4b4a08f9..f55117ca 100644 --- a/clientserver.c +++ b/clientserver.c @@ -28,6 +28,7 @@ #include "rsync.h" extern int verbose; +extern int quiet; extern int list_only; extern int am_sender; extern int am_server; @@ -46,20 +47,26 @@ extern int no_detach; extern int default_af_hint; extern char *bind_address; extern char *sockopts; -extern struct filter_list_struct server_filter_list; extern char *config_file; extern char *files_from; extern char *tmpdir; +extern struct chmod_mode_struct *chmod_modes; +extern struct filter_list_struct server_filter_list; char *auth_user; int read_only = 0; int daemon_log_format_has_i = 0; int daemon_log_format_has_o_or_i = 0; int module_id = -1; +struct chmod_mode_struct *daemon_chmod_modes; /* Length of lp_path() string when in daemon mode & not chrooted, else 0. */ unsigned int module_dirlen = 0; +#ifdef HAVE_SIGACTION +static struct sigaction sigact; +#endif + /** * Run a client connected to an rsyncd. The alternative to this * function for remote-shell connections is do_cmd(). @@ -618,6 +625,7 @@ static int rsync_module(int f_in, int f_out, int i) verbose = 0; /* future verbosity is controlled by client options */ ret = parse_arguments(&argc, (const char ***) &argv, 0); + quiet = 0; /* Don't let someone try to be tricky. */ if (filesfrom_fd == 0) filesfrom_fd = f_in; @@ -682,6 +690,19 @@ static int rsync_module(int f_in, int f_out, int i) if (lp_timeout(i) && lp_timeout(i) > io_timeout) set_io_timeout(lp_timeout(i)); + /* If we have some incoming/outgoing chmod changes, append them to + * any user-specified changes (making our changes have priority). + * We also get a pointer to just our changes so that a receiver + * process can use them separately if --perms wasn't specified. */ + if (am_sender) + p = lp_outgoing_chmod(i); + else + p = lp_incoming_chmod(i); + if (*p && !(daemon_chmod_modes = parse_chmod(p, &chmod_modes))) { + rprintf(FLOG, "Invalid \"%sing chmod\" directive: %s\n", + am_sender ? "outgo" : "incom", p); + } + start_server(f_in, f_out, argc, argv); return 0; @@ -760,6 +781,10 @@ int start_daemon(int f_in, int f_out) return -1; if (!*line || strcmp(line, "#list") == 0) { + char *addr = client_addr(f_in); + char *host = client_name(f_in); + rprintf(FLOG, "module-list request from %s (%s)\n", + host, addr); send_listing(f_out); return -1; } @@ -779,6 +804,11 @@ int start_daemon(int f_in, int f_out) return -1; } +#ifdef HAVE_SIGACTION + sigact.sa_flags = SA_NOCLDSTOP; +#endif + SIGACTION(SIGCHLD, remember_children); + return rsync_module(f_in, f_out, i); }