| 1146 | } |
| 1147 | |
| 1148 | static void do_server_recv(int f_in, int f_out, int argc, char *argv[]) |
| 1149 | { |
| 1150 | int exit_code; |
| 1151 | struct file_list *flist; |
| 1152 | char *local_name = NULL; |
| 1153 | int negated_levels; |
| 1154 | |
| 1155 | if (filesfrom_fd >= 0 && msgs2stderr != 1 && protocol_version < 31) { |
| 1156 | /* We can't mix messages with files-from data on the socket, |
| 1157 | * so temporarily turn off info/debug messages. */ |
| 1158 | negate_output_levels(); |
| 1159 | negated_levels = 1; |
| 1160 | } else |
| 1161 | negated_levels = 0; |
| 1162 | |
| 1163 | if (DEBUG_GTE(RECV, 1)) |
| 1164 | rprintf(FINFO, "server_recv(%d) starting pid=%d\n", argc, (int)getpid()); |
| 1165 | |
| 1166 | if (am_daemon && read_only) { |
| 1167 | rprintf(FERROR,"ERROR: module is read only\n"); |
| 1168 | exit_cleanup(RERR_SYNTAX); |
| 1169 | return; |
| 1170 | } |
| 1171 | |
| 1172 | become_copy_as_user(); |
| 1173 | |
| 1174 | if (argc > 0) { |
| 1175 | char *dir = argv[0]; |
| 1176 | argc--; |
| 1177 | argv++; |
| 1178 | if (!am_daemon && !change_dir(dir, CD_NORMAL)) { |
| 1179 | rsyserr(FERROR, errno, "change_dir#4 %s failed", |
| 1180 | full_fname(dir)); |
| 1181 | exit_cleanup(RERR_FILESELECT); |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | if (protocol_version >= 30) |
| 1186 | io_start_multiplex_in(f_in); |
| 1187 | else |
| 1188 | io_start_buffering_in(f_in); |
| 1189 | recv_filter_list(f_in); |
| 1190 | |
| 1191 | if (filesfrom_fd >= 0) { |
| 1192 | /* We need to send the files-from names to the sender at the |
| 1193 | * same time that we receive the file-list from them, so we |
| 1194 | * need the IO routines to automatically write out the names |
| 1195 | * onto our f_out socket as we read the file-list. This |
| 1196 | * avoids both deadlock and extra delays/buffers. */ |
| 1197 | start_filesfrom_forwarding(filesfrom_fd); |
| 1198 | filesfrom_fd = -1; |
| 1199 | } |
| 1200 | |
| 1201 | flist = recv_file_list(f_in, -1); |
| 1202 | if (!flist) { |
| 1203 | rprintf(FERROR,"server_recv: recv_file_list error\n"); |
| 1204 | exit_cleanup(RERR_FILESELECT); |
| 1205 | } |
no test coverage detected