Skip to content

Commit

Permalink
Got rid of calls to (the soon to vanish) safe_fname() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Davison committed Jan 13, 2006
1 parent 0ee32c6 commit 45c49b5
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 122 deletions.
6 changes: 3 additions & 3 deletions authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ static int get_secret(int module, char *user, char *secret, int len)
return 0;

if (do_stat(fname, &st) == -1) {
rsyserr(FLOG, errno, "stat(%s)", safe_fname(fname));
rsyserr(FLOG, errno, "stat(%s)", fname);
ok = 0;
} else if (lp_strict_modes(module)) {
if ((st.st_mode & 06) != 0) {
Expand Down Expand Up @@ -160,14 +160,14 @@ static char *getpassf(char *filename)

if ((fd = open(filename,O_RDONLY)) < 0) {
rsyserr(FERROR, errno, "could not open password file \"%s\"",
safe_fname(filename));
filename);
if (envpw)
rprintf(FERROR, "falling back to RSYNC_PASSWORD environment variable.\n");
return NULL;
}

if (do_stat(filename, &st) == -1) {
rsyserr(FERROR, errno, "stat(%s)", safe_fname(filename));
rsyserr(FERROR, errno, "stat(%s)", filename);
ok = 0;
} else if ((st.st_mode & 06) != 0) {
rprintf(FERROR,"password file must not be other-accessible\n");
Expand Down
15 changes: 7 additions & 8 deletions backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ static int make_simple_backup(char *fname)
if (do_rename(fname, fnamebak) == 0) {
if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname),
safe_fname(fnamebak));
fname, fnamebak);
}
break;
}
Expand All @@ -81,7 +80,7 @@ static int make_simple_backup(char *fname)
continue;

rsyserr(FERROR, rename_errno, "rename %s to backup %s",
safe_fname(fname), safe_fname(fnamebak));
fname, fnamebak);
errno = rename_errno;
return 0;
}
Expand Down Expand Up @@ -197,7 +196,7 @@ static int keep_backup(char *fname)
full_fname(buf));
} else if (verbose > 2) {
rprintf(FINFO, "make_backup: DEVICE %s successful.\n",
safe_fname(fname));
fname);
}
kept = 1;
do_unlink(fname);
Expand Down Expand Up @@ -235,7 +234,7 @@ static int keep_backup(char *fname)
|| do_symlink(file->u.link, buf) < 0)) {
rsyserr(FERROR, errno, "link %s -> \"%s\"",
full_fname(buf),
safe_fname(file->u.link));
file->u.link);
}
do_unlink(fname);
kept = 1;
Expand All @@ -245,15 +244,15 @@ static int keep_backup(char *fname)

if (!kept && !S_ISREG(file->mode)) {
rprintf(FINFO, "make_bak: skipping non-regular file %s\n",
safe_fname(fname));
fname);
return 1;
}

/* move to keep tree if a file */
if (!kept) {
if (robust_move(fname, buf) != 0) {
rsyserr(FERROR, errno, "keep_backup failed: %s -> \"%s\"",
full_fname(fname), safe_fname(buf));
full_fname(fname), buf);
} else if (st.st_nlink > 1) {
/* If someone has hard-linked the file into the backup
* dir, rename() might return success but do nothing! */
Expand All @@ -265,7 +264,7 @@ static int keep_backup(char *fname)

if (verbose > 1) {
rprintf(FINFO, "backed up %s to %s\n",
safe_fname(fname), safe_fname(buf));
fname, buf);
}
return 1;
}
Expand Down
12 changes: 6 additions & 6 deletions batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
S_IRUSR | S_IWUSR | S_IEXEC);
if (fd < 0) {
rsyserr(FERROR, errno, "Batch file %s open error",
safe_fname(filename));
filename);
exit_cleanup(1);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ void write_batch_shell_file(int argc, char *argv[], int file_arg_cnt)
write_filter_rules(fd);
if (write(fd, "\n", 1) != 1 || close(fd) < 0) {
rsyserr(FERROR, errno, "Batch file %s write error",
safe_fname(filename));
filename);
exit_cleanup(1);
}
}
Expand All @@ -229,14 +229,14 @@ void show_flist(int index, struct file_struct **fptr)
(double) fptr[i]->length);
rprintf(FINFO, "flist->mode=%#o\n", (int) fptr[i]->mode);
rprintf(FINFO, "flist->basename=%s\n",
safe_fname(fptr[i]->basename));
fptr[i]->basename);
if (fptr[i]->dirname) {
rprintf(FINFO, "flist->dirname=%s\n",
safe_fname(fptr[i]->dirname));
fptr[i]->dirname);
}
if (am_sender && fptr[i]->dir.root) {
rprintf(FINFO, "flist->dir.root=%s\n",
safe_fname(fptr[i]->dir.root));
fptr[i]->dir.root);
}
}
}
Expand All @@ -248,5 +248,5 @@ void show_argvs(int argc, char *argv[])

rprintf(FINFO, "BATCH.C:show_argvs,argc=%d\n", argc);
for (i = 0; i < argc; i++)
rprintf(FINFO, "i=%d,argv[i]=%s\n", i, safe_fname(argv[i]));
rprintf(FINFO, "i=%d,argv[i]=%s\n", i, argv[i]);
}
4 changes: 2 additions & 2 deletions cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void _exit_cleanup(int code, const char *file, int line)

if (verbose > 3) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): entered\n",
code, safe_fname(file), line);
code, file, line);
}

if (cleanup_child_pid != -1) {
Expand Down Expand Up @@ -149,7 +149,7 @@ void _exit_cleanup(int code, const char *file, int line)

if (verbose > 2) {
rprintf(FINFO,"_exit_cleanup(code=%d, file=%s, line=%d): about to call exit(%d)\n",
ocode, safe_fname(file), line, code);
ocode, file, line, code);
}

close_all();
Expand Down
10 changes: 5 additions & 5 deletions clientserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ static int rsync_module(int f_in, int f_out, int i)
if (!claim_connection(lp_lock_file(i), lp_max_connections(i))) {
if (errno) {
rsyserr(FLOG, errno, "failed to open lock file %s",
safe_fname(lp_lock_file(i)));
lp_lock_file(i));
io_printf(f_out, "@ERROR: failed to open lock file\n");
} else {
rprintf(FLOG, "max connections (%d) reached\n",
Expand Down Expand Up @@ -494,22 +494,22 @@ static int rsync_module(int f_in, int f_out, int i)
*/
if (chroot(lp_path(i))) {
rsyserr(FLOG, errno, "chroot %s failed",
safe_fname(lp_path(i)));
lp_path(i));
io_printf(f_out, "@ERROR: chroot failed\n");
return -1;
}

if (!push_dir("/")) {
rsyserr(FLOG, errno, "chdir %s failed\n",
safe_fname(lp_path(i)));
lp_path(i));
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}

} else {
if (!push_dir(lp_path(i))) {
rsyserr(FLOG, errno, "chdir %s failed\n",
safe_fname(lp_path(i)));
lp_path(i));
io_printf(f_out, "@ERROR: chdir failed\n");
return -1;
}
Expand Down Expand Up @@ -822,7 +822,7 @@ int daemon_main(void)
0666 & ~orig_umask)) == -1) {
cleanup_set_pid(0);
rsyserr(FLOG, errno, "failed to create pid file %s",
safe_fname(pid_file));
pid_file);
exit_cleanup(RERR_FILEIO);
}
snprintf(pidbuf, sizeof pidbuf, "%ld\n", (long)pid);
Expand Down
9 changes: 4 additions & 5 deletions exclude.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
}
if (!sanitize_path(fn, merge_file, r, dirbuf_depth)) {
rprintf(FERROR, "merge-file name overflows: %s\n",
safe_fname(merge_file));
merge_file);
return NULL;
}
} else {
Expand All @@ -315,8 +315,7 @@ static char *parse_merge_name(const char *merge_file, unsigned int *len_ptr,
goto done;

if (dirbuf_len + fn_len >= MAXPATHLEN) {
rprintf(FERROR, "merge-file name overflows: %s\n",
safe_fname(fn));
rprintf(FERROR, "merge-file name overflows: %s\n", fn);
return NULL;
}
memcpy(buf, dirbuf + prefix_skip, dirbuf_len - prefix_skip);
Expand Down Expand Up @@ -985,7 +984,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,

if (verbose > 2) {
rprintf(FINFO, "[%s] parse_filter_file(%s,%x,%x)%s\n",
who_am_i(), safe_fname(fname), mflags, xflags,
who_am_i(), fname, mflags, xflags,
fp ? "" : " [not found]");
}

Expand All @@ -994,7 +993,7 @@ void parse_filter_file(struct filter_list_struct *listp, const char *fname,
rsyserr(FERROR, errno,
"failed to open %sclude file %s",
mflags & MATCHFLG_INCLUDE ? "in" : "ex",
safe_fname(fname));
fname);
exit_cleanup(RERR_FILEIO);
}
return;
Expand Down
Loading

0 comments on commit 45c49b5

Please sign in to comment.