Complain about a missing/non-dir --temp-dir.

This commit is contained in:
Wayne Davison
2020-07-26 01:56:30 -07:00
parent 8455bf66c2
commit f6967eca58
2 changed files with 21 additions and 0 deletions

View File

@@ -23,6 +23,9 @@
get out of sync between the sender and the receiver, which could cause a
device to get created with the wrong major value in its major,minor pair.
- Rsync now complains about a missing `--temp-dir` before starting any file
transfers.
### ENHANCEMENTS:
- Allow `--max-alloc=0` to specify no limit to the alloc sanity check.

18
main.c
View File

@@ -97,6 +97,7 @@ extern char *shell_cmd;
extern char *password_file;
extern char *backup_dir;
extern char *copy_as;
extern char *tmpdir;
extern char curr_dir[MAXPATHLEN];
extern char backup_dir_buf[MAXPATHLEN];
extern char *basis_dir[MAX_BASIS_DIRS+1];
@@ -1002,6 +1003,23 @@ static int do_recv(int f_in, int f_out, char *local_name)
backup_dir_buf[backup_dir_len-1] = '/';
}
if (tmpdir) {
STRUCT_STAT st;
int ret = do_stat(tmpdir, &st);
if (ret < 0 || !S_ISDIR(st.st_mode)) {
if (ret == 0) {
rprintf(FERROR, "The temp-dir is not a directory: %s\n", tmpdir);
exit_cleanup(RERR_SYNTAX);
}
if (errno == ENOENT) {
rprintf(FERROR, "The temp-dir does not exist: %s\n", tmpdir);
exit_cleanup(RERR_SYNTAX);
}
rprintf(FERROR, "Failed to stat temp-dir %s: %s\n", tmpdir, strerror(errno));
exit_cleanup(RERR_FILEIO);
}
}
io_flush(FULL_FLUSH);
if ((pid = do_fork()) == -1) {