mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-10-21 21:34:17 -04:00
Use the new safe_fname() function.
This commit is contained in:
1 parent
b4afd23c30
commit
ecc81fce17
4 files changed
+59
-45
No files matched your search
+23
-16
@@ -270,14 +270,14 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
return;
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);
|
||||
rprintf(FINFO, "recv_generator(%s,%d)\n", safe_fname(fname), i);
|
||||
|
||||
if (server_exclude_list.head
|
||||
&& check_exclude(&server_exclude_list, fname,
|
||||
S_ISDIR(file->mode)) < 0) {
|
||||
if (verbose) {
|
||||
rprintf(FINFO, "skipping server-excluded file \"%s\"\n",
|
||||
fname);
|
||||
safe_fname(fname));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -286,8 +286,10 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
|
||||
if (only_existing && statret == -1 && errno == ENOENT) {
|
||||
/* we only want to update existing files */
|
||||
if (verbose > 1)
|
||||
rprintf(FINFO, "not creating new file \"%s\"\n", fname);
|
||||
if (verbose > 1) {
|
||||
rprintf(FINFO, "not creating new file \"%s\"\n",
|
||||
safe_fname(fname));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -331,7 +333,7 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
* and modification-time repair. */
|
||||
if (set_perms(fname, file, statret ? NULL : &st, 0)
|
||||
&& verbose && f_out != -1)
|
||||
rprintf(FINFO,"%s/\n",fname);
|
||||
rprintf(FINFO, "%s/\n", safe_fname(fname));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -367,11 +369,12 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
}
|
||||
if (do_symlink(file->u.link,fname) != 0) {
|
||||
rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed",
|
||||
full_fname(fname), file->u.link);
|
||||
full_fname(fname), safe_fname(file->u.link));
|
||||
} else {
|
||||
set_perms(fname,file,NULL,0);
|
||||
if (verbose) {
|
||||
rprintf(FINFO,"%s -> %s\n", fname,file->u.link);
|
||||
rprintf(FINFO, "%s -> %s\n", safe_fname(fname),
|
||||
safe_fname(file->u.link));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -386,15 +389,18 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
delete_file(fname);
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO,"mknod(%s,0%o,0x%x)\n",
|
||||
fname,(int)file->mode,(int)file->u.rdev);
|
||||
safe_fname(fname),
|
||||
(int)file->mode, (int)file->u.rdev);
|
||||
}
|
||||
if (do_mknod(fname,file->mode,file->u.rdev) != 0) {
|
||||
rsyserr(FERROR, errno, "mknod %s failed",
|
||||
full_fname(fname));
|
||||
} else {
|
||||
set_perms(fname,file,NULL,0);
|
||||
if (verbose)
|
||||
rprintf(FINFO,"%s\n",fname);
|
||||
if (verbose) {
|
||||
rprintf(FINFO, "%s\n",
|
||||
safe_fname(fname));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
set_perms(fname, file, &st, PERMS_REPORT);
|
||||
@@ -407,7 +413,8 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
return;
|
||||
|
||||
if (!S_ISREG(file->mode)) {
|
||||
rprintf(FINFO, "skipping non-regular file \"%s\"\n",fname);
|
||||
rprintf(FINFO, "skipping non-regular file \"%s\"\n",
|
||||
safe_fname(fname));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -427,7 +434,7 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
if (do_link(fnamecmpbuf, fname) != 0) {
|
||||
if (verbose > 0) {
|
||||
rsyserr(FINFO, errno, "link %s => %s",
|
||||
fnamecmpbuf, fname);
|
||||
fnamecmpbuf, safe_fname(fname));
|
||||
}
|
||||
}
|
||||
fnamecmp = fnamecmpbuf;
|
||||
@@ -468,14 +475,14 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
|
||||
if (opt_ignore_existing && fnamecmp == fname) {
|
||||
if (verbose > 1)
|
||||
rprintf(FINFO,"%s exists\n",fname);
|
||||
rprintf(FINFO, "%s exists\n", safe_fname(fname));
|
||||
return;
|
||||
}
|
||||
|
||||
if (update_only && fnamecmp == fname
|
||||
&& cmp_modtime(st.st_mtime, file->modtime) > 0) {
|
||||
if (verbose > 1)
|
||||
rprintf(FINFO,"%s is newer\n",fname);
|
||||
rprintf(FINFO, "%s is newer\n", safe_fname(fname));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -511,8 +518,8 @@ static void recv_generator(char *fname, struct file_struct *file, int i,
|
||||
}
|
||||
|
||||
if (verbose > 3) {
|
||||
rprintf(FINFO,"gen mapped %s of size %.0f\n", fnamecmp,
|
||||
(double)st.st_size);
|
||||
rprintf(FINFO, "gen mapped %s of size %.0f\n",
|
||||
safe_fname(fnamecmp), (double)st.st_size);
|
||||
}
|
||||
|
||||
if (verbose > 2)
|
||||
|
||||
+20
-15
@@ -62,7 +62,7 @@ static void delete_one(char *fn, int is_dir)
|
||||
rsyserr(FERROR, errno, "delete_one: unlink %s failed",
|
||||
full_fname(fn));
|
||||
} else if (verbose)
|
||||
rprintf(FINFO, "deleting %s\n", fn);
|
||||
rprintf(FINFO, "deleting %s\n", safe_fname(fn));
|
||||
} else {
|
||||
if (do_rmdir(fn) != 0) {
|
||||
if (errno == ENOTDIR && keep_dirlinks) {
|
||||
@@ -74,8 +74,10 @@ static void delete_one(char *fn, int is_dir)
|
||||
"delete_one: rmdir %s failed",
|
||||
full_fname(fn));
|
||||
}
|
||||
} else if (verbose)
|
||||
rprintf(FINFO, "deleting directory %s\n", fn);
|
||||
} else if (verbose) {
|
||||
rprintf(FINFO, "deleting directory %s\n",
|
||||
safe_fname(fn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +117,7 @@ void delete_files(struct file_list *flist)
|
||||
continue;
|
||||
|
||||
if (verbose > 1)
|
||||
rprintf(FINFO, "deleting in %s\n", fbuf);
|
||||
rprintf(FINFO, "deleting in %s\n", safe_fname(fbuf));
|
||||
|
||||
for (i = local_file_list->count-1; i >= 0; i--) {
|
||||
if (max_delete && deletion_count > max_delete)
|
||||
@@ -126,8 +128,10 @@ void delete_files(struct file_list *flist)
|
||||
char *f = f_name(local_file_list->files[i]);
|
||||
if (make_backups && (backup_dir || !is_backup_file(f))) {
|
||||
make_backup(f);
|
||||
if (verbose)
|
||||
rprintf(FINFO, "deleting %s\n", f);
|
||||
if (verbose) {
|
||||
rprintf(FINFO, "deleting %s\n",
|
||||
safe_fname(f));
|
||||
}
|
||||
} else {
|
||||
int mode = local_file_list->files[i]->mode;
|
||||
delete_one(f, S_ISDIR(mode) != 0);
|
||||
@@ -221,7 +225,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
|
||||
mapbuf = map_file(fd_r, size_r, sum.blength);
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "recv mapped %s of size %.0f\n",
|
||||
fname_r, (double)size_r);
|
||||
safe_fname(fname_r), (double)size_r);
|
||||
}
|
||||
} else
|
||||
mapbuf = NULL;
|
||||
@@ -396,15 +400,15 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
|
||||
fname = f_name_to(file, fbuf);
|
||||
|
||||
if (dry_run) {
|
||||
if (!am_server && verbose)
|
||||
rprintf(FINFO, "%s\n", fname);
|
||||
if (!am_server && verbose) /* log the transfer */
|
||||
rprintf(FINFO, "%s\n", safe_fname(fname));
|
||||
continue;
|
||||
}
|
||||
|
||||
initial_stats = stats;
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO,"recv_files(%s)\n",fname);
|
||||
rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname));
|
||||
|
||||
fnamecmp = fname;
|
||||
|
||||
@@ -416,7 +420,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
|
||||
}
|
||||
if (i < next_gen_i) {
|
||||
rprintf(FINFO, "skipping update for \"%s\"\n",
|
||||
fname);
|
||||
safe_fname(fname));
|
||||
discard_receive_data(f_in, file->length);
|
||||
continue;
|
||||
}
|
||||
@@ -428,7 +432,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
|
||||
if (verbose) {
|
||||
rprintf(FINFO,
|
||||
"skipping server-excluded update for \"%s\"\n",
|
||||
fname);
|
||||
safe_fname(fname));
|
||||
}
|
||||
discard_receive_data(f_in, file->length);
|
||||
continue;
|
||||
@@ -527,8 +531,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
|
||||
cleanup_set(fnametmp, fname, file, fd1, fd2);
|
||||
}
|
||||
|
||||
if (!am_server && verbose)
|
||||
rprintf(FINFO, "%s\n", fname);
|
||||
if (!am_server && verbose) /* log the transfer */
|
||||
rprintf(FINFO, "%s\n", safe_fname(fname));
|
||||
|
||||
/* recv file data */
|
||||
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
|
||||
@@ -567,7 +571,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
|
||||
}
|
||||
rprintf(msgtype,
|
||||
"%s: %s failed verification -- update %sed%s.\n",
|
||||
errstr, fname, keptstr, redostr);
|
||||
errstr, safe_fname(fname),
|
||||
keptstr, redostr);
|
||||
}
|
||||
if (csum_length != SUM_LENGTH) {
|
||||
char buf[4];
|
||||
|
||||
@@ -98,7 +98,7 @@ int delete_file(char *fname)
|
||||
continue;
|
||||
pathjoin(buf, sizeof buf, fname, dname);
|
||||
if (verbose > 0)
|
||||
rprintf(FINFO, "deleting %s\n", buf);
|
||||
rprintf(FINFO, "deleting %s\n", safe_fname(buf));
|
||||
if (delete_file(buf) != 0) {
|
||||
closedir(d);
|
||||
return -1;
|
||||
|
||||
@@ -115,7 +115,7 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
||||
struct sum_struct *s;
|
||||
struct map_struct *mbuf = NULL;
|
||||
STRUCT_STAT st;
|
||||
char fname[MAXPATHLEN];
|
||||
char *fname2, fname[MAXPATHLEN];
|
||||
int i;
|
||||
struct file_struct *file;
|
||||
int phase = 0;
|
||||
@@ -160,15 +160,14 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
||||
fname[offset++] = '/';
|
||||
} else
|
||||
offset = 0;
|
||||
f_name_to(file, fname + offset);
|
||||
fname2 = f_name_to(file, fname + offset);
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO, "send_files(%d, %s)\n", i, fname);
|
||||
|
||||
if (dry_run) {
|
||||
if (!am_server && verbose) {
|
||||
rprintf(FINFO, "%s\n", fname+offset);
|
||||
}
|
||||
if (!am_server && verbose) /* log the transfer */
|
||||
rprintf(FINFO, "%s\n", safe_fname(fname2));
|
||||
write_int(f_out, i);
|
||||
continue;
|
||||
}
|
||||
@@ -213,19 +212,20 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
||||
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "send_files mapped %s of size %.0f\n",
|
||||
fname, (double)st.st_size);
|
||||
safe_fname(fname), (double)st.st_size);
|
||||
}
|
||||
|
||||
write_int(f_out, i);
|
||||
write_sum_head(f_out, s);
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO, "calling match_sums %s\n", fname);
|
||||
|
||||
if (!am_server && verbose) {
|
||||
rprintf(FINFO, "%s\n", fname+offset);
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "calling match_sums %s\n",
|
||||
safe_fname(fname));
|
||||
}
|
||||
|
||||
if (!am_server && verbose) /* log the transfer */
|
||||
rprintf(FINFO, "%s\n", safe_fname(fname2));
|
||||
|
||||
set_compression(fname);
|
||||
|
||||
match_sums(f_out, s, mbuf, st.st_size);
|
||||
@@ -244,8 +244,10 @@ void send_files(struct file_list *flist, int f_out, int f_in)
|
||||
|
||||
free_sums(s);
|
||||
|
||||
if (verbose > 2)
|
||||
rprintf(FINFO, "sender finished %s\n", fname);
|
||||
if (verbose > 2) {
|
||||
rprintf(FINFO, "sender finished %s\n",
|
||||
safe_fname(fname));
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose > 2)
|
||||
|
||||
Reference in new issue
Block a user