diff options
-rw-r--r-- | acls.c | 27 | ||||
-rw-r--r-- | authenticate.c | 14 | ||||
-rw-r--r-- | cleanup.c | 4 | ||||
-rw-r--r-- | flist.c | 22 | ||||
-rw-r--r-- | generator.c | 20 | ||||
-rw-r--r-- | hlink.c | 8 | ||||
-rw-r--r-- | io.c | 10 | ||||
-rw-r--r-- | log.c | 38 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | receiver.c | 20 | ||||
-rw-r--r-- | rsync.c | 12 | ||||
-rw-r--r-- | rsync.h | 21 | ||||
-rw-r--r-- | sender.c | 6 | ||||
-rw-r--r-- | util.c | 16 | ||||
-rw-r--r-- | xattrs.c | 28 |
15 files changed, 134 insertions, 116 deletions
@@ -300,7 +300,7 @@ static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *racl) ida->access = access; } if (rc) { - rsyserr(FERROR, errno, "unpack_smb_acl: %s()", errfun); + rsyserr(FERROR_XFER, errno, "unpack_smb_acl: %s()", errfun); rsync_acl_free(racl); return False; } @@ -356,7 +356,7 @@ static BOOL unpack_smb_acl(SMB_ACL_T sacl, rsync_acl *racl) static int store_access_in_entry(uint32 access, SMB_ACL_ENTRY_T entry) { if (sys_acl_set_access_bits(entry, access)) { - rsyserr(FERROR, errno, "store_access_in_entry sys_acl_set_access_bits()"); + rsyserr(FERROR_XFER, errno, "store_access_in_entry sys_acl_set_access_bits()"); return -1; } return 0; @@ -375,7 +375,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsync_acl *racl) SMB_ACL_ENTRY_T entry; if (!(*smb_acl = sys_acl_init(calc_sacl_entries(racl)))) { - rsyserr(FERROR, errno, "pack_smb_acl: sys_acl_init()"); + rsyserr(FERROR_XFER, errno, "pack_smb_acl: sys_acl_init()"); return False; } @@ -424,14 +424,14 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_acl, const rsync_acl *racl) #ifdef DEBUG if (sys_acl_valid(*smb_acl) < 0) - rprintf(FERROR, "pack_smb_acl: warning: system says the ACL I packed is invalid\n"); + rprintf(FERROR_XFER, "pack_smb_acl: warning: system says the ACL I packed is invalid\n"); #endif return True; error_exit: if (errfun) { - rsyserr(FERROR, errno, "pack_smb_acl %s()", errfun); + rsyserr(FERROR_XFER, errno, "pack_smb_acl %s()", errfun); } sys_acl_free_acl(*smb_acl); return False; @@ -514,7 +514,7 @@ static int get_rsync_acl(const char *fname, rsync_acl *racl, if (type == SMB_ACL_TYPE_ACCESS) rsync_acl_fake_perms(racl, mode); } else { - rsyserr(FERROR, errno, "get_acl: sys_acl_get_file(%s, %s)", + rsyserr(FERROR_XFER, errno, "get_acl: sys_acl_get_file(%s, %s)", fname, str_acl_type(type)); return -1; } @@ -655,7 +655,7 @@ static uint32 recv_acl_access(uchar *name_follows_ptr, int f) access |= NAME_IS_USER; } else if (am_root >= 0 && access & ~SMB_ACL_VALID_OBJ_BITS) { value_error: - rprintf(FERROR, "recv_acl_access: value out of range: %x\n", + rprintf(FERROR_XFER, "recv_acl_access: value out of range: %x\n", access); exit_cleanup(RERR_STREAMIO); } @@ -710,7 +710,7 @@ static int recv_rsync_acl(item_list *racl_list, SMB_ACL_TYPE_T type, int f) int ndx = read_varint(f); if (ndx < 0 || (size_t)ndx > racl_list->count) { - rprintf(FERROR, "recv_acl_index: %s ACL index %d > %d\n", + rprintf(FERROR_XFER, "recv_acl_index: %s ACL index %d > %d\n", str_acl_type(type), ndx, (int)racl_list->count); exit_cleanup(RERR_STREAMIO); } @@ -855,7 +855,7 @@ static mode_t change_sacl_perms(SMB_ACL_T sacl, rsync_acl *racl, mode_t old_mode if (rc) { error_exit: if (errfun) { - rsyserr(FERROR, errno, "change_sacl_perms: %s()", + rsyserr(FERROR_XFER, errno, "change_sacl_perms: %s()", errfun); } return (mode_t)~0; @@ -887,7 +887,7 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item, #endif rc = sys_acl_delete_def_file(fname); if (rc < 0) { - rsyserr(FERROR, errno, "set_acl: sys_acl_delete_def_file(%s)", + rsyserr(FERROR_XFER, errno, "set_acl: sys_acl_delete_def_file(%s)", fname); return -1; } @@ -932,7 +932,7 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item, } #endif if (sys_acl_set_file(fname, type, duo_item->sacl) < 0) { - rsyserr(FERROR, errno, "set_acl: sys_acl_set_file(%s, %s)", + rsyserr(FERROR_XFER, errno, "set_acl: sys_acl_set_file(%s, %s)", fname, str_acl_type(type)); return -1; } @@ -1052,7 +1052,8 @@ int default_perms_for_dir(const char *dir) } /* Otherwise fall through. */ default: - rprintf(FERROR, "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n", + rprintf(FWARNING, + "default_perms_for_dir: sys_acl_get_file(%s, %s): %s, falling back on umask\n", dir, str_acl_type(SMB_ACL_TYPE_DEFAULT), strerror(errno)); } return perms; @@ -1063,7 +1064,7 @@ int default_perms_for_dir(const char *dir) ok = unpack_smb_acl(sacl, &racl); sys_acl_free_acl(sacl); if (!ok) { - rprintf(FERROR, "default_perms_for_dir: unpack_smb_acl failed, falling back on umask\n"); + rprintf(FWARNING, "default_perms_for_dir: unpack_smb_acl failed, falling back on umask\n"); return perms; } diff --git a/authenticate.c b/authenticate.c index afb85541..dd74b684 100644 --- a/authenticate.c +++ b/authenticate.c @@ -21,7 +21,6 @@ #include "rsync.h" extern char *password_file; -extern int log_got_error; /*************************************************************************** encode a buffer using base64 - simple and slow algorithm. null terminates @@ -164,7 +163,7 @@ static const char *getpassf(const char *filename) return NULL; if ((fd = open(filename,O_RDONLY)) < 0) { - rsyserr(FERROR, errno, "could not open password file \"%s\"", + rsyserr(FWARNING, errno, "could not open password file \"%s\"", filename); if (envpw) rprintf(FINFO, "falling back to RSYNC_PASSWORD environment variable.\n"); @@ -172,18 +171,18 @@ static const char *getpassf(const char *filename) } if (do_stat(filename, &st) == -1) { - rsyserr(FERROR, errno, "stat(%s)", filename); + rsyserr(FWARNING, errno, "stat(%s)", filename); ok = 0; } else if ((st.st_mode & 06) != 0) { - rprintf(FERROR, "password file must not be other-accessible\n"); + rprintf(FWARNING, "password file must not be other-accessible\n"); ok = 0; } else if (MY_UID() == 0 && st.st_uid != 0) { - rprintf(FERROR, "password file must be owned by root when running as root\n"); + rprintf(FWARNING, "password file must be owned by root when running as root\n"); ok = 0; } if (!ok) { close(fd); - rprintf(FERROR, "continuing without password file\n"); + rprintf(FWARNING, "continuing without password file\n"); if (envpw) rprintf(FINFO, "falling back to RSYNC_PASSWORD environment variable.\n"); return NULL; @@ -308,9 +307,6 @@ void auth_client(int fd, const char *user, const char *challenge) pass = getpass("Password: "); } - /* Any errors output during password handling aren't transfer errors. */ - log_got_error = 0; - if (!pass) pass = ""; @@ -26,7 +26,7 @@ extern int am_server; extern int am_daemon; extern int io_error; extern int keep_partial; -extern int log_got_error; +extern int got_xfer_error; extern char *partial_dir; extern char *logfile_name; @@ -174,7 +174,7 @@ NORETURN void _exit_cleanup(int code, const char *file, int line) code = exit_code = RERR_DEL_LIMIT; if (io_error & IOERR_VANISHED) code = exit_code = RERR_VANISHED; - if (io_error & IOERR_GENERAL || log_got_error) + if (io_error & IOERR_GENERAL || got_xfer_error) code = exit_code = RERR_PARTIAL; } @@ -726,7 +726,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist, modtime = read_varlong(f, 4); #if SIZEOF_TIME_T < SIZEOF_INT64 if ((modtime > INT_MAX || modtime < INT_MIN) && !am_generator) { - rprintf(FERROR, + rprintf(FERROR_XFER, "Time value of %s truncated on receiver.\n", lastname); } @@ -1029,20 +1029,20 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, if (copy_links && x_lstat(thisname, &st, NULL) == 0 && S_ISLNK(st.st_mode)) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "symlink has no referent: %s\n", + rprintf(FERROR_XFER, "symlink has no referent: %s\n", full_fname(thisname)); } else #endif { enum logcode c = am_daemon && protocol_version < 28 - ? FERROR : FINFO; + ? FERROR : FWARNING; io_error |= IOERR_VANISHED; rprintf(c, "file has vanished: %s\n", full_fname(thisname)); } } else { io_error |= IOERR_GENERAL; - rsyserr(FERROR, save_errno, "readlink %s failed", + rsyserr(FERROR_XFER, save_errno, "readlink %s failed", full_fname(thisname)); } return NULL; @@ -1310,7 +1310,7 @@ static void send_if_directory(int f, struct file_list *flist, fbuf[--len] = '\0'; if (len >= MAXPATHLEN - 1) { io_error |= IOERR_GENERAL; - rprintf(FERROR, "skipping long-named directory: %s\n", + rprintf(FERROR_XFER, "skipping long-named directory: %s\n", full_fname(fbuf)); return; } @@ -1449,7 +1449,7 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len, if (!(d = opendir(fbuf))) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "opendir %s failed", full_fname(fbuf)); + rsyserr(FERROR_XFER, errno, "opendir %s failed", full_fname(fbuf)); return; } @@ -1486,7 +1486,7 @@ static void send_directory(int f, struct file_list *flist, char *fbuf, int len, if (errno) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "readdir(%s)", full_fname(fbuf)); + rsyserr(FERROR_XFER, errno, "readdir(%s)", full_fname(fbuf)); } closedir(d); @@ -1596,7 +1596,7 @@ static void send1extra(int f, struct file_struct *file, struct file_list *flist) STRUCT_STAT st; if (link_stat(fbuf, &st, copy_dirlinks) != 0) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "link_stat %s failed", + rsyserr(FERROR_XFER, errno, "link_stat %s failed", full_fname(fbuf)); return; } @@ -1633,7 +1633,7 @@ static void send1extra(int f, struct file_struct *file, struct file_list *flist) STRUCT_STAT st; if (link_stat(fbuf, &st, 1) != 0) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "link_stat %s failed", + rsyserr(FERROR_XFER, errno, "link_stat %s failed", full_fname(fbuf)); continue; } @@ -1791,7 +1791,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) disable_buffering = io_start_buffering_out(f); if (filesfrom_fd >= 0) { if (argv[0] && !push_dir(argv[0], 0)) { - rsyserr(FERROR, errno, "push_dir %s failed in %s", + rsyserr(FERROR_XFER, errno, "push_dir %s failed in %s", full_fname(argv[0]), curr_dir); exit_cleanup(RERR_FILESELECT); } @@ -1918,7 +1918,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) if (link_stat(fbuf, &st, copy_dirlinks || name_type != NORMAL_NAME) != 0) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, "link_stat %s failed", + rsyserr(FERROR_XFER, errno, "link_stat %s failed", full_fname(fbuf)); continue; } diff --git a/generator.c b/generator.c index 38041186..046ad95d 100644 --- a/generator.c +++ b/generator.c @@ -196,7 +196,7 @@ static enum delret delete_item(char *fbuf, int mode, char *replace, int flags) check_ret: if (replace && ret != DR_SUCCESS) { - rprintf(FERROR, "could not make way for new %s: %s\n", + rprintf(FERROR_XFER, "could not make way for new %s: %s\n", replace, fbuf); } return ret; @@ -1082,7 +1082,7 @@ static int try_dests_non(struct file_struct *file, char *fname, int ndx, #endif && !S_ISDIR(file->mode)) { if (do_link(cmpbuf, fname) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "failed to hard-link %s with %s", cmpbuf, fname); return j; @@ -1239,7 +1239,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, if (relative_paths && !implied_dirs && do_stat(dn, &sx.st) < 0 && create_directory_path(fname) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "recv_generator: mkdir %s failed", full_fname(dn)); } @@ -1342,7 +1342,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, if (!relative_paths || errno != ENOENT || create_directory_path(fname) < 0 || (do_mkdir(fname, file->mode) < 0 && errno != EEXIST)) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "recv_generator: mkdir %s failed", full_fname(fname)); skipping_dir_contents: @@ -1365,7 +1365,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, if (!am_root && !(file->mode & S_IWUSR) && dir_tweaking) { mode_t mode = file->mode | S_IWUSR; if (do_chmod(fname, mode) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "failed to modify permissions on %s", full_fname(fname)); } @@ -1462,7 +1462,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, } #endif if (do_symlink(sl, fname) != 0) { - rsyserr(FERROR, errno, "symlink %s -> \"%s\" failed", + rsyserr(FERROR_XFER, errno, "symlink %s -> \"%s\" failed", full_fname(fname), sl); } else { set_file_attrs(fname, file, NULL, NULL, 0); @@ -1546,7 +1546,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, (long)major(rdev), (long)minor(rdev)); } if (do_mknod(fname, file->mode, rdev) < 0) { - rsyserr(FERROR, errno, "mknod %s failed", + rsyserr(FERROR_XFER, errno, "mknod %s failed", full_fname(fname)); } else { set_file_attrs(fname, file, NULL, NULL, 0); @@ -1664,7 +1664,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, #endif if (stat_errno == ENOENT) goto notify_others; - rsyserr(FERROR, stat_errno, "recv_generator: failed to stat %s", + rsyserr(FERROR_XFER, stat_errno, "recv_generator: failed to stat %s", full_fname(fname)); goto cleanup; } @@ -1754,7 +1754,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, goto pretend_missing; } if (robust_unlink(backupptr) && errno != ENOENT) { - rsyserr(FERROR, errno, "unlink %s", + rsyserr(FERROR_XFER, errno, "unlink %s", full_fname(backupptr)); unmake_file(back_file); back_file = NULL; @@ -1764,7 +1764,7 @@ static void recv_generator(char *fname, struct file_struct *file, int ndx, 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, errno, "open %s", + rsyserr(FERROR_XFER, errno, "open %s", full_fname(backupptr)); unmake_file(back_file); back_file = NULL; @@ -217,7 +217,7 @@ static int maybe_hard_link(struct file_struct *file, int ndx, if (!make_backup(fname)) return -1; } else if (robust_unlink(fname)) { - rsyserr(FERROR, errno, "unlink %s failed", + rsyserr(FERROR_XFER, errno, "unlink %s failed", full_fname(fname)); return -1; } @@ -317,7 +317,7 @@ int hard_link_check(struct file_struct *file, int ndx, const char *fname, } if (link_stat(prev_name, &prev_st, 0) < 0) { - rsyserr(FERROR, errno, "stat %s failed", + rsyserr(FERROR_XFER, errno, "stat %s failed", full_fname(prev_name)); return -1; } @@ -393,7 +393,7 @@ int hard_link_one(struct file_struct *file, const char *fname, return -1; code = FINFO; } else - code = FERROR; + code = FERROR_XFER; rsyserr(code, errno, "link %s => %s failed", full_fname(fname), oldname); return 0; @@ -417,7 +417,7 @@ void finish_hard_link(struct file_struct *file, const char *fname, int fin_ndx, if (stp == NULL && prev_ndx >= 0) { if (link_stat(fname, &st, 0) < 0) { - rsyserr(FERROR, errno, "stat %s failed", + rsyserr(FERROR_XFER, errno, "stat %s failed", full_fname(fname)); return; } @@ -413,15 +413,17 @@ static void read_msg_fd(void) readfd(fd, buf, 4); got_flist_entry_status(FES_NO_SEND, buf); break; - case MSG_SOCKERR: + case MSG_ERROR_SOCKET: case MSG_CLIENT: if (!am_generator) goto invalid_msg; - if (tag == MSG_SOCKERR) + if (tag == MSG_ERROR_SOCKET) io_end_multiplex_out(); /* FALL THROUGH */ case MSG_INFO: case MSG_ERROR: + case MSG_ERROR_XFER: + case MSG_WARNING: case MSG_LOG: while (len) { n = len; @@ -751,7 +753,7 @@ static int read_timeout(int fd, char *buf, size_t len) /* Don't write errors on a dead socket. */ if (fd == sock_f_in) { io_end_multiplex_out(); - rsyserr(FSOCKERR, errno, "read error"); + rsyserr(FERROR_SOCKET, errno, "read error"); } else rsyserr(FERROR, errno, "read error"); exit_cleanup(RERR_STREAMIO); @@ -1106,6 +1108,8 @@ static int readfd_unbuffered(int fd, char *buf, size_t len) break; case MSG_INFO: case MSG_ERROR: + case MSG_ERROR_XFER: + case MSG_WARNING: if (msg_bytes >= sizeof line) { overflow: rprintf(FERROR, @@ -61,7 +61,7 @@ static int logfile_was_closed; static FILE *logfile_fp; struct stats stats; -int log_got_error = 0; +int got_xfer_error = 0; struct { int code; @@ -235,8 +235,8 @@ static void filtered_fwrite(FILE *f, const char *buf, int len, int use_isprint) } /* this is the underlying (unformatted) rsync debugging function. Call - * it with FINFO, FERROR or FLOG. Note: recursion can happen with - * certain fatal conditions. */ + * it with FINFO, FERROR_*, FWARNING, FLOG, or FCLIENT. Note: recursion + * can happen with certain fatal conditions. */ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) { int trailing_CR_or_NL; @@ -259,7 +259,7 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) return; } - if (code == FSOCKERR) /* This gets simplified for a non-sibling. */ + if (code == FERROR_SOCKET) /* This gets simplified for a non-sibling. */ code = FERROR; if (code == FCLIENT) @@ -267,7 +267,7 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) else if (am_daemon || logfile_name) { static int in_block; char msg[2048]; - int priority = code == FERROR ? LOG_WARNING : LOG_INFO; + int priority = code == FINFO || code == FLOG ? LOG_INFO : LOG_WARNING; if (in_block) return; @@ -283,12 +283,19 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) } else if (code == FLOG) return; - if (quiet && code != FERROR) + if (quiet && code == FINFO) return; if (am_server) { + enum msgcode msg = (enum msgcode)code; + if (protocol_version < 30) { + if (msg == MSG_ERROR) + msg = MSG_ERROR_XFER; + else if (msg == MSG_WARNING) + msg = MSG_INFO; + } /* Pass the message to the non-server side. */ - if (send_msg((enum msgcode)code, buf, len, !is_utf8)) + if (send_msg(msg, buf, len, !is_utf8)) return; if (am_daemon) { /* TODO: can we send the error to the user somehow? */ @@ -297,8 +304,11 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) } switch (code) { + case FERROR_XFER: + got_xfer_error = 1; + /* CONTINUE */ case FERROR: - log_got_error = 1; + case FWARNING: f = stderr; break; case FINFO: @@ -342,8 +352,8 @@ void rwrite(enum logcode code, const char *buf, int len, int is_utf8) } } -/* This is the rsync debugging function. Call it with FINFO, FERROR or - * FLOG. */ +/* This is the rsync debugging function. Call it with FINFO, FERROR_*, + * FWARNING, FLOG, or FCLIENT. */ void rprintf(enum logcode code, const char *format, ...) { va_list ap; @@ -421,10 +431,10 @@ void rflush(enum logcode code) if (am_daemon || code == FLOG) return; - if (code == FERROR || am_server) - f = stderr; - else + if (code == FINFO && !am_server) f = stdout; + else + f = stderr; fflush(f); } @@ -801,7 +811,7 @@ void log_exit(int code, const char *file, int line) /* VANISHED is not an error, only a warning */ if (code == RERR_VANISHED) { - rprintf(FINFO, "rsync warning: %s (code %d) at %s(%d) [%s=%s]\n", + rprintf(FWARNING, "rsync warning: %s (code %d) at %s(%d) [%s=%s]\n", name, code, file, line, who_am_i(), RSYNC_VERSION); } else { rprintf(FERROR, "rsync error: %s (code %d) at %s(%d) [%s=%s]\n", @@ -41,7 +41,7 @@ extern int remove_source_files; extern int need_messages_from_generator; extern int kluge_around_eof; extern int do_stats; -extern int log_got_error; +extern int got_xfer_error; extern int module_id; extern int copy_links; extern int copy_dirlinks; @@ -1310,7 +1310,7 @@ static RETSIGTYPE sigusr2_handler(UNUSED(int val)) if (!am_server) output_summary(); close_all(); - if (log_got_error) + if (got_xfer_error) _exit(RERR_PARTIAL); _exit(0); } @@ -110,7 +110,7 @@ int get_tmpname(char *fnametmp, const char *fname) maxname = MIN(MAXPATHLEN - 7 - length, NAME_MAX - 8); if (maxname < 1) { - rprintf(FERROR, "temporary filename too long: %s\n", fname); + rprintf(FERROR_XFER, "temporary filename too long: %s\n", fname); fnametmp[0] = '\0'; return 0; } @@ -153,7 +153,7 @@ int open_tmpfile(char *fnametmp, const char *fname, struct file_struct *file) #endif if (fd == -1) { - rsyserr(FERROR, errno, "mkstemp %s failed", + rsyserr(FERROR_XFER, errno, "mkstemp %s failed", full_fname(fnametmp)); return -1; } @@ -211,7 +211,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, } offset = sum.flength; if (fd != -1 && (j = do_lseek(fd, offset, SEEK_SET)) != offset) { - rsyserr(FERROR, errno, "lseek of %s returned %.0f, not %.0f", + rsyserr(FERROR_XFER, errno, "lseek of %s returned %.0f, not %.0f", full_fname(fname), (double)j, (double)offset); exit_cleanup(RERR_FILEIO); } @@ -266,7 +266,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, goto report_write_error; offset += len; if ((pos = do_lseek(fd, len, SEEK_CUR)) != offset) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "lseek of %s returned %.0f, not %.0f", full_fname(fname), (double)pos, (double)offset); @@ -293,7 +293,7 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, if (fd != -1 && offset > 0 && sparse_end(fd) != 0) { report_write_error: - rsyserr(FERROR, errno, "write failed on %s", + rsyserr(FERROR_XFER, errno, "write failed on %s", full_fname(fname)); exit_cleanup(RERR_FILEIO); } @@ -335,7 +335,7 @@ static void handle_delayed_updates(char *local_name) /* We don't use robust_rename() here because the * partial-dir must be on the same drive. */ if (do_rename(partialptr, fname) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "rename failed for %s (from %s)", full_fname(fname), partialptr); } else { @@ -598,7 +598,7 @@ int recv_files(int f_in, char *local_name) st.st_mode = 0; st.st_size = 0; } else if (do_fstat(fd1,&st) != 0) { - rsyserr(FERROR, errno, "fstat %s failed", + rsyserr(FERROR_XFER, errno, "fstat %s failed", full_fname(fnamecmp)); discard_receive_data(f_in, F_LENGTH(file)); close(fd1); @@ -613,7 +613,7 @@ int recv_files(int f_in, char *local_name) * and the underlying robust_unlink could cope * with directories */ - rprintf(FERROR,"recv_files: %s is a directory\n", + rprintf(FERROR_XFER, "recv_files: %s is a directory\n", full_fname(fnamecmp)); discard_receive_data(f_in, F_LENGTH(file)); close(fd1); @@ -647,7 +647,7 @@ int recv_files(int f_in, char *local_name) if (inplace) { fd2 = do_open(fname, O_WRONLY|O_CREAT, 0600); if (fd2 == -1) { - rsyserr(FERROR, errno, "open %s failed", + rsyserr(FERROR_XFER, errno, "open %s failed", full_fname(fname)); } } else { @@ -719,7 +719,7 @@ int recv_files(int f_in, char *local_name) || (preserve_hard_links && F_IS_HLINKED(file))) send_msg_int(MSG_SUCCESS, ndx); } else if (!recv_ok) { - enum logcode msgtype = redoing || read_batch ? FERROR : FINFO; + enum logcode msgtype = redoing || read_batch ? FERROR : FWARNING; if (msgtype == FERROR || verbose) { char *errstr, *redostr, *keptstr; if (!(keep_partial && partialptr) && !inplace) @@ -350,7 +350,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, if (dry_run) return 1; if (link_stat(fname, &sx2.st, 0) < 0) { - rsyserr(FERROR, errno, "stat %s failed", + rsyserr(FERROR_XFER, errno, "stat %s failed", full_fname(fname)); return 0; } @@ -389,7 +389,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, && cmp_time(sxp->st.st_mtime, file->modtime) != 0) { int ret = set_modtime(fname, file->modtime, sxp->st.st_mode); if (ret < 0) { - rsyserr(FERROR, errno, "failed to set times on %s", + rsyserr(FERROR_XFER, errno, "failed to set times on %s", full_fname(fname)); goto cleanup; } @@ -425,7 +425,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, change_gid ? (gid_t)F_GROUP(file) : sxp->st.st_gid) != 0) { /* shouldn't have attempted to change uid or gid * unless have the privilege */ - rsyserr(FERROR, errno, "%s %s failed", + rsyserr(FERROR_XFER, errno, "%s %s failed", change_uid ? "chown" : "chgrp", full_fname(fname)); goto cleanup; @@ -458,7 +458,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, if (!BITS_EQUAL(sxp->st.st_mode, new_mode, CHMOD_BITS)) { int ret = am_root < 0 ? 0 : do_chmod(fname, new_mode); if (ret < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "failed to set permissions on %s", full_fname(fname)); goto cleanup; @@ -533,7 +533,7 @@ void finish_transfer(const char *fname, const char *fnametmp, ret = robust_rename(fnametmp, fname, partialptr, file->mode & INITACCESSPERMS); if (ret < 0) { - rsyserr(FERROR, errno, "%s %s -> \"%s\"", + rsyserr(FERROR_XFER, errno, "%s %s -> \"%s\"", ret == -2 ? "copy" : "rename", full_fname(fnametmp), fname); do_unlink(fnametmp); @@ -553,7 +553,7 @@ void finish_transfer(const char *fname, const char *fnametmp, if (partialptr) { if (do_rename(fnametmp, fname) < 0) { - rsyserr(FERROR, errno, "rename %s -> \"%s\"", + rsyserr(FERROR_XFER, errno, "rename %s -> \"%s\"", full_fname(fnametmp), fname); } else handle_partial_dir(partialptr, PDIR_DELETE); @@ -90,7 +90,7 @@ /* This is used when working on a new protocol version in CVS, and should * be a new non-zero value for each CVS change that affects the protocol. * It must ALWAYS be 0 when the protocol goes final! */ -#define SUBPROTOCOL_VERSION 14 +#define SUBPROTOCOL_VERSION 15 /* We refuse to interoperate with versions that are not in this range. * Note that we assume we'll work with later versions: the onus is on @@ -188,17 +188,24 @@ #define CFN_DROP_TRAILING_DOT_DIR (1<<2) #define CFN_COLLAPSE_DOT_DOT_DIRS (1<<3) -/* Log-message categories. Only FERROR and FINFO get sent over the socket, - * but FLOG and FSOCKERR can be sent over the receiver -> generator pipe. - * FLOG only goes to the log file, not the client; FCLIENT is the opposite. */ -enum logcode { FNONE=0, FERROR=1, FINFO=2, FLOG=3, FCLIENT=4, FSOCKERR=5 }; +/* Log-message categories. FLOG only goes to the log file, not the client; + * FCLIENT is the opposite. */ +enum logcode { + FNONE=0, /* never sent */ + FERROR_XFER=1, FINFO=2, /* sent over socket for any protocol */ + FERROR=3, FWARNING=4, /* sent over socket for protocols >= 30 */ + FERROR_SOCKET=5, FLOG=6, /* only sent via receiver -> generator pipe */ + FCLIENT=7 /* never transmitted (e.g. server converts to FINFO) */ +}; /* Messages types that are sent over the message channel. The logcode * values must all be present here with identical numbers. */ enum msgcode { MSG_DATA=0, /* raw data on the multiplexed stream */ - MSG_ERROR=FERROR, MSG_INFO=FINFO, /* remote logging */ - MSG_LOG=FLOG, MSG_CLIENT=FCLIENT, MSG_SOCKERR=FSOCKERR, /* sibling logging */ + MSG_ERROR_XFER=FERROR_XFER, MSG_INFO=FINFO, /* remote logging */ + MSG_ERROR=FERROR, MSG_WARNING=FWARNING, /* protocol-30 remote logging */ + MSG_ERROR_SOCKET=FERROR_SOCKET, /* sibling logging */ + MSG_LOG=FLOG, MSG_CLIENT=FCLIENT, /* sibling logging */ MSG_REDO=9, /* reprocess indicated flist index */ MSG_FLIST=20, /* extra file list over sibling socket */ MSG_FLIST_EOF=21,/* we've transmitted all the file lists */ @@ -289,13 +289,13 @@ void send_files(int f_in, int f_out) if (errno == ENOENT) { enum logcode c = am_daemon && protocol_version < 28 ? FERROR - : FINFO; + : FWARNING; io_error |= IOERR_VANISHED; rprintf(c, "file has vanished: %s\n", full_fname(fname)); } else { io_error |= IOERR_GENERAL; - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "send_files failed to open %s", full_fname(fname)); } @@ -349,7 +349,7 @@ void send_files(int f_in, int f_out) j = unmap_file(mbuf); if (j) { io_error |= IOERR_GENERAL; - rsyserr(FERROR, j, + rsyserr(FERROR_XFER, j, "read errors mapping %s", full_fname(fname)); } @@ -274,20 +274,20 @@ int copy_file(const char *source, const char *dest, int ofd, int len; /* Number of bytes read into `buf'. */ if ((ifd = do_open(source, O_RDONLY, 0)) < 0) { - rsyserr(FERROR, errno, "open %s", full_fname(source)); + rsyserr(FERROR_XFER, errno, "open %s", full_fname(source)); return -1; } if (ofd < 0) { if (robust_unlink(dest) && errno != ENOENT) { - rsyserr(FERROR, errno, "unlink %s", full_fname(dest)); + rsyserr(FERROR_XFER, errno, "unlink %s", full_fname(dest)); return -1; } if ((ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0 && (!create_bak_dir || errno != ENOENT || make_bak_dir(dest) < 0 || (ofd = do_open(dest, O_WRONLY | O_CREAT | O_TRUNC | O_EXCL, mode)) < 0)) { - rsyserr(FERROR, errno, "open %s", full_fname(dest)); + rsyserr(FERROR_XFER, errno, "open %s", full_fname(dest)); close(ifd); return -1; } @@ -295,7 +295,7 @@ int copy_file(const char *source, const char *dest, int ofd, while ((len = safe_read(ifd, buf, sizeof buf)) > 0) { if (full_write(ofd, buf, len) < 0) { - rsyserr(FERROR, errno, "write %s", full_fname(dest)); + rsyserr(FERROR_XFER, errno, "write %s", full_fname(dest)); close(ifd); close(ofd); return -1; @@ -303,19 +303,19 @@ int copy_file(const char *source, const char *dest, int ofd, } if (len < 0) { - rsyserr(FERROR, errno, "read %s", full_fname(source)); + rsyserr(FERROR_XFER, errno, "read %s", full_fname(source)); close(ifd); close(ofd); return -1; } if (close(ifd) < 0) { - rsyserr(FINFO, errno, "close failed on %s", + rsyserr(FWARNING, errno, "close failed on %s", full_fname(source)); } if (close(ofd) < 0) { - rsyserr(FERROR, errno, "close failed on %s", + rsyserr(FERROR_XFER, errno, "close failed on %s", full_fname(dest)); return -1; } @@ -371,7 +371,7 @@ int robust_unlink(const char *fname) } while ((rc = access(path, 0)) == 0 && counter != start); if (verbose > 0) { - rprintf(FINFO,"renaming %s to %s because of text busy\n", + rprintf(FWARNING, "renaming %s to %s because of text busy\n", fname, path); } @@ -132,7 +132,7 @@ static ssize_t get_xattr_names(const char *fname) if (errno == ERANGE) { list_len = sys_llistxattr(fname, NULL, 0); if (list_len < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "get_xattr_names: llistxattr(\"%s\",0) failed", fname); return -1; @@ -148,7 +148,7 @@ static ssize_t get_xattr_names(const char *fname) return list_len; } - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "get_xattr_names: llistxattr(\"%s\",%ld) failed", fname, (long)namebuf_len); return -1; @@ -169,7 +169,7 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr if (datum_len == (size_t)-1) { if (errno == ENOTSUP || no_missing_error) return NULL; - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "get_xattr_data: lgetxattr(\"%s\",\"%s\",0) failed", fname, name); return NULL; @@ -185,11 +185,11 @@ static char *get_xattr_data(const char *fname, const char *name, size_t *len_ptr size_t len = sys_lgetxattr(fname, name, ptr, datum_len); if (len != datum_len) { if (len == (size_t)-1) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)" " failed", fname, name, (long)datum_len); } else { - rprintf(FERROR, + rprintf(FERROR_XFER, "get_xattr_data: lgetxattr(\"%s\",\"%s\",%ld)" " returned %ld\n", fname, name, (long)datum_len, (long)len); @@ -722,7 +722,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp, if (fname == fnamecmp) ; /* Value is already set when identical */ else if (sys_lsetxattr(fname, name, ptr, len) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed", fname, name); ret = -1; @@ -745,7 +745,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp, } if (sys_lsetxattr(fname, name, rxas[i].datum, rxas[i].datum_len) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "rsync_xal_set: lsetxattr(\"%s\",\"%s\") failed", fname, name); ret = -1; @@ -772,7 +772,7 @@ static int rsync_xal_set(const char *fname, item_list *xalp, } if (i == xalp->count) { if (sys_lremovexattr(fname, name) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "rsync_xal_clear: lremovexattr(\"%s\",\"%s\") failed", fname, name); ret = -1; @@ -815,7 +815,7 @@ int set_xattr_acl(const char *fname, int is_access_acl, const char *buf, size_t { const char *name = is_access_acl ? XACC_ACL_ATTR : XDEF_ACL_ATTR; if (sys_lsetxattr(fname, name, buf, buf_len) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "set_xattr_acl: lsetxattr(\"%s\",\"%s\") failed", fname, name); return -1; @@ -860,7 +860,7 @@ int get_stat_xattr(const char *fname, int fd, STRUCT_STAT *fst, STRUCT_STAT *xst xst->st_gid = 0; return 0; } - rsyserr(FERROR, errno, "failed to read xattr %s for %s", + rsyserr(FERROR_XFER, errno, "failed to read xattr %s for %s", XSTAT_ATTR, full_fname(fname)); return -1; } @@ -891,13 +891,13 @@ int set_stat_xattr(const char *fname, struct file_struct *file) return 0; if (read_only || list_only) { - rsyserr(FERROR, EROFS, "failed to write xattr %s for %s", + rsyserr(FERROR_XFER, EROFS, "failed to write xattr %s for %s", XSTAT_ATTR, full_fname(fname)); return -1; } if (x_lstat(fname, &fst, &xst) < 0) { - rsyserr(FERROR, errno, "failed to re-stat %s", + rsyserr(FERROR_XFER, errno, "failed to re-stat %s", full_fname(fname)); return -1; } @@ -923,7 +923,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file) && fst.st_uid == F_OWNER(file) && fst.st_gid == F_GROUP(file)) { /* xst.st_mode will be 0 if there's no current stat xattr */ if (xst.st_mode && sys_lremovexattr(fname, XSTAT_ATTR) < 0) { - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "delete of stat xattr failed for %s", full_fname(fname)); return -1; @@ -941,7 +941,7 @@ int set_stat_xattr(const char *fname, struct file_struct *file) if (sys_lsetxattr(fname, XSTAT_ATTR, buf, len) < 0) { if (errno == EPERM && S_ISLNK(fst.st_mode)) return 0; - rsyserr(FERROR, errno, + rsyserr(FERROR_XFER, errno, "failed to write xattr %s for %s", XSTAT_ATTR, full_fname(fname)); return -1; |