X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/141c62659eb64ba27eda7e9f79e45df9594526c5..fa3e4a0548699ccaac41df2428fe1ad9d3659435:/clientserver.c diff --git a/clientserver.c b/clientserver.c index f3adfe97..3b1567bf 100644 --- a/clientserver.c +++ b/clientserver.c @@ -45,10 +45,12 @@ extern int orig_umask; extern int no_detach; extern int default_af_hint; extern char *bind_address; -extern struct filter_list_struct server_filter_list; +extern char *sockopts; 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; @@ -98,6 +100,8 @@ int start_socket_client(char *host, char *path, int argc, char *argv[]) if (fd == -1) exit_cleanup(RERR_SOCKETIO); + set_socket_options(fd, sockopts); + ret = start_inband_exchange(user, path, fd, fd, argc); return ret ? ret : client_run(fd, fd, -1, argc, argv); @@ -297,7 +301,7 @@ static int rsync_module(int f_in, int f_out, int i) if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) { if (errno) { rsyserr(FLOG, errno, "failed to open lock file %s", - safe_fname(lp_lock_file(i))); + lp_lock_file(i)); io_printf(f_out, "@ERROR: failed to open lock file\n"); } else { rprintf(FLOG, "max connections (%d) reached\n", @@ -494,14 +498,14 @@ static int rsync_module(int f_in, int f_out, int i) */ if (chroot(lp_path(i))) { rsyserr(FLOG, errno, "chroot %s failed", - safe_fname(lp_path(i))); + lp_path(i)); io_printf(f_out, "@ERROR: chroot failed\n"); return -1; } if (!push_dir("/")) { rsyserr(FLOG, errno, "chdir %s failed\n", - safe_fname(lp_path(i))); + lp_path(i)); io_printf(f_out, "@ERROR: chdir failed\n"); return -1; } @@ -509,7 +513,7 @@ static int rsync_module(int f_in, int f_out, int i) } else { if (!push_dir(lp_path(i))) { rsyserr(FLOG, errno, "chdir %s failed\n", - safe_fname(lp_path(i))); + lp_path(i)); io_printf(f_out, "@ERROR: chdir failed\n"); return -1; } @@ -679,6 +683,16 @@ 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 (am_sender) + p = lp_outgoing_chmod(i); + else + p = lp_incoming_chmod(i); + if (*p && !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; @@ -718,7 +732,10 @@ int start_daemon(int f_in, int f_out) if (!am_server) { set_socket_options(f_in, "SO_KEEPALIVE"); - set_socket_options(f_in, lp_socket_options()); + if (sockopts) + set_socket_options(f_in, sockopts); + else + set_socket_options(f_in, lp_socket_options()); set_nonblocking(f_in); } @@ -822,7 +839,7 @@ int daemon_main(void) 0666 & ~orig_umask)) == -1) { cleanup_set_pid(0); rsyserr(FLOG, errno, "failed to create pid file %s", - safe_fname(pid_file)); + pid_file); exit_cleanup(RERR_FILEIO); } snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);