From: Wayne Davison Date: Sun, 26 Jul 2020 08:56:30 +0000 (-0700) Subject: Complain about a missing/non-dir `--temp-dir`. X-Git-Tag: v3.2.3pre1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6967eca58c7438ebc99a435a49549487bb9af75;p=thirdparty%2Frsync.git Complain about a missing/non-dir `--temp-dir`. --- diff --git a/NEWS.md b/NEWS.md index 03c0e5cb..66b88758 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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. diff --git a/main.c b/main.c index e68d73c4..bfb69797 100644 --- a/main.c +++ b/main.c @@ -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) {