Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Build & run mkrounding to make the rounding.h file used by flist.c.
[rsync/rsync.git]
/
main.c
diff --git
a/main.c
b/main.c
index
841d438
..
9a1bec0
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-103,7
+103,11
@@
static void show_malloc_stats(void);
* remember_children(), we succeed instead of returning an error. */
pid_t wait_process(pid_t pid, int *status_ptr, int flags)
{
* remember_children(), we succeed instead of returning an error. */
pid_t wait_process(pid_t pid, int *status_ptr, int flags)
{
- pid_t waited_pid = waitpid(pid, status_ptr, flags);
+ pid_t waited_pid;
+
+ do {
+ waited_pid = waitpid(pid, status_ptr, flags);
+ } while (waited_pid == -1 && errno == EINTR);
if (waited_pid == -1 && errno == ECHILD) {
/* Status of requested child no longer available: check to
if (waited_pid == -1 && errno == ECHILD) {
/* Status of requested child no longer available: check to
@@
-238,7
+242,8
@@
static void output_summary(void)
human_num(stats.literal_data));
rprintf(FINFO,"Matched data: %s bytes\n",
human_num(stats.matched_data));
human_num(stats.literal_data));
rprintf(FINFO,"Matched data: %s bytes\n",
human_num(stats.matched_data));
- rprintf(FINFO,"File list size: %d\n", stats.flist_size);
+ rprintf(FINFO,"File list size: %s\n",
+ human_num(stats.flist_size));
if (stats.flist_buildtime) {
rprintf(FINFO,
"File list generation time: %.3f seconds\n",
if (stats.flist_buildtime) {
rprintf(FINFO,
"File list generation time: %.3f seconds\n",
@@
-477,11
+482,9
@@
static char *get_local_name(struct file_list *flist, char *dest_path)
return NULL;
/* See what currently exists at the destination. */
return NULL;
/* See what currently exists at the destination. */
- if ((statret =
safe
_stat(dest_path, &st)) == 0) {
+ if ((statret =
do
_stat(dest_path, &st)) == 0) {
/* If the destination is a dir, enter it and use mode 1. */
if (S_ISDIR(st.st_mode)) {
/* If the destination is a dir, enter it and use mode 1. */
if (S_ISDIR(st.st_mode)) {
- if (sanitize_paths)
- die_on_unsafe_path(dest_path, 0);
if (!push_dir(dest_path, 0)) {
rsyserr(FERROR, errno, "push_dir#1 %s failed",
full_fname(dest_path));
if (!push_dir(dest_path, 0)) {
rsyserr(FERROR, errno, "push_dir#1 %s failed",
full_fname(dest_path));
@@
-489,8
+492,6
@@
static char *get_local_name(struct file_list *flist, char *dest_path)
}
return NULL;
}
}
return NULL;
}
- if (sanitize_paths && S_ISLNK(st.st_mode))
- die_on_unsafe_path(dest_path, 0);
if (flist->count > 1) {
rprintf(FERROR,
"ERROR: destination must be a directory when"
if (flist->count > 1) {
rprintf(FERROR,
"ERROR: destination must be a directory when"
@@
-543,8
+544,6
@@
static char *get_local_name(struct file_list *flist, char *dest_path)
dry_run++;
}
dry_run++;
}
- if (sanitize_paths)
- die_on_unsafe_path(dest_path, 0);
if (!push_dir(dest_path, dry_run > 1)) {
rsyserr(FERROR, errno, "push_dir#2 %s failed",
full_fname(dest_path));
if (!push_dir(dest_path, dry_run > 1)) {
rsyserr(FERROR, errno, "push_dir#2 %s failed",
full_fname(dest_path));
@@
-565,8
+564,6
@@
static char *get_local_name(struct file_list *flist, char *dest_path)
dest_path = "/";
*cp = '\0';
dest_path = "/";
*cp = '\0';
- if (sanitize_paths)
- die_on_unsafe_path(dest_path, 0);
if (!push_dir(dest_path, 0)) {
rsyserr(FERROR, errno, "push_dir#3 %s failed",
full_fname(dest_path));
if (!push_dir(dest_path, 0)) {
rsyserr(FERROR, errno, "push_dir#3 %s failed",
full_fname(dest_path));
@@
-626,14
+623,13
@@
static void read_final_goodbye(int f_in, int f_out)
}
}
}
}
- if (i !=
-1
) {
+ if (i !=
NDX_DONE
) {
rprintf(FERROR, "Invalid packet at end of run (%d) [%s]\n",
i, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
}
rprintf(FERROR, "Invalid packet at end of run (%d) [%s]\n",
i, who_am_i());
exit_cleanup(RERR_PROTOCOL);
}
}
-
static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
{
struct file_list *flist;
static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
{
struct file_list *flist;
@@
-658,8
+654,6
@@
static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
}
if (!relative_paths) {
}
if (!relative_paths) {
- if (sanitize_paths)
- die_on_unsafe_path(dir, 0);
if (!push_dir(dir, 0)) {
rsyserr(FERROR, errno, "push_dir#3 %s failed",
full_fname(dir));
if (!push_dir(dir, 0)) {
rsyserr(FERROR, errno, "push_dir#3 %s failed",
full_fname(dir));
@@
-676,9
+670,8
@@
static void do_server_sender(int f_in, int f_out, int argc, char *argv[])
}
flist = send_file_list(f_out,argc,argv);
}
flist = send_file_list(f_out,argc,argv);
- if (!flist || flist->count == 0)
{
+ if (!flist || flist->count == 0)
exit_cleanup(0);
exit_cleanup(0);
- }
the_file_list = flist;
io_start_buffering_in();
the_file_list = flist;
io_start_buffering_in();
@@
-704,8
+697,10
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
* points to an identical file won't be replaced by the referent. */
copy_links = copy_dirlinks = 0;
* points to an identical file won't be replaced by the referent. */
copy_links = copy_dirlinks = 0;
+#ifdef SUPPORT_HARD_LINKS
if (preserve_hard_links)
if (preserve_hard_links)
- init_hard_links();
+ match_hard_links();
+#endif
if (fd_pair(error_pipe) < 0) {
rsyserr(FERROR, errno, "pipe failed in do_recv");
if (fd_pair(error_pipe) < 0) {
rsyserr(FERROR, errno, "pipe failed in do_recv");
@@
-777,7
+772,7
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
io_flush(FULL_FLUSH);
if (protocol_version >= 24) {
/* send a final goodbye message */
io_flush(FULL_FLUSH);
if (protocol_version >= 24) {
/* send a final goodbye message */
- write_int(f_out,
-1
);
+ write_int(f_out,
NDX_DONE
);
}
io_flush(FULL_FLUSH);
}
io_flush(FULL_FLUSH);
@@
-787,7
+782,6
@@
static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
return exit_code;
}
return exit_code;
}
-
static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
{
int exit_code;
static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
{
int exit_code;
@@
-854,13
+848,9
@@
static void do_server_recv(int f_in, int f_out, int argc,char *argv[])
char **dir;
for (dir = basis_dir; *dir; dir++) {
*dir = sanitize_path(NULL, *dir, NULL, curr_dir_depth, NULL);
char **dir;
for (dir = basis_dir; *dir; dir++) {
*dir = sanitize_path(NULL, *dir, NULL, curr_dir_depth, NULL);
- die_on_unsafe_path(*dir, 0);
}
if (partial_dir) {
partial_dir = sanitize_path(NULL, partial_dir, NULL, curr_dir_depth, NULL);
}
if (partial_dir) {
partial_dir = sanitize_path(NULL, partial_dir, NULL, curr_dir_depth, NULL);
- /* A relative path gets this checked at every dir change. */
- if (*partial_dir == '/')
- die_on_unsafe_path(partial_dir, 0);
}
}
fix_basis_dirs();
}
}
fix_basis_dirs();
@@
-912,12
+902,10
@@
void start_server(int f_in, int f_out, int argc, char *argv[])
keep_dirlinks = 0; /* Must be disabled on the sender. */
if (need_messages_from_generator)
io_start_multiplex_in();
keep_dirlinks = 0; /* Must be disabled on the sender. */
if (need_messages_from_generator)
io_start_multiplex_in();
-
recv_filter_list(f_in);
do_server_sender(f_in, f_out, argc, argv);
recv_filter_list(f_in);
do_server_sender(f_in, f_out, argc, argv);
- } else
{
+ } else
do_server_recv(f_in, f_out, argc, argv);
do_server_recv(f_in, f_out, argc, argv);
- }
exit_cleanup(0);
}
exit_cleanup(0);
}
@@
-1030,7
+1018,7
@@
int client_run(int f_in, int f_out, pid_t pid, int argc, char *argv[])
return MAX(exit_code, exit_code2);
}
return MAX(exit_code, exit_code2);
}
-static int copy_argv
(char *argv[])
+static int copy_argv(char *argv[])
{
int i;
{
int i;
@@
-1272,8
+1260,8
@@
static RETSIGTYPE rsync_panic_handler(UNUSED(int whatsig))
char cmd_buf[300];
int ret;
char cmd_buf[300];
int ret;
- s
printf(
cmd_buf, get_panic_action(),
- getpid(), getpid());
+ s
nprintf(cmd_buf, sizeof
cmd_buf, get_panic_action(),
+
getpid(), getpid());
/* Unless we failed to execute gdb, we allow the process to
* continue. I'm not sure if that's right. */
/* Unless we failed to execute gdb, we allow the process to
* continue. I'm not sure if that's right. */