Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Jun 2004 17:07:43 +0700 (NOVST)
From:      Dmitry A Grigorovich <odip@bionet.nsc.ru>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/67445: [PATCH] mirror don't fetch files with $ in names when update_local=yes
Message-ID:  <200406011007.i51A7hBh029226@pierino.bionet.nsc.ru>
Resent-Message-ID: <200406011010.i51AAFUh038822@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         67445
>Category:       ports
>Synopsis:       [PATCH] mirror don't fetch files with $ in names when update_local=yes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 01 03:10:14 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Dmitry A Grigorovich
>Release:        FreeBSD 4.8-RELEASE i386
>Organization:
ICiG SB RAS
>Environment:
System: FreeBSD pierino.bionet.nsc.ru 4.8-RELEASE FreeBSD 4.8-RELEASE #5: Sat Oct 4 02:28:14 NOVST 2003 root@pierino.bionet.nsc.ru:/usr/obj/usr/src/sys/ODIP i386
>Description:

Use port ftp/mirror and include update_local=yes in config
This mean, that mirror must update only files, which present in local directory

To do this mirror scan local directory and build get_patt pattern.
Pattern get_patt have perl RE syntax, like '^file1$|^file2$'.
This pattern must match only local files and no more.

Next step, mirror list remote files and update only files,
which match get_patt.

But mirror incorrectly build get_patt pattern
if file name have special characters like '^', '$' and other.
Pattern don't match this files and accordingly mirror
don't update this files from remote site.

>How-To-Repeat:

1) Create file config with content:

package=test
        comment=test
        site=ftp.bionet.nsc.ru
        passive_ftp=true
        # where to start pulling files back from
        remote_dir=/test
        # where to put the files on your machine
        local_dir=/home/odip/mirror/local
	update_local=yes

2) Put non empty files to ftp://ftp.bionet.nsc.ru/test/
    with names: normal_file, $bad_file, bad_file$

root# ls -l /home/ftp/test
total 6
-rw-r--r--  1 root  wheel   9 Jun  1 16:44 $bad_file
-rw-r--r--  1 root  wheel   9 Jun  1 16:44 bad_file$
-rw-r--r--  1 root  wheel  12 Jun  1 16:16 normal_file

3) Create empty dir local
   Create empty files with names: normal_file, $bad_file, bad_file$

odip$ ls -l local
total 0
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 16:58 $bad_file
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 16:58 bad_file$
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 16:58 normal_file

4) Run mirror in debug mode

odip@hydra$ mirror -d -p test ./config
package=test ftp.bionet.nsc.ru:/test -> /home/odip/mirror/local
Scanning local directory /home/odip/mirror/local
get_patt = ^$bad_file|^bad_file$|^normal_file
Scanning remote directory /test
compare directories (src 3, dest 3)
No files to transfer
unlink /home/odip/mirror/local/bad_file$
unlink /home/odip/mirror/local/$bad_file

disconnecting from ftp.bionet.nsc.ru
All done, Exiting


ERROR: get_patt in invalid and mirror remove two files !!!

5) Show local directory

odip@hydra$ ls -l local
total 2
-r--r--r--  1 odip  odip  12  1 ÉÀÎ 09:16 normal_file

>Fix:

Put follow file into /usr/ports/ftp/mirror/files
Remove port ftp/mirror
Build and install port ftp/mirror

--- patch-ba begins here ---
--- mirror.pl.orig	Thu Aug  7 11:47:06 2003
+++ mirror.pl	Fri Apr 30 14:21:48 2004
@@ -1323,8 +1323,11 @@
 
 		# Create a get_patt from the contents of the local directory
 		if( $update_local && $#get_top >= 0 ){
-			$get_patt = '^' . join( '|^', @get_top );
-			$get_patt =~ s/$squished//g;
+			my ($path,$re,@re_patt);
+			#$get_patt = '^' . join( '|^', @get_top );
+			#$get_patt =~ s/$squished//g;
+			foreach $path ( @get_top ) { push @re_patt, "\^\Q$path\E\$"; }
+			$get_patt= join( '|', @re_patt );
 			&msg( "get_patt = $get_patt\n" ) if $debug;
 		}
 	
--- patch-ba ends here ---


Try again test above

3) Create empty dir local
   Create empty files with names: normal_file, $bad_file, bad_file$

odip$ ls -l local
total 0
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 17:03 $bad_file
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 17:03 bad_file$
-rw-r--r--  1 odip  odip  0  1 ÉÀÎ 17:04 normal_file

4) Run mirror in debug mode

odip@hydra$ mirror -d -p test ./config
package=test ftp.bionet.nsc.ru:/test -> /home/odip/mirror/local
Scanning local directory /home/odip/mirror/local
get_patt = ^\$bad_file$|^bad_file\$$|^normal_file$
Scanning remote directory /test
compare directories (src 3, dest 3)
Got bad_file$ 9 0
Got $bad_file 9 0
Got normal_file 12 0

disconnecting from ftp.bionet.nsc.ru
All done, Exiting

5) Show local directory

odip@hydra$ ls -l local
total 6
-r--r--r--  1 odip  odip   9  1 ÉÀÎ 09:44 $bad_file
-r--r--r--  1 odip  odip   9  1 ÉÀÎ 09:44 bad_file$
-r--r--r--  1 odip  odip  12  1 ÉÀÎ 09:16 normal_file


All is ok - files mirrored
>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406011007.i51A7hBh029226>