fixed the relative paths bug pointed out by Alberto Accomazzi
[rsync/rsync.git] / rsync.c
diff --git a/rsync.c b/rsync.c
index 9681827..f5a1f48 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -441,6 +441,15 @@ static void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
 #if SUPPORT_LINKS
                char lnk[MAXPATHLEN];
                int l;
+               extern int safe_symlinks;
+
+               if (safe_symlinks && unsafe_symlink(file->link, fname)) {
+                       if (verbose) {
+                               rprintf(FINFO,"ignoring unsafe symlink %s -> %s\n",
+                                       fname,file->link);
+                       }
+                       return;
+               }
                if (statret == 0) {
                        l = readlink(fname,lnk,MAXPATHLEN-1);
                        if (l > 0) {
@@ -457,9 +466,10 @@ static void recv_generator(char *fname,struct file_list *flist,int i,int f_out)
                                fname,file->link,strerror(errno));
                } else {
                        set_perms(fname,file,NULL,0);
-                       if (verbose) 
+                       if (verbose) {
                                rprintf(FINFO,"%s -> %s\n",
                                        fname,file->link);
+                       }
                }
 #endif
                return;
@@ -688,7 +698,7 @@ static void delete_one(struct file_struct *f)
 
 static struct delete_list {
        dev_t dev;
-       ino_t inode;
+       INO_T inode;
 } *delete_list;
 static int dlist_len, dlist_alloc_len;
 
@@ -845,7 +855,7 @@ static void finish_transfer(char *fname, char *fnametmp, struct file_struct *fil
                if (errno == EXDEV) {
                        /* rename failed on cross-filesystem link.  
                           Copy the file instead. */
-                       if (copy_file(fnametmp,fname, file->mode)) {
+                       if (copy_file(fnametmp,fname, file->mode & ACCESSPERMS)) {
                                rprintf(FERROR,"copy %s -> %s : %s\n",
                                        fnametmp,fname,strerror(errno));
                        } else {
@@ -951,7 +961,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
 
                if (!get_tmpname(fnametmp,fname)) {
                        if (buf) unmap_file(buf);
-                       close(fd1);
+                       if (fd1 != -1) close(fd1);
                        continue;
                }
 
@@ -959,7 +969,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                        rprintf(FERROR,"mktemp %s failed\n",fnametmp);
                        receive_data(f_in,buf,-1,NULL,file->length);
                        if (buf) unmap_file(buf);
-                       close(fd1);
+                       if (fd1 != -1) close(fd1);
                        continue;
                }
 
@@ -980,7 +990,7 @@ int recv_files(int f_in,struct file_list *flist,char *local_name,int f_gen)
                        rprintf(FERROR,"open %s : %s\n",fnametmp,strerror(errno));
                        receive_data(f_in,buf,-1,NULL,file->length);
                        if (buf) unmap_file(buf);
-                       close(fd1);
+                       if (fd1 != -1) close(fd1);
                        continue;
                }