Some daemon security improvements, including the new parameters
[rsync/rsync.git] / flist.c
diff --git a/flist.c b/flist.c
index 3616a8e..2035045 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -1037,9 +1037,15 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
                }
                if (save_errno == ENOENT) {
 #ifdef SUPPORT_LINKS
-                       /* Avoid "vanished" error if symlink points nowhere. */
-                       if (copy_links && x_lstat(thisname, &st, NULL) == 0
-                           && S_ISLNK(st.st_mode)) {
+                       /* When our options tell us to follow a symlink that
+                        * points nowhere, tell the user about the symlink
+                        * instead of giving a "vanished" message.  We only
+                        * dereference a symlink if one of the --copy*links
+                        * options was specified, so there's no need for the
+                        * extra lstat() if one of these options isn't on. */
+                       if ((copy_links || copy_unsafe_links || copy_dirlinks)
+                        && x_lstat(thisname, &st, NULL) == 0
+                        && S_ISLNK(st.st_mode)) {
                                io_error |= IOERR_GENERAL;
                                rprintf(FERROR_XFER, "symlink has no referent: %s\n",
                                        full_fname(thisname));
@@ -2031,7 +2037,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[])
        flist_sort_and_clean(flist, 0);
        file_total += flist->used;
 
-       if (!numeric_ids && !inc_recurse)
+       if (numeric_ids <= 0 && !inc_recurse)
                send_id_list(f);
 
        /* send the io_error flag */