X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/f6f74b93efc1b37f6135650dc034d3403ef482b6..e9489cd6cb380b30727bd3d074eacc59abca080e:/generator.c diff --git a/generator.c b/generator.c index 80db57dd..27e5b97d 100644 --- a/generator.c +++ b/generator.c @@ -1284,7 +1284,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, skip_dir = NULL; } - if (daemon_filter_list.head) { + if (daemon_filter_list.head && (*fname != '.' || fname[1])) { if (check_filter(&daemon_filter_list, FLOG, fname, is_dir) < 0) { if (is_dir < 0) return; @@ -1488,7 +1488,6 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, delete_in_dir(fname, file, &real_sx.st.st_dev); else change_local_filter_dir(fname, strlen(fname), F_DEPTH(file)); - } goto cleanup; } @@ -1869,15 +1868,21 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, close(fd); goto cleanup; } - if ((f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0 - && (errno != ENOENT || make_bak_dir(backupptr) < 0 - || (f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0)) { - rsyserr(FERROR_XFER, errno, "open %s", - full_fname(backupptr)); - unmake_file(back_file); - back_file = NULL; - close(fd); - goto cleanup; + if ((f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) { + int save_errno = errno ? errno : EINVAL; /* 0 paranoia */ + if (errno == ENOENT && make_bak_dir(backupptr) == 0) { + if ((f_copy = do_open(backupptr, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, 0600)) < 0) + save_errno = errno ? errno : save_errno; + else + save_errno = 0; + } + if (save_errno) { + rsyserr(FERROR_XFER, save_errno, "open %s", full_fname(backupptr)); + unmake_file(back_file); + back_file = NULL; + close(fd); + goto cleanup; + } } fnamecmp_type = FNAMECMP_BACKUP; } @@ -1939,9 +1944,16 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, cleanup: if (back_file) { + int save_preserve_xattrs = preserve_xattrs; if (f_copy >= 0) close(f_copy); +#ifdef SUPPORT_XATTRS + if (preserve_xattrs) + copy_xattrs(fname, backupptr); +#endif + preserve_xattrs = 0; set_file_attrs(backupptr, back_file, NULL, NULL, 0); + preserve_xattrs = save_preserve_xattrs; if (verbose > 1) { rprintf(FINFO, "backed up %s to %s\n", fname, backupptr);