]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Complain about a missing/non-dir `--temp-dir`.
authorWayne Davison <wayne@opencoder.net>
Sun, 26 Jul 2020 08:56:30 +0000 (01:56 -0700)
committerWayne Davison <wayne@opencoder.net>
Sun, 26 Jul 2020 09:01:30 +0000 (02:01 -0700)
NEWS.md
main.c

diff --git a/NEWS.md b/NEWS.md
index 03c0e5cb4ea7ef7e33106f83505c8262f22fb66b..66b887588f4dedf8f7b767278f25ea55fa95497f 100644 (file)
--- 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 e68d73c420e7ec4283eda9182ef69120faec03c9..bfb69797f8520ddfd2d63a5da16ca16336006476 100644 (file)
--- 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) {