| 1 |
#! /bin/sh |
| 2 |
|
| 3 |
# not checked (list incomplete): |
| 4 |
# --timeout |
| 5 |
|
| 6 |
if test "x$PUBLICFILE_FTPD" = x ; then |
| 7 |
PUBLICFILE_FTPD="/usr/local/publicfile/bin/ftpd" |
| 8 |
fi |
| 9 |
LC_ALL=C ; export LC_ALL |
| 10 |
LANG=C ; export LANG |
| 11 |
unset BC_LINE_LENGTH |
| 12 |
unset BC_ENV_ARGS |
| 13 |
|
| 14 |
shortcut=0 # or 0 for full test |
| 15 |
|
| 16 |
for i in `echo $PATH | sed 's/:/ /g'` ; do |
| 17 |
if test -x $i/printenv ; then |
| 18 |
PRINTENV=$i/printenv |
| 19 |
fi |
| 20 |
done |
| 21 |
if test "x$PRINTENV" = x ; then echo "printenv not found" >&2 ; exit 1 ; fi |
| 22 |
|
| 23 |
|
| 24 |
rm -rf tmp.check |
| 25 |
mkdir tmp.check || exit 1 |
| 26 |
O=`pwd` |
| 27 |
cd tmp.check |
| 28 |
N=`pwd` |
| 29 |
mkdir client || exit 1 |
| 30 |
|
| 31 |
# find out how to set the time zone to POSIX UTC (not that it's better |
| 32 |
# than right/UTC, but the tests expect POSIX). |
| 33 |
cat >auto-tztest.c <<EOF |
| 34 |
#include <stdio.h> |
| 35 |
#include <string.h> |
| 36 |
#include <time.h> |
| 37 |
int main(void) { |
| 38 |
time_t x=0x3fffffff; |
| 39 |
fputs(ctime(&x),stdout); |
| 40 |
return 0; |
| 41 |
} |
| 42 |
EOF |
| 43 |
$O/auto-compile.sh -g -O2 -o $O/auto-tztest auto-tztest.c || exit 1 |
| 44 |
|
| 45 |
for i in posix/UTC UTC ; do |
| 46 |
t=`TZ=$i $O/auto-tztest` |
| 47 |
if test "x$t" = "xSat Jan 10 13:37:03 2004" ; then |
| 48 |
mytz=$i |
| 49 |
fi |
| 50 |
done |
| 51 |
rm $O/auto-tztest |
| 52 |
if test "x$mytz" = x ; then |
| 53 |
echo "failed to find out how to use posix/UTC" >&2 |
| 54 |
exit 1 |
| 55 |
fi |
| 56 |
TZ=$mytz |
| 57 |
export TZ |
| 58 |
|
| 59 |
echo '--- canon works as expected' |
| 60 |
$O/auto-compile.sh -I$O -DTEST -g -O2 -o $O/auto-canon $O/canon.c \ |
| 61 |
$O/libuomisc.a $O/libunix.a $O/libbyte.a |
| 62 |
$O/auto-canon <<EOF |
| 63 |
/files/dir/test.jpg |
| 64 |
/files/dir/../test.jpg |
| 65 |
/files/dir/../dir2/test.jpg |
| 66 |
/files/dir/../../test.jpg |
| 67 |
/files/dir/../../files2/dir2/test.jpg |
| 68 |
/files/dir/../../../files2/dir2/test.jpg |
| 69 |
../files2/dir2/test.jpg |
| 70 |
/../files2/dir2/test.jpg |
| 71 |
/f/d/../f2/x |
| 72 |
/f/../../d/x |
| 73 |
/f/d/../../x |
| 74 |
../x |
| 75 |
/files/dir/../../../files2/dir2/test.jpg |
| 76 |
files/dir/../../../files2/dir2/test.jpg |
| 77 |
EOF |
| 78 |
|
| 79 |
echo '--- ftpparse works as expected' |
| 80 |
cat >fptest.c <<EOF |
| 81 |
#include <stdio.h> |
| 82 |
#include <string.h> |
| 83 |
#include <time.h> |
| 84 |
#include "$O/ftpparse.h" |
| 85 |
int main(int argc, char **argv) |
| 86 |
{ |
| 87 |
char buf[1024]; |
| 88 |
struct ftpparse f; |
| 89 |
while (fgets(buf,sizeof(buf),stdin)) { |
| 90 |
char *p; |
| 91 |
char *c=strchr(buf,'\n'); |
| 92 |
int x; |
| 93 |
if (c) *c=0; |
| 94 |
if (*buf=='#') {puts(buf); continue; } |
| 95 |
printf("in: %s:\n",buf); |
| 96 |
|
| 97 |
/* for the sake of memory debuggers */ |
| 98 |
p=strdup(buf); if (!p) return 1; |
| 99 |
if (0==strncmp(p,"MLST:",5)) |
| 100 |
x=ftpparse_mlsx(&f, p+5,strlen(p)-5,1); |
| 101 |
else if (0==strncmp(p,"MLSD:",5)) |
| 102 |
x=ftpparse_mlsx(&f, p+5,strlen(p)-5,0); |
| 103 |
else |
| 104 |
x=ftpparse(&f, p,strlen(p), argc>1); |
| 105 |
if (!x) { |
| 106 |
puts(" unparsable\n"); |
| 107 |
continue; |
| 108 |
} |
| 109 |
fputs(" name: ",stdout); fwrite(f.name,f.namelen,1,stdout); |
| 110 |
printf("\n namelen: %d\n",f.namelen); |
| 111 |
if (f.flagtrycwd) |
| 112 |
fputs(" may be directory\n",stdout); |
| 113 |
if (f.flagtryretr) |
| 114 |
fputs(" may be file\n",stdout); |
| 115 |
if (f.sizetype==FTPPARSE_SIZE_UNKNOWN) { |
| 116 |
puts(" size: unknown"); |
| 117 |
} else { |
| 118 |
printf(" sizetype: %d\n",f.sizetype); |
| 119 |
printf(" size: "); |
| 120 |
#define MRD 1000000000 |
| 121 |
if (f.size >= MRD) { |
| 122 |
unsigned long x,y; |
| 123 |
x=f.size / MRD; |
| 124 |
y=f.size % MRD; |
| 125 |
printf("%lu%08lu\n",x,y); |
| 126 |
} else |
| 127 |
printf("%lu\n",(unsigned long)f.size); |
| 128 |
} |
| 129 |
if (f.mtimetype == FTPPARSE_MTIME_UNKNOWN) { |
| 130 |
puts(" mtime: unknown"); |
| 131 |
} else { |
| 132 |
time_t t; |
| 133 |
t=f.mtime.x-4611686018427387914ULL; |
| 134 |
printf(" mtimetype: %d\n",f.mtimetype); |
| 135 |
printf(" mtime: %ld %s",t,ctime(&t)); |
| 136 |
} |
| 137 |
if (f.idtype == FTPPARSE_ID_UNKNOWN) { |
| 138 |
puts(" id: unknown"); |
| 139 |
} else { |
| 140 |
printf(" idtype: %d\n",f.idtype); |
| 141 |
fputs(" id: ",stdout); fwrite(f.id,f.idlen,1,stdout); |
| 142 |
printf("\n idlen: %d\n",f.idlen); |
| 143 |
} |
| 144 |
if (f.flagbrokenmlsx) |
| 145 |
puts(" has unterminated MLSX fact list"); |
| 146 |
free(p); |
| 147 |
} |
| 148 |
return 0; |
| 149 |
} |
| 150 |
EOF |
| 151 |
$O/auto-compile.sh -g -O2 -o fptest fptest.c \ |
| 152 |
$O/ftpparse.o $O/utcdate2tai.o $O/libtai.a $O/libbyte.a |
| 153 |
THISYEAR=`date +%Y` |
| 154 |
LASTYEAR=`echo $THISYEAR - 1 | bc` |
| 155 |
( |
| 156 |
./fptest <<EOF |
| 157 |
# generic scan_time checks. |
| 158 |
04-27-99 7:28:39 <DIR> licensed |
| 159 |
04-27-99 07:28:39 <DIR> licensed |
| 160 |
04-27-99 17:28:39 <DIR> licensed |
| 161 |
04-27-99 07:28:39AM <DIR> licensed |
| 162 |
04-27-99 07:28:39PM <DIR> licensed |
| 163 |
04-27-99 7:28 <DIR> licensed |
| 164 |
04-27-99 07:28 <DIR> licensed |
| 165 |
04-27-99 07:28AM <DIR> licensed |
| 166 |
04-27-99 07:28PM <DIR> licensed |
| 167 |
# bad things |
| 168 |
04-27-99 :28:39 <DIR> licensed |
| 169 |
04-27-99 :28 <DIR> licensed |
| 170 |
04-27-99 7:2:39 <DIR> licensed |
| 171 |
04-27-99 07:28:3 <DIR> licensed |
| 172 |
04-27-99 17:28: <DIR> licensed |
| 173 |
04-27-99 007:28:39 <DIR> licensed |
| 174 |
04-27-99 07:028:39 <DIR> licensed |
| 175 |
04-27-99 07:28:039 <DIR> licensed |
| 176 |
04-27-99 07:28:039AM <DIR> licensed |
| 177 |
04-27-99 07:28:039PM <DIR> licensed |
| 178 |
04-27-99 07:28:9AM <DIR> licensed |
| 179 |
04-27-99 07:28:9PM <DIR> licensed |
| 180 |
04-27-99 07:28:39A <DIR> licensed |
| 181 |
04-27-99 07:28:39P <DIR> licensed |
| 182 |
04-27-99 007:28 <DIR> licensed |
| 183 |
04-27-99 07:028 <DIR> licensed |
| 184 |
04-27-99 07:2 <DIR> licensed |
| 185 |
04-27-99 07:2 <DIR> licensed |
| 186 |
04-27-99 07 <DIR> licensed |
| 187 |
04-27-99 07:28A <DIR> licensed |
| 188 |
04-27-99 07:28P <DIR> licensed |
| 189 |
# EPLF |
| 190 |
+i8388621.29609,m824255902,/, dev |
| 191 |
+i8388621.44468,m839956783,r,s10376, RFCEPLF |
| 192 |
+i8388621.44468,m839956783,r,s10000000000, RFCEPLF |
| 193 |
+i8388621.44468,m839956783,r,s10376, RFC EPLF |
| 194 |
# bad EPLF |
| 195 |
+i8388621.44468,m839956783,r,s10376, |
| 196 |
+i8388621.44468,m839956783,r,s10376, |
| 197 |
+i8388621.44468,m839956783,r,s10376 |
| 198 |
+i,m839956783,r,s10376, RFCEPLF |
| 199 |
+i8388621.44468,m,r,s10376, RFCEPLF |
| 200 |
+i8388621.44468,m839956783,r,s, RFCEPLF |
| 201 |
# note: not tab, but space. |
| 202 |
+i8388621.44468,m839956783,r,s10376, RFCEPLF |
| 203 |
# VMS / MultiNet |
| 204 |
00README.TXT;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE) |
| 205 |
CORE.DIR;1 1 8-SEP-1996 16:09 [SYSTEM] (RWE,RWE,RE,RE) |
| 206 |
CII-MANUAL.TEX;1 213/216 29-JAN-1996 03:33:12 [ANONYMOU,ANONYMOUS] (RWED,RWED,,) |
| 207 |
DSPD.MAN;1 9 1-APR-1991 12:55 [SG,ROSENBLUM] (RWED,RWED,RE,RE) |
| 208 |
[VMSSERV.FILES]ALARM.DIR;1 1/3 5-MAR-1993 18:09 |
| 209 |
# bad VMS / MultiNet |
| 210 |
00README.TXT; 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE) |
| 211 |
00README.TXT 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE) |
| 212 |
00README.TXT;1 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE) |
| 213 |
.DIR;1 2 30-DEC-1996 17:44 [SYSTEM] (RWED,RWED,RE,RE) |
| 214 |
# unix |
| 215 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16:32 s.uogetopt.c |
| 216 |
-r--r--r-- 1 uwe ohse 1382 Dec 18 1991 s.sig.c |
| 217 |
lrwxr-xr-x 1 uwe ohse 18 Dec 31 1999 SCCS -> XXXXX |
| 218 |
lrwxrwxrwx 1 root root 35 Jun 19 10:46 mmmm -> dddd |
| 219 |
-rw-r--r-- 1 root other 531 Jan 29 03:26 README |
| 220 |
dr-xr-xr-x 2 root other 512 Apr 8 1994 etc |
| 221 |
dr-xr-xr-x 2 root 512 Apr 8 1994 etc |
| 222 |
lrwxrwxrwx 1 root other 7 Jan 25 00:17 bin -> usr/bin |
| 223 |
# stranger cases |
| 224 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 1996 file name |
| 225 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 1996 my file name |
| 226 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 1996 17:01 file name |
| 227 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 1996 17:01 |
| 228 |
-rwxrwxrwx 1 uwe ohse 27040 Jan 29 1996 spacy |
| 229 |
drwxrwxrwx 1 uwe ohse 1024 Jan 29 1996 spacydir |
| 230 |
- 1 u o 3 Jan 29 1996 17:01 a b c d e f g h i j k l m n o p q r s t |
| 231 |
# bad unix |
| 232 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16:32 |
| 233 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16:32s.uogetopt.c |
| 234 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16:3 s.uogetopt.c |
| 235 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16: s.uogetopt.c |
| 236 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 16 s.uogetopt.c |
| 237 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 s.uogetopt.c |
| 238 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 199 s.uogetopt.c |
| 239 |
-r--r--r-- 1 uwe ohse 27040 jan 29 16:32 s.uogetopt.c |
| 240 |
-r--r--r-- 1 uwe ohse 27040 an 29 16:32 s.uogetopt.c |
| 241 |
-r--r--r-- 1 uwe ohse Jan 29 16:32 s.uogetopt.c |
| 242 |
-r--r--r-- 1 uwe 27040 Jan 29 16:32 s.uogetopt.c |
| 243 |
-r--r--r-- 1 ohse 27040 Jan 29 16:32 s.uogetopt.c |
| 244 |
-r--r--r-- uwe ohse 27040 Jan 29 16:32 s.uogetopt.c |
| 245 |
1 uwe ohse 27040 Jan 29 16:32 s.uogetopt.c |
| 246 |
l 1 uwe ohse 27040 Jan 29 16:32 s.uogetopt.c |
| 247 |
l 1 uwe ohse 27040 Jan 29 16:32 s.uogetopt.c -> ooo |
| 248 |
br--r--r-- 1 uwe ohse 27040 Jan 29 16:32 s.uogetopt.c -> ooo |
| 249 |
br--r--r-- 1 uwe ohse 12345627040 Jan 29 16:32 s.uogetopt.c |
| 250 |
br--r--r-- 1 uwe ohse 10000000000 Jan 29 16:32 s.uogetopt.c |
| 251 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 96 16:32 s.uogetopt.c |
| 252 |
-r--r--r-- 1 uwe ohse 27040 Jan 29 1996 16:32 s.uogetopt.c |
| 253 |
# Microsoft's FTP server for Windows: |
| 254 |
---------- 1 owner group 1803128 Jul 10 10:18 ls-lR.Z |
| 255 |
d--------- 1 owner group 0 May 9 19:45 Softlib |
| 256 |
# WFTPD for Windows: |
| 257 |
-rwxrwxrwx 1 noone nogroup 322 Aug 19 1996 message.ftp |
| 258 |
# NetPresenz for the Mac: |
| 259 |
-------r-- 326 1391972 1392298 Nov 22 1995 MegaPhone.sit |
| 260 |
drwxrwxr-x folder 2 May 10 1996 network |
| 261 |
# MSDOS |
| 262 |
4-27-00 09:09PM <DIR> licensed |
| 263 |
7-18-00 10:16AM <DIR> pub |
| 264 |
4-14-00 03:47PM 589 readme.htm |
| 265 |
03-16-94 06:29AM <DIR> . |
| 266 |
03-16-94 06:29AM <DIR> .. |
| 267 |
04-11-94 11:48PM <DIR> creative |
| 268 |
03-08-94 07:17AM 5504 article.xfiles.intro |
| 269 |
02-28-94 11:44AM 3262 article1.gillian.anderson |
| 270 |
02-28-04 11:44AM 3262 article1.gillian.anderson |
| 271 |
02-28-94 11:44:55AM 3262 article1.gillian.anderson |
| 272 |
02-28-94 11:44AM 10000000000 article1.gillian.anderson |
| 273 |
02-28-1994 11:44AM 3262 article1.gillian.anderson |
| 274 |
# MSDOS with leading spaces, aka NT. |
| 275 |
03-16-94 06:29AM <DIR> dirnamewithleadingspace |
| 276 |
03-16-94 06:29AM 123 filenamewithleadingspace |
| 277 |
# bad MSDOS |
| 278 |
2-28-94 11:44AM 3262 article1.gillian.anderson |
| 279 |
02-8-94 11:44AM 3262 article1.gillian.anderson |
| 280 |
02-28-4 11:44AM 3262 article1.gillian.anderson |
| 281 |
02-28-94 11:44AM article1.gillian.anderson |
| 282 |
02-28-94 11:44AM 3262 |
| 283 |
02-28-94 11:44AM 3262 |
| 284 |
# NetWare. Quite like unix. |
| 285 |
d [R----F--] supervisor 512 Jan 16 18:53 login |
| 286 |
- [R----F--] rhesus 214059 Oct 20 15:27 cx.exe |
| 287 |
- [R----F--] jrd 197928 Sep 25 15:19 kermit.exe |
| 288 |
d [R----F--] jrd 512 Oct 06 09:31 source |
| 289 |
d [RWCEAFMS] jrd 512 Sep 04 14:38 lwp |
| 290 |
d [R----F-] 1 carl 512 Mar 12 15:47 txt |
| 291 |
- [-RWCE-F-] mlm 11820 Feb 3 93 12:00 drivers.doc |
| 292 |
-[R----F-] 1 supervis 256 Nov 15 14:21 readme.txt |
| 293 |
# supertcp |
| 294 |
. <DIR> 11-16-94 17:16 |
| 295 |
.. <DIR> 11-16-94 17:16 |
| 296 |
INSTALL <DIR> 11-16-94 17:17 |
| 297 |
CMT <DIR> 11-21-94 10:17 |
| 298 |
DESIGN1.DOC 11264 05-11-95 14:20 |
| 299 |
README.TXT 1045 05-10-95 11:01 |
| 300 |
WPKIT1.EXE 960338 06-21-95 17:01 |
| 301 |
CMT.CSV 0 07-06-95 14:56 |
| 302 |
# bad supertcp |
| 303 |
WPKIT1.EXE 06-21-95 17:01 |
| 304 |
WPKIT1.EXE 10000000000 06-21-95 17:01 |
| 305 |
WPKIT1.EXE 960338 6-21-95 17:01 |
| 306 |
# OS/2 |
| 307 |
0 DIR 04-11-95 16:26 . |
| 308 |
0 DIR 04-11-95 16:26 .. |
| 309 |
0 DIR 04-11-95 16:26 ADDRESS |
| 310 |
612 A 07-28-95 16:45 air_tra1.bag |
| 311 |
195 A 08-09-95 10:23 Alfa1.bag |
| 312 |
0 DIR 04-11-95 16:26 ATTACH |
| 313 |
372 A 08-09-95 10:26 Aussie_1.bag |
| 314 |
310992 06-28-94 09:56 INSTALL.EXE |
| 315 |
# ------------------------------ VM/CMS |
| 316 |
DIRACC EXEC A1 F 132 84 3 01/25/93 14:49:47 |
| 317 |
DIRUNIX SCRIPT A1 V 77 1216 17 01/04/93 20:30:47 |
| 318 |
MAIL PROFILE A2 F 80 1 1 10/14/92 16:12:27 |
| 319 |
# MLSD |
| 320 |
MLSD:size=4161;lang=en-US;modify=19970214165800;create=19961001124534;type=file;x.myfact=foo,bar; filename |
| 321 |
MLST: Type=file;Size=1024990;Perm=r; /tmp/cap60.pl198.tar.gz |
| 322 |
MLST: Type=dir;Modify=19981107085215;Perm=el; /tmp |
| 323 |
MLSD:Type=cdir;Modify=19981107085215;Perm=el; tmp |
| 324 |
MLSD:Type=cdir;Modify=19981107085215;Perm=el; /tmp |
| 325 |
MLSD:Type=pdir;Modify=19990112030508;Perm=el; .. |
| 326 |
MLSD:Type=file;Size=25730;Modify=19940728095854;Perm=; capmux.tar.z |
| 327 |
MLSD:Type=file;Size=1830;Modify=19940916055648;Perm=r; hatch.c |
| 328 |
MLSD:Type=file;Size=25624;Modify=19951003165342;Perm=r; MacIP-02.txt |
| 329 |
MLSD:Type=file;Size=2154;Modify=19950501105033;Perm=r; uar.netbsd.patch |
| 330 |
MLSD:Type=file;Size=54757;Modify=19951105101754;Perm=r; iptnnladev.1.0.sit.hqx |
| 331 |
MLSD:Type=file;Size=226546;Modify=19970515023901;Perm=r; melbcs.tif |
| 332 |
MLSD:Type=file;Size=12927;Modify=19961025135602;Perm=r; tardis.1.6.sit.hqx |
| 333 |
MLST: Type=dir;Perm=el;Unique=keVO1+ZF4 test |
| 334 |
MLSD:Type=cdir;Perm=el;Unique=keVO1+ZF4; test |
| 335 |
MLSD:Type=pdir;Perm=e;Unique=keVO1+d?3; .. |
| 336 |
MLSD:Type=OS.unix=slink:/foobar;Perm=;Unique=keVO1+4G4; foobar |
| 337 |
MLSD:Type=OS.unix=chr-13/29;Perm=;Unique=keVO1+5G4; device |
| 338 |
MLSD:Type=OS.unix=blk-11/108;Perm=;Unique=keVO1+6G4; block |
| 339 |
MLSD:Type=file;Perm=awr;Unique=keVO1+8G4; writable |
| 340 |
MLSD:Type=dir;Perm=cpmel;Unique=keVO1+7G4; promiscuous |
| 341 |
MLSD:Type=dir;Perm=;Unique=keVO1+1t2; no-exec |
| 342 |
MLSD:Type=file;Perm=r;Unique=keVO1+EG4; two words |
| 343 |
MLSD:Type=file;Perm=r;Unique=keVO1+IH4; leading space |
| 344 |
MLSD:Type=file;Perm=r;Unique=keVO1+1G4; file1 |
| 345 |
MLSD:Type=dir;Perm=cpmel;Unique=keVO1+7G4; incoming |
| 346 |
MLSD:Type=file;Perm=r;Unique=keVO1+1G4; file2 |
| 347 |
MLSD:Type=file;Perm=r;Unique=keVO1+1G4; file3 |
| 348 |
MLSD:Type=file;Perm=r;Unique=keVO1+1G4; file4 |
| 349 |
# checking the "usual" MLSX brokeness, too. |
| 350 |
MLSD:size=4161;lang=en-US;modify=19970214165800;create=19961001124534;type=file;x.myfact=foo,bar filename |
| 351 |
EOF |
| 352 |
echo '--- ftpparse handling of file names starting with spaces' |
| 353 |
./fptest <<EOF |
| 354 |
# AIX 5.1 server - note the space at a different place |
| 355 |
-rw-r--r-- 1 818 epsystem 4 Jan 01 2000 junk-old |
| 356 |
-rw-r--r-- 1 818 epsystem 5 Sep 26 08:10 junk-new |
| 357 |
# this isn't AIX, but ... |
| 358 |
-rw-r--r-- 1 818 epsystem 4 Jan 01 2000 junk-old2 |
| 359 |
EOF |
| 360 |
echo '--- ftpparse eating spaces when ordered' |
| 361 |
./fptest 12345 <<EOF |
| 362 |
# AIX 5.1 server - note the space at a different place |
| 363 |
-rw-r--r-- 1 818 epsystem 4 Jan 01 2000 junk-old |
| 364 |
-rw-r--r-- 1 818 epsystem 5 Sep 26 08:10 junk-new |
| 365 |
# this isn't AIX, but ... |
| 366 |
-rw-r--r-- 1 818 epsystem 4 Jan 01 2000 junk-old2 |
| 367 |
EOF |
| 368 |
) | sed -e "s/$THISYEAR/SOMEYEAR/" -e "s/$LASTYEAR/SOMEYEAR/" \ |
| 369 |
-e "s/mtime:.*SOMEYEAR/mtime: LAST 12 MONTHS/" |
| 370 |
# The problem lthe lines above solve is that "Nov 15 16:32" will be |
| 371 |
# interpreted as "$LASTYEAR", or, after that time, as $THISYEAR. |
| 372 |
# i checked whether this stuff really works, at least once. |
| 373 |
|
| 374 |
rm -f fptest fptest.o |
| 375 |
|
| 376 |
#TZ=right/UTC # get rid of TAI / UTC difference |
| 377 |
#export TZ |
| 378 |
|
| 379 |
echo '--- ftpcopy prints usage message without enough arguments' |
| 380 |
$O/ftpcopy ; echo $? |
| 381 |
$O/ftpcopy 127.255.255.255 ; echo $? |
| 382 |
echo '--- ftpcopy refuses default localdir . without -n option' |
| 383 |
$O/ftpcopy ftp://127.255.255.255:0/ ; echo $? |
| 384 |
$O/ftpcopy 127.255.255.255 0 ; echo $? |
| 385 |
echo '--- ftpcopy prints usage message with too many arguments' |
| 386 |
$O/ftpcopy ftp://127.255.255.255:0/ client superfluous ; echo $? |
| 387 |
$O/ftpcopy ftp://127.255.255.255:0/ client superfluous super2 ; echo $? |
| 388 |
$O/ftpcopy 127.255.255.255:0 / client superfluous ; echo $? |
| 389 |
$O/ftpcopy 127.255.255.255:0 / client superfluous super2 ; echo $? |
| 390 |
echo '--- ftpcopy refuses unknown url schemes' |
| 391 |
$O/ftpcopy ftpcopy://127.255.255.255:0/ ; echo $? |
| 392 |
$O/ftpcopy http://127.255.255.255:0/ ; echo $? |
| 393 |
$O/ftpcopy Ftp://127.255.255.255:0/ ; echo $? |
| 394 |
echo '--- ftpcopy prints error message with unknown port name' |
| 395 |
$O/ftpcopy ftp://127.255.255.255:nonexistantport/ client ; echo $? |
| 396 |
$O/ftpcopy 127.255.255.255:nonexistantport / client ; echo $? |
| 397 |
echo '--- ftpcopy prints error message with unknown host name' |
| 398 |
$O/ftpcopy ftp://nonexistinghost:ftp/ client ; echo $? |
| 399 |
$O/ftpcopy nonexistinghost:ftp / client ; echo $? |
| 400 |
echo '--- ftpcopy prints error message with unresolvable host name' |
| 401 |
$O/ftpcopy ftp://thislabelistoolongbecausednshasalimitof63charactersinasinglelabel.:ftp/ client ; echo $? |
| 402 |
$O/ftpcopy thislabelistoolongbecausednshasalimitof63charactersinasinglelabel.:ftp / client ; echo $? |
| 403 |
|
| 404 |
echo '--- set up ftp service' |
| 405 |
mkdir $N/server |
| 406 |
mkdir $N/server/ftpd |
| 407 |
mkdir $N/server/file |
| 408 |
mkdir $N/server/file/0 |
| 409 |
cat >$N/server/ftpd/run <<EOF |
| 410 |
#!/bin/sh |
| 411 |
# one million bytes for the shell ... |
| 412 |
exec softlimit -o20 -d1000000 tcpserver \ |
| 413 |
-vDRHl0 -b20 -c40 -B'220 Features: a p . |
| 414 |
' 127.0.0.1 50000 \ |
| 415 |
sh -c "cd '$N'/server/file ; exec $PUBLICFILE_FTPD" |
| 416 |
EOF |
| 417 |
chmod +x $N/server/ftpd/run |
| 418 |
supervise $N/server/ftpd 2>$N/server.log & |
| 419 |
sleep 2 |
| 420 |
F="$N/server/file/0" |
| 421 |
|
| 422 |
if test "x$shortcut" = "x0" ; then |
| 423 |
|
| 424 |
# against stupid patches. |
| 425 |
echo '--- publicfile listing format check' |
| 426 |
touch $F/file |
| 427 |
out=`$O/ftpls --raw ftp://127.0.0.1:50000/` || out="-bad" |
| 428 |
case "$out" in |
| 429 |
-*) |
| 430 |
echo "badly patched publicfile detected. Further tests not run" |
| 431 |
svc -dtx $N/server/ftpd |
| 432 |
sleep 1 # give supervise time to exit. otherwise race with supervise/status file |
| 433 |
#cat $N/server.log |grep -v ^tcpserver |
| 434 |
rm onetouch |
| 435 |
cd $O || exit 1 |
| 436 |
rm -rf tmp.check |
| 437 |
exit 0 |
| 438 |
;; |
| 439 |
esac |
| 440 |
rm $F/file |
| 441 |
echo '--- empty start directory test' |
| 442 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 443 |
echo '--- nonexistant start entity' |
| 444 |
$O/ftpcopy ftp://127.0.0.1:50000/nonexistant client ; echo $? |
| 445 |
#mkdir "$F/t1" |
| 446 |
#mkdir "$F/t1" ; touch "$F/t1/file"; chmod 000 "$F/t1/file" |
| 447 |
echo '--- start entity is a file' |
| 448 |
touch $F/file |
| 449 |
$O/ftpcopy ftp://127.0.0.1:50000/file ./file ; echo $? |
| 450 |
$O/ftpcopy ftp://127.0.0.1:50000/file ./file ; echo $? |
| 451 |
$O/ftpcopy ftp://127.0.0.1:50000/file file ; echo $? |
| 452 |
rm file |
| 453 |
$O/ftpcopy ftp://127.0.0.1:50000/file file ; echo $? |
| 454 |
$O/ftpcopy ftp://127.0.0.1:50000/file ./file ; echo $? |
| 455 |
$O/ftpcopy ftp://127.0.0.1:50000/file file ; echo $? |
| 456 |
rm file |
| 457 |
$O/ftpcopy ftp://127.0.0.1:50000/file client ; echo $? |
| 458 |
$O/ftpcopy ftp://127.0.0.1:50000/file client ; echo $? |
| 459 |
rm client/file |
| 460 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ ; echo $? |
| 461 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ ; echo $? |
| 462 |
rm client/file |
| 463 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/file ; echo $? |
| 464 |
rm client/file |
| 465 |
echo '--- start entity is a file, ftpcopy creates parent directory' |
| 466 |
$O/ftpcopy ftp://127.0.0.1:50000/file createit/file ; echo $? |
| 467 |
rm createit/file ; rmdir createit |
| 468 |
$O/ftpcopy ftp://127.0.0.1:50000/file createit/ ; echo $? |
| 469 |
rm createit/file ; rmdir createit |
| 470 |
echo '--- start entity is a file, ftpcopy handles different local name' |
| 471 |
$O/ftpcopy ftp://127.0.0.1:50000/file createit ; echo $? |
| 472 |
rm createit |
| 473 |
|
| 474 |
echo '--- start entity is a directory with one file' |
| 475 |
rm -rf client/* |
| 476 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 477 |
rm -rf client/* |
| 478 |
$O/ftpcopy ftp://127.0.0.1:50000/ client/subdir ; echo $? |
| 479 |
echo '--- start entity is a directory with two files' |
| 480 |
rm $F/file |
| 481 |
touch $F/one $F/two |
| 482 |
rm -rf client/* |
| 483 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 484 |
rm -rf client/* |
| 485 |
$O/ftpcopy ftp://127.0.0.1:50000/ client/subdir ; echo $? |
| 486 |
echo '--- start entity contains one directory with two files' |
| 487 |
rm -rf client/* |
| 488 |
rm -rf $F/* |
| 489 |
mkdir $F/dir |
| 490 |
touch $F/dir/one $F/dir/two |
| 491 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 492 |
rm -rf client/* |
| 493 |
$O/ftpcopy ftp://127.0.0.1:50000/ client/subdir ; echo $? |
| 494 |
echo '--- ftpcopy deletes superfluous files' |
| 495 |
rm -rf client/* |
| 496 |
rm -rf $F/* |
| 497 |
mkdir $F/dir |
| 498 |
touch $F/dir/one $F/dir/two |
| 499 |
cp -pr $F/dir client/dir |
| 500 |
touch client/dir/three |
| 501 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 502 |
echo '--- ftpcopy deletes superfluous directories' |
| 503 |
rm -rf client/* |
| 504 |
rm -rf $F/* |
| 505 |
mkdir $F/dir |
| 506 |
touch $F/dir/one $F/dir/two |
| 507 |
cp -pr $F/dir client/dir |
| 508 |
mkdir client/dir2 |
| 509 |
mkdir client/dir/dir4 |
| 510 |
$O/ftpcopy ftp://127.0.0.1:50000/ client | sort |
| 511 |
echo - |
| 512 |
find client -print | sort |
| 513 |
echo '--- ftpcopy survives if a file is turned into a directory' |
| 514 |
rm $F/dir/one |
| 515 |
mkdir $F/dir/one |
| 516 |
touch $F/dir/one/three # so something is downloaded |
| 517 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 518 |
find client -print | sort |
| 519 |
echo '--- ftpcopy survives if a directory is turned into a file' |
| 520 |
rm -rf $F/dir/one |
| 521 |
touch $F/dir/one |
| 522 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 523 |
find client -print | sort |
| 524 |
|
| 525 |
echo '--- ftpcopy survives local symlink loops' |
| 526 |
rm client/dir/one |
| 527 |
ln -s one client/dir/one |
| 528 |
echo "first symlink loop test" >$F/dir/one |
| 529 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 530 |
cat client/dir/one |
| 531 |
find client -print | sort |
| 532 |
|
| 533 |
rm client/dir/one |
| 534 |
ln -s one client/dir/one |
| 535 |
rm $F/dir/one |
| 536 |
mkdir $F/dir/one |
| 537 |
echo "second symlink loop test" >$F/dir/one/file |
| 538 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 539 |
cat client/dir/one/file |
| 540 |
find client -print | sort |
| 541 |
|
| 542 |
echo '--- ftpcopy recognizes changed symbolic links to directories' |
| 543 |
rm -rf client/* $F/* |
| 544 |
mkdir $F/dir1 |
| 545 |
touch $F/dir1/one |
| 546 |
(cd $F ; ln -s dir1 dir2 ) |
| 547 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 548 |
find client -print | sort |
| 549 |
rm $F/dir2 |
| 550 |
mkdir $F/dir2 |
| 551 |
touch $F/dir2/two |
| 552 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 553 |
find client -print | sort |
| 554 |
echo '--- ftpcopy handles dir -> symbolic link change' |
| 555 |
rm -rf $F/dir2 |
| 556 |
(cd $F ; ln -s dir1 dir2 ) |
| 557 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 558 |
find client -print | sort |
| 559 |
|
| 560 |
echo '--- ftpcopy deals with rename situation 1' |
| 561 |
rm -rf client/* $F/* |
| 562 |
mkdir $F/dir1 |
| 563 |
touch $F/dir1/one |
| 564 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 565 |
find client -print | sort |
| 566 |
(cd $F ; ln -s dir1 dir2 ) |
| 567 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 568 |
find client -print | sort |
| 569 |
(cd $F ; rm dir2 ; mv dir1 dir2 ; ln -s dir2 dir1 ) |
| 570 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 571 |
find client -print | sort |
| 572 |
(cd $F ; rm dir1 ) |
| 573 |
$O/ftpcopy ftp://127.0.0.1:50000/ client |sort ; echo - |
| 574 |
find client -print | sort |
| 575 |
|
| 576 |
echo '--- ftpcopy deals with symlink to upper level directories' |
| 577 |
rm -rf client/* $F/* |
| 578 |
mkdir $F/dir1 |
| 579 |
mkdir $F/dir1/dir2 |
| 580 |
touch $F/dir1/dir2/one |
| 581 |
(cd $F/dir1/dir2 ; ln -s ../../dir1 dir1 ) |
| 582 |
(cd $F/dir1/dir2 ; ln -s ../../dir1 dir2 ) |
| 583 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 584 |
touch client/dir1/dir2/dir1/1 |
| 585 |
touch client/dir1/dir2/dir2/2 |
| 586 |
find client -print | sort |
| 587 |
echo '--- ftpcopy deals with symlink to current directories' |
| 588 |
rm -rf client/* $F/* |
| 589 |
mkdir $F/dir1 |
| 590 |
mkdir $F/dir1/dir2 |
| 591 |
touch $F/dir1/dir2/one |
| 592 |
(cd $F/dir1 ; ln -s . dir1 ) |
| 593 |
(cd $F/dir1/dir2 ; ln -s . dir2 ) |
| 594 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 595 |
touch client/dir1/dir1/1 |
| 596 |
touch client/dir1/dir2/dir2/2 |
| 597 |
find client -print | sort |
| 598 |
echo '--- ftpcopy deals with symlink to top level directory' |
| 599 |
rm -rf client/* $F/* |
| 600 |
touch $F/one |
| 601 |
mkdir $F/dir1 |
| 602 |
mkdir $F/dir1/dir2 |
| 603 |
touch $F/dir1/dir2/two |
| 604 |
# can't do this since the server isn't chrooted: |
| 605 |
# (cd $F/dir1/dir2 ; ln -s / dir3 ) |
| 606 |
(cd $F/dir1 ; ln -s $F dir1 ) |
| 607 |
(cd $F/dir1 ; ln -s $F/one . ) |
| 608 |
(cd $F/dir1/dir2 ; ln -s $F dir2 ) |
| 609 |
(cd $F/dir1/dir2 ; ln -s $F/one . ) |
| 610 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 611 |
touch client/dir1/dir1/1 |
| 612 |
touch client/dir1/dir2/dir2/2 |
| 613 |
find client -print | sort |
| 614 |
echo "really a (sym)link" >client/one |
| 615 |
cat client/dir1/one |
| 616 |
|
| 617 |
echo '--- ftpcopy deals with symlink to lower level directory' |
| 618 |
rm -rf client/* $F/* |
| 619 |
(cd $F ; ln -s dir2/dir1 dir1) |
| 620 |
(cd $F ; ln -s dir2/file1 file1) |
| 621 |
mkdir $F/dir2 |
| 622 |
(cd $F ; ln -s dir2/dir3 dir3) |
| 623 |
(cd $F ; ln -s dir2/file3 file3) |
| 624 |
mkdir $F/dir2/dir1 |
| 625 |
touch $F/dir2/dir1/one |
| 626 |
touch $F/dir2/file1 |
| 627 |
touch $F/dir2/file3 |
| 628 |
mkdir $F/dir2/dir3 |
| 629 |
touch $F/dir2/dir3/three |
| 630 |
$O/ftpcopy ftp://127.0.0.1:50000/ client ; echo $? |
| 631 |
touch client/dir2/dir1/1 |
| 632 |
touch client/dir3/3 |
| 633 |
find client -print | sort |
| 634 |
echo "really a (sym)link 1" >client/dir2/dir1/new |
| 635 |
echo "really a (sym)link 2" >client/dir2/file1 |
| 636 |
echo "really a (sym)link 3" >client/dir2/file3 |
| 637 |
cat client/dir1/new |
| 638 |
cat client/file1 |
| 639 |
cat client/file3 |
| 640 |
|
| 641 |
echo '--- ftpcopy deals with /../ in local file names' |
| 642 |
# this checks a few lines of canonization code. |
| 643 |
# canonization is mainly used for the hashed file names, |
| 644 |
# the (untestable) hacking symbolic link mode, and |
| 645 |
# remote path names. |
| 646 |
rm -rf client/* $F/* |
| 647 |
echo 1 >$F/one |
| 648 |
mkdir $F/dir1 |
| 649 |
( cd $F/dir1 ; ln -s ../one two) |
| 650 |
|
| 651 |
$O/ftpcopy -l2 ftp://127.0.0.1:50000/ client/../client/ ; echo $? |
| 652 |
find client -print | sort |
| 653 |
echo "changed" >client/one |
| 654 |
cat client/dir1/two |
| 655 |
|
| 656 |
|
| 657 |
echo '--- ftpcopy --max-days works' |
| 658 |
# to make things more interesting publicfiles ftpd doesn't output |
| 659 |
# modification time for files modified in the last 60 seconds. |
| 660 |
# ftpparse() returns them as modified 1970, and ftpcopy thinks |
| 661 |
# they are "too old". Ugly, but this is how things work. |
| 662 |
# "1" and "3" are dated 2000-01-01 -> not downloaded |
| 663 |
# "2" and "5" are one day old. -> downloaded |
| 664 |
# "3" and "6" are very young (<60 seconds) -> not downloaded |
| 665 |
cat >oneday.c <<EOF |
| 666 |
#include <time.h> |
| 667 |
int main(void) |
| 668 |
{ |
| 669 |
time_t x=time(0) - 86400; |
| 670 |
printf("%lu\n",x); |
| 671 |
exit(0); |
| 672 |
} |
| 673 |
EOF |
| 674 |
$O/auto-compile.sh -o oneday oneday.c |
| 675 |
oneday="`./oneday`" |
| 676 |
rm oneday.c oneday |
| 677 |
|
| 678 |
cat >onetouch.c <<EOF |
| 679 |
#include <sys/time.h> |
| 680 |
#include <fcntl.h> |
| 681 |
int main(int argc, char **argv) |
| 682 |
{ unsigned long x=strtol(argv[1],0,10); |
| 683 |
int fd; |
| 684 |
struct timeval tv[2]; |
| 685 |
fd=open(argv[2],O_WRONLY|O_CREAT,0644); |
| 686 |
tv[0].tv_sec=x; |
| 687 |
tv[1].tv_sec=x; |
| 688 |
tv[0].tv_usec=0; |
| 689 |
tv[1].tv_usec=0; |
| 690 |
return utimes(argv[2],tv); |
| 691 |
} |
| 692 |
EOF |
| 693 |
$O/auto-compile.sh -o onetouch onetouch.c |
| 694 |
rm onetouch.c |
| 695 |
|
| 696 |
rm -rf client/* $F/* |
| 697 |
#touch -r $O/Makefile.pre $F/1 |
| 698 |
mkdir $F/dir |
| 699 |
./onetouch 946753200 $F/1 |
| 700 |
./onetouch 946753200 $F/dir/4 |
| 701 |
./onetouch $oneday $F/2 |
| 702 |
./onetouch $oneday $F/dir/5 |
| 703 |
touch $F/3 |
| 704 |
touch $F/dir/6 |
| 705 |
$O/ftpcopy --max-days 10 -l2 ftp://127.0.0.1:50000/ client ; echo $? |
| 706 |
#gdb $O/ftpcopy #--max-days 10 -l2 ftp://127.0.0.1:50000/ client ; echo $? |
| 707 |
find client -print | sort |
| 708 |
|
| 709 |
|
| 710 |
echo '--- ftpcopy handles excludes and includes' |
| 711 |
rm -rf client/* $F/* |
| 712 |
touch $F/0 |
| 713 |
mkdir $F/d1 |
| 714 |
touch $F/d1/1 |
| 715 |
mkdir $F/d1/d2 |
| 716 |
touch $F/d1/d2/2 |
| 717 |
mkdir $F/d1/d2/d3 |
| 718 |
touch $F/d1/d2/d3/3 |
| 719 |
|
| 720 |
echo '- e&i: download /0' |
| 721 |
rm -rf client |
| 722 |
$O/ftpcopy --exclude '*' --include /0 \ |
| 723 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 724 |
|
| 725 |
echo '- e&i: no download due to not included upper level directory' |
| 726 |
rm -rf client |
| 727 |
$O/ftpcopy --exclude '*' --include /d1/1 \ |
| 728 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 729 |
|
| 730 |
echo '- e&i: download /d1/1 (include /d1 and /d1/1)' |
| 731 |
rm -rf client |
| 732 |
$O/ftpcopy --exclude '*' --include '/d1' --include /d1/1 \ |
| 733 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 734 |
echo '- e&i: download /d1/1 (include /d1 and /d1/?)' |
| 735 |
rm -rf client |
| 736 |
$O/ftpcopy --exclude '*' --include '/d1' --include '/d1/?' \ |
| 737 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 738 |
echo '- e&i: download all (include /d1*)' |
| 739 |
rm -rf client |
| 740 |
$O/ftpcopy --exclude '*' --include '/d1*' \ |
| 741 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 742 |
echo '- e&i: just get the directories (include *d?)' |
| 743 |
rm -rf client |
| 744 |
$O/ftpcopy --exclude '*' --include '*d?' \ |
| 745 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 746 |
find client -print | sort |
| 747 |
echo '- e&i: just get the directories (include /d1, /d1/d2, /d1/d2/d3)' |
| 748 |
rm -rf client |
| 749 |
$O/ftpcopy --exclude '*' --include '/d1' --include '/d1/d2' \ |
| 750 |
--include '/d1/d2/d3' \ |
| 751 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 752 |
find client -print | sort |
| 753 |
echo '- e&i: get all but */2*' |
| 754 |
rm -rf client |
| 755 |
$O/ftpcopy --exclude '*/2*' \ |
| 756 |
ftp://127.0.0.1:50000/ client ; echo $? |
| 757 |
find client -print | sort |
| 758 |
|
| 759 |
echo '- e&i: --in-exclude-file check (bad syntax)' |
| 760 |
rm -rf client |
| 761 |
( |
| 762 |
echo '-*' ; |
| 763 |
echo '?/0' ; |
| 764 |
echo '+/0' ; |
| 765 |
) >inex-file |
| 766 |
$O/ftpcopy --in-exclude-file ./inex-file ftp://127.0.0.1:50000/ client ; echo $? |
| 767 |
echo '- e&i: --in-exclude-file check' |
| 768 |
rm -rf client |
| 769 |
( |
| 770 |
echo '-*' ; |
| 771 |
echo '+/0' ; |
| 772 |
) >inex-file |
| 773 |
$O/ftpcopy --in-exclude-file ./inex-file ftp://127.0.0.1:50000/ client ; echo $? |
| 774 |
|
| 775 |
echo '--- ftpcopy handles subdirectory mirroring' |
| 776 |
rm -rf client/* $F/* |
| 777 |
mkdir $F/dir1 |
| 778 |
(cd $F/dir1 ; ln -s ../dir2 .) |
| 779 |
(cd $F/dir1 ; ln -s ../dir2/file21 .) |
| 780 |
mkdir $F/dir11 |
| 781 |
mkdir $F/dir2 |
| 782 |
mkdir $F/dir2/dir21 |
| 783 |
echo file211 >$F/dir2/dir21/file211 |
| 784 |
(cd $F/dir2 ; ln -s dir21/file211 file21 ) |
| 785 |
mkdir $F/dir3 |
| 786 |
(cd $F/dir3 ; ln -s . dir3) |
| 787 |
mkdir $F/dir3/dir31 |
| 788 |
echo file31 >$F/dir3/file31 |
| 789 |
echo file311 >$F/dir3/dir31/file31 |
| 790 |
|
| 791 |
echo '- subdir1:' |
| 792 |
$O/ftpcopy ftp://127.0.0.1:50000/dir1 client ; echo $? |
| 793 |
find client -print | sort |
| 794 |
echo "changed" >client/file21 |
| 795 |
cat client/dir2/file21 |
| 796 |
echo '- subdir2:' # including deletes |
| 797 |
$O/ftpcopy ftp://127.0.0.1:50000/dir2 client |sort ; echo - |
| 798 |
find client -print | sort |
| 799 |
echo '- subdir3:' # including deletes |
| 800 |
$O/ftpcopy ftp://127.0.0.1:50000/dir3 client |sort ; echo - |
| 801 |
touch client/dir3/newfile |
| 802 |
find client -print | sort |
| 803 |
|
| 804 |
echo '--- ftpcopy --directories-only works' |
| 805 |
# depends on previous file structure |
| 806 |
$O/ftpcopy --directories-only ftp://127.0.0.1:50000/ client | sort |
| 807 |
echo - |
| 808 |
find client -print | sort |
| 809 |
rm -rf client |
| 810 |
$O/ftpcopy -d 127.0.0.1:50000 / client ; echo $? |
| 811 |
find client -print | sort |
| 812 |
|
| 813 |
echo '--- ftpcopy handles absolute local directories' |
| 814 |
# this is more superfluous than not. But then again it doesn't cost that much. |
| 815 |
rm -rf client/* $F/* |
| 816 |
touch $F/0 |
| 817 |
mkdir $F/d1 |
| 818 |
touch $F/d1/1 |
| 819 |
mkdir $F/d1/d2 |
| 820 |
(cd $F/d1/d2 ; ln -s ../../0 .) |
| 821 |
(cd $F/d1/d2 ; ln -s ../1 .) |
| 822 |
(cd $F/d1/d2 ; ln -s ../.. d0) |
| 823 |
(cd $F/d1/d2 ; ln -s .. d1) |
| 824 |
(cd $F/d1/d2 ; ln -s . d2) |
| 825 |
touch $F/d1/d2/2 |
| 826 |
$O/ftpcopy 127.0.0.1:50000 / `env - pwd`/client ; echo $? |
| 827 |
touch client/d1/d2/d0/t0 |
| 828 |
touch client/d1/d2/d1/t1 |
| 829 |
touch client/d1/d2/d2/t2 |
| 830 |
echo "changed0" >client/0 |
| 831 |
echo "changed1" >client/d1/1 |
| 832 |
find client -print | sort |
| 833 |
cat client/d1/d2/0 |
| 834 |
cat client/d1/d2/1 |
| 835 |
|
| 836 |
echo '--- ftpcopy recognizes --user and --pass' |
| 837 |
# we can't really test whether these options work. common.c is too |
| 838 |
# smart for that. |
| 839 |
rm -rf client/* $F/* |
| 840 |
$O/ftpcopy -l3 --user uwe --pass 42 127.0.0.1:50000 / `pwd`/client ; echo $? |
| 841 |
$O/ftpcopy -l3 -u uwe -p 42 127.0.0.1:50000 / `pwd`/client ; echo $? |
| 842 |
echo '--- ftpcopy recognizes username in urls' |
| 843 |
$O/ftpcopy -l3 ftp://[email protected]:50000/ client ; echo $? |
| 844 |
|
| 845 |
echo '--- ftpcopy --dry-run works' |
| 846 |
rm -rf client/* $F/* |
| 847 |
touch $F/file0 |
| 848 |
mkdir $F/dir1 |
| 849 |
touch $F/dir1/file1 |
| 850 |
mkdir $F/dir1/dir2 |
| 851 |
touch $F/dir1/dir2/file2 |
| 852 |
(cd $F/dir1/dir2 ; ln -s '../../file0' 'linkf0') |
| 853 |
(cd $F/dir1/dir2 ; ln -s '../file1' 'linkf1') |
| 854 |
(cd $F/dir1/dir2 ; ln -s 'file2' 'linkf2') |
| 855 |
(cd $F ; ln -s 'dir1/dir2/file2' 'linkf2') |
| 856 |
(cd $F ; ln -s 'dir1/file1' 'linkf1') |
| 857 |
mkdir $F/directory_to_keep |
| 858 |
echo 123 >$F/directory_to_keep/file_to_keep |
| 859 |
echo 124 >$F/directory_to_keep/file_to_get |
| 860 |
touch client/do_delete |
| 861 |
mkdir client/directory_to_keep |
| 862 |
touch client/directory_to_keep/file_to_keep # note: will be downloaded |
| 863 |
touch client/directory_to_keep/file2delete |
| 864 |
mkdir client/directory_to_delete |
| 865 |
touch client/directory_to_delete/file2delete |
| 866 |
|
| 867 |
$O/ftpcopy --dry-run 127.0.0.1:50000 / client |sort ; echo - |
| 868 |
find client -print | sort |
| 869 |
fi |
| 870 |
|
| 871 |
echo '--- ftpcopy --interactive works' |
| 872 |
rm -rf client/* $F/* |
| 873 |
mkdir $F/dir1 |
| 874 |
(cd $F/dir1 ; ln -s ../dir2 .) |
| 875 |
(cd $F/dir1 ; ln -s ../dir2/file21 .) |
| 876 |
mkdir $F/dir11 |
| 877 |
mkdir $F/dir2 |
| 878 |
mkdir $F/dir2/dir21 |
| 879 |
echo file211 >$F/dir2/dir21/file211 |
| 880 |
(cd $F/dir2 ; ln -s dir21/file211 file21 ) |
| 881 |
mkdir $F/dir3 |
| 882 |
(cd $F/dir3 ; ln -s . dir3) |
| 883 |
mkdir $F/dir3/dir31 |
| 884 |
echo file31 >$F/dir3/file31 |
| 885 |
echo file311 >$F/dir3/dir31/file31 |
| 886 |
|
| 887 |
# This also checks how ftpcopy deals with absolute remote paths. |
| 888 |
( |
| 889 |
cat <<EOF |
| 890 |
dir1 |
| 891 |
client/dir1 |
| 892 |
/dir1 |
| 893 |
client/dir1a |
| 894 |
dir2 |
| 895 |
client/dir2 |
| 896 |
dir3 |
| 897 |
client/dir3 |
| 898 |
/ dir3 |
| 899 |
EOF |
| 900 |
) | $O/ftpcopy --interactive 127.0.0.1:50000 ; echo $? |
| 901 |
find client -print | sort |
| 902 |
$O/ftpcopy 127.0.0.1:50000 / client |sort ; echo - |
| 903 |
find client -print | sort |
| 904 |
|
| 905 |
echo '--- ftpcopy --tolower works' |
| 906 |
rm -rf client/* $F/* |
| 907 |
touch $F/file0 |
| 908 |
mkdir $F/dir1 |
| 909 |
touch $F/dir1/FILE1 |
| 910 |
mkdir $F/dir1/DIR2 |
| 911 |
touch $F/dir1/DIR2/FILE2 |
| 912 |
(cd $F ; ln -s 'dir1/DIR2/FILE2' 'LINK') |
| 913 |
|
| 914 |
$O/ftpcopy -l2 --tolower 127.0.0.1:50000 / client ; echo $? |
| 915 |
find client -print | sort |
| 916 |
|
| 917 |
echo '--- ftpcopy --tolower does not needlessly reget files' |
| 918 |
$O/ftpcopy -l2 --tolower 127.0.0.1:50000 / client ; echo $? |
| 919 |
|
| 920 |
echo '--- ftpcopy --tolower deals with collisions' |
| 921 |
# in this case it loses and downloads the files more than once. Oh well. |
| 922 |
echo 123 >$F/dir1/FiLE1 |
| 923 |
(cd $F ; ln -s 'dir1/FiLE1' 'link') |
| 924 |
# "wc" tends to add different amounts of white space, depending on the |
| 925 |
# vendor. Oh. |
| 926 |
$O/ftpcopy --tolower 127.0.0.1:50000 / client | wc -l | tr -d ' ' # 1 download |
| 927 |
$O/ftpcopy --tolower 127.0.0.1:50000 / client | wc -l | tr -d ' ' # 2 downloads |
| 928 |
$O/ftpcopy --tolower 127.0.0.1:50000 / client | wc -l | tr -d ' ' # 2 downloads |
| 929 |
|
| 930 |
echo '--- ftpcopy --tolower works with exclude, too' |
| 931 |
rm -rf client/* $F/* |
| 932 |
touch $F/file0 |
| 933 |
mkdir $F/dir1 |
| 934 |
touch $F/dir1/FILE1 |
| 935 |
mkdir $F/dir1/DIR2 |
| 936 |
touch $F/dir1/DIR2/FILE2 |
| 937 |
(cd $F ; ln -s 'dir1/DIR2/FILE2' 'LINK') |
| 938 |
# the important thing is to write dir2 in lower case. |
| 939 |
$O/ftpcopy -l2 --tolower --exclude "*dir2*" 127.0.0.1:50000 / client ; echo $? |
| 940 |
find client -print | sort |
| 941 |
|
| 942 |
echo '--- ftpcopy --ignore-size works' |
| 943 |
rm -rf client/* $F/* |
| 944 |
echo 123 >$F/FILE1 |
| 945 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 946 |
echo 1234 >$F/FILE1 |
| 947 |
$O/ftpcopy --ignore-size 127.0.0.1:50000 / client |
| 948 |
echo '--- ftpcopy without --ignore-size works' |
| 949 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 950 |
|
| 951 |
echo '--- ftpcopy --ignore-time works' |
| 952 |
rm -rf client/* $F/* |
| 953 |
echo 123 >$F/FILE1 |
| 954 |
./onetouch 946000000 $F/FILE1 |
| 955 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 956 |
./onetouch 947000000 $F/FILE1 |
| 957 |
$O/ftpcopy --ignore-time 127.0.0.1:50000 / client |
| 958 |
echo '--- ftpcopy --ignore-size --ignore-time works' |
| 959 |
echo >$F/FILE1 |
| 960 |
./onetouch 945000000 $F/FILE1 |
| 961 |
$O/ftpcopy --ignore-time --ignore-size 127.0.0.1:50000 / client |
| 962 |
echo '--- ftpcopy without --ignore-time works' |
| 963 |
echo 123 >$F/FILE1 |
| 964 |
./onetouch 944000000 $F/FILE1 |
| 965 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 966 |
|
| 967 |
echo '--- ftpcopy has no file descriptor leak in remove_dir' |
| 968 |
rm -rf client/* $F/* |
| 969 |
for i in 0 1 2 3 ; do |
| 970 |
for j in 1 2 3 4 5 6 7 8 9 0 ; do |
| 971 |
mkdir client/d$i$j |
| 972 |
touch $F/d$i$j |
| 973 |
done |
| 974 |
done |
| 975 |
( |
| 976 |
ulimit -n 12 |
| 977 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 978 |
) |
| 979 |
|
| 980 |
echo '--- ftpcopy has no file descriptor leak in loop' |
| 981 |
rm -rf client/* $F/* |
| 982 |
for i in 0 1 2 3 ; do |
| 983 |
for j in 1 2 3 4 5 6 7 8 9 0 ; do |
| 984 |
mkdir $F/d$i$j |
| 985 |
touch $F/d$i$j/f$i$j |
| 986 |
done |
| 987 |
done |
| 988 |
( |
| 989 |
ulimit -n 12 |
| 990 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 991 |
) |
| 992 |
|
| 993 |
echo '--- ftpcopy has no file descriptor leak in delete' |
| 994 |
rm -rf client/* $F/* |
| 995 |
for i in 0 1 2 3 ; do |
| 996 |
for j in 1 2 3 4 5 6 7 8 9 0 ; do |
| 997 |
mkdir client/d$i$j |
| 998 |
touch client/d$i$j/f$i$j |
| 999 |
done |
| 1000 |
done |
| 1001 |
( |
| 1002 |
ulimit -n 12 |
| 1003 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 1004 |
) | sort |
| 1005 |
|
| 1006 |
echo '--- ftpcopy has no file descriptor leak in download' |
| 1007 |
rm -rf client/* $F/* |
| 1008 |
for i in 0 1 2 3 ; do |
| 1009 |
for j in 1 2 3 4 5 6 7 8 9 0 ; do |
| 1010 |
mkdir $F/d$i$j |
| 1011 |
touch $F/d$i$j/f$i$j |
| 1012 |
done |
| 1013 |
done |
| 1014 |
( |
| 1015 |
ulimit -n 12 |
| 1016 |
$O/ftpcopy 127.0.0.1:50000 / client |
| 1017 |
) |
| 1018 |
echo '--- ftpcopy --max-deletes works' |
| 1019 |
rm -rf client/* $F/* |
| 1020 |
touch $F/1 |
| 1021 |
(cd client; touch 1 2 3 4 5 6 7 8 9 a b c d e f ) |
| 1022 |
$O/ftpcopy -l 0 --max-deletes 10 127.0.0.1:50000 / client |
| 1023 |
# note: finds directory "client", too, so the numbers are one off ... |
| 1024 |
find client -print | wc -l | tr -d ' ' |
| 1025 |
$O/ftpcopy -l 0 -M 1 127.0.0.1:50000 / client |
| 1026 |
find client -print | wc -l | tr -d ' ' |
| 1027 |
|
| 1028 |
echo '--- ftpcopy --max-size works' |
| 1029 |
rm -rf client/* $F/* |
| 1030 |
cp $O/ftpcopy.c $F/1 |
| 1031 |
head -n 100 $O/ftpcopy.c >$F/2 |
| 1032 |
head -n 10 $O/ftpcopy.c >$F/3 |
| 1033 |
$O/ftpcopy -l 0 --max-size 1000 127.0.0.1:50000 / client |
| 1034 |
# note: finds directory "client", too, so the numbers are one off ... |
| 1035 |
find client -print | sort |
| 1036 |
$O/ftpcopy -l 0 127.0.0.1:50000 / client |
| 1037 |
find client -print | sort |
| 1038 |
|
| 1039 |
echo '--- ftpcopy --ascii-listings works' |
| 1040 |
# this doesn't catch everything, but might catch if something is horribly |
| 1041 |
# broken. |
| 1042 |
rm -rf client/* $F/* |
| 1043 |
cp $O/ftpcopy.c $F/1 |
| 1044 |
cp $O/ftpcopy $F/2 |
| 1045 |
printf "hello\r\nworld\nHello\r\nWorld\n" >$F/3 |
| 1046 |
mkdir $F/D |
| 1047 |
cp $O/ftpcopy.c $F/D/1 |
| 1048 |
cp $O/ftpcopy $F/D/2 |
| 1049 |
printf "hello\r\nworld\nHello\r\nWorld\n" >$F/D/3 |
| 1050 |
mkdir $F/D/D |
| 1051 |
cp $O/ftpcopy.c $F/D/D/1 |
| 1052 |
cp $O/ftpcopy $F/D/D/2 |
| 1053 |
printf "hello\r\nworld\nHello\r\nWorld\n" >$F/D/D/3 |
| 1054 |
echo '- part one: binary mode listing' |
| 1055 |
$O/ftpcopy -l 0 127.0.0.1:50000 / client |
| 1056 |
find client -print | sort |
| 1057 |
cmp $F/1 client/1 && echo "client/1 ok" |
| 1058 |
cmp $F/2 client/2 && echo "client/2 ok" |
| 1059 |
cmp $F/3 client/3 && echo "client/3 ok" |
| 1060 |
cmp $F/D/1 client/D/1 && echo "client/D/1 ok" |
| 1061 |
cmp $F/D/2 client/D/2 && echo "client/D/2 ok" |
| 1062 |
cmp $F/D/3 client/D/3 && echo "client/D/3 ok" |
| 1063 |
cmp $F/D/D/1 client/D/D/1 && echo "client/D/D/1 ok" |
| 1064 |
cmp $F/D/D/2 client/D/D/2 && echo "client/D/D/2 ok" |
| 1065 |
cmp $F/D/D/3 client/D/D/3 && echo "client/D/D/3 ok" |
| 1066 |
rm -rf client/* |
| 1067 |
echo '- part two: ascii mode listing' |
| 1068 |
$O/ftpcopy --ascii-listings -l 0 127.0.0.1:50000 / client |
| 1069 |
find client -print | sort |
| 1070 |
cmp $F/1 client/1 && echo "client/1 ok" |
| 1071 |
cmp $F/2 client/2 && echo "client/2 ok" |
| 1072 |
cmp $F/3 client/3 && echo "client/3 ok" |
| 1073 |
cmp $F/D/1 client/D/1 && echo "client/D/1 ok" |
| 1074 |
cmp $F/D/2 client/D/2 && echo "client/D/2 ok" |
| 1075 |
cmp $F/D/3 client/D/3 && echo "client/D/3 ok" |
| 1076 |
cmp $F/D/D/1 client/D/D/1 && echo "client/D/D/1 ok" |
| 1077 |
cmp $F/D/D/2 client/D/D/2 && echo "client/D/D/2 ok" |
| 1078 |
cmp $F/D/D/3 client/D/D/3 && echo "client/D/D/3 ok" |
| 1079 |
|
| 1080 |
echo '--- ftpcopy --max-depth works' |
| 1081 |
rm -rf client/* $F/* |
| 1082 |
mkdir $F/D1 |
| 1083 |
cp $O/ftpcopy.c $F/1 |
| 1084 |
mkdir $F/D1/D2 |
| 1085 |
cp $O/ftpcopy.c $F/D1/2 |
| 1086 |
mkdir $F/D1/D2/D3 |
| 1087 |
cp $O/ftpcopy.c $F/D1/D2/3 |
| 1088 |
cp $O/ftpcopy.c $F/D1/D2/D3/4 |
| 1089 |
echo '- part zero: --max-depth 0' |
| 1090 |
rm -rf client/ |
| 1091 |
$O/ftpcopy --max-depth 0 -l 0 127.0.0.1:50000 / client |
| 1092 |
find client -print | sort |
| 1093 |
echo '- part one: --max-depth 1' |
| 1094 |
rm -rf client/ |
| 1095 |
$O/ftpcopy --max-depth 1 -l 0 127.0.0.1:50000 / client |
| 1096 |
find client -print | sort |
| 1097 |
echo '- part two: --max-depth 2' |
| 1098 |
rm -rf client/ |
| 1099 |
$O/ftpcopy --max-depth 2 -l 0 127.0.0.1:50000 / client |
| 1100 |
find client -print | sort |
| 1101 |
echo '- part three: --max-depth 3' |
| 1102 |
rm -rf client/ |
| 1103 |
$O/ftpcopy --max-depth 3 -l 0 127.0.0.1:50000 / client |
| 1104 |
find client -print | sort |
| 1105 |
|
| 1106 |
echo '--- ftpcopy --rate-limit works' |
| 1107 |
rm -rf client/* $F/* |
| 1108 |
cat >a5.c <<EOF |
| 1109 |
int main(int argc, char **argv) |
| 1110 |
{ |
| 1111 |
/* made even more complicated so that the shell never sees the |
| 1112 |
* alarm signal. |
| 1113 |
*/ |
| 1114 |
int x=fork(); |
| 1115 |
int y; |
| 1116 |
if (x==0) { |
| 1117 |
alarm(5); execv(argv[1],argv+1); _exit(1); |
| 1118 |
} |
| 1119 |
x=wait(&y); |
| 1120 |
return 0; |
| 1121 |
} |
| 1122 |
EOF |
| 1123 |
$O/auto-compile.sh -o a5 a5.c |
| 1124 |
cat $O/ftpcopy $O/ftpls $O/*.c >>$F/file |
| 1125 |
( |
| 1126 |
exec 2>/dev/null |
| 1127 |
exec 1>/dev/null |
| 1128 |
./a5 $O/ftpcopy --rate-limit 5000 -l 0 ftp://127.0.0.1:50000/file client/ |
| 1129 |
) >/dev/null 2>/dev/null # need to get rid of "alarm clock" messages of sh. |
| 1130 |
cmp client/file $F/file >/dev/null 2>/dev/null \ |
| 1131 |
&& echo "files identical - rate limiting does not work" |
| 1132 |
|
| 1133 |
echo '--- ftpcopy resumes downloads' |
| 1134 |
rm -rf client/* $F/* |
| 1135 |
touch $F/file |
| 1136 |
cat $O/ftpcopy $O/ftpls $O/*.c >>$F/ofile |
| 1137 |
dd if=$F/ofile of=$F/file bs=1024 count=100 >/dev/null 2>/dev/null |
| 1138 |
./onetouch 946753000 $F/file |
| 1139 |
TFILE=.tmp.file.946753000.102400 |
| 1140 |
|
| 1141 |
dd if=$F/file of=$F/$TFILE bs=1024 count=24 >/dev/null 2>/dev/null |
| 1142 |
cp $F/$TFILE client/ |
| 1143 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ |
| 1144 |
|
| 1145 |
echo '--- ftpcopy resume does not detect local corruption' |
| 1146 |
# this actuelly tests wether there is a resume at all ... |
| 1147 |
rm -f client/* |
| 1148 |
./onetouch 946753000 $F/file |
| 1149 |
cp $F/$TFILE client/ |
| 1150 |
echo 1 >>client/$TFILE |
| 1151 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ |
| 1152 |
cmp client/file $F/file >/dev/null 2>/dev/null \ |
| 1153 |
|| echo "file corrupted - resume done" |
| 1154 |
echo '--- ftpcopy does not resume in case time changed' |
| 1155 |
rm -f client/* |
| 1156 |
./onetouch 946753200 $F/file |
| 1157 |
cp $F/$TFILE client/ |
| 1158 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ |
| 1159 |
cmp client/file $F/file |
| 1160 |
echo '--- ftpcopy does not resume in case size changed' |
| 1161 |
cp $F/$TFILE client/ |
| 1162 |
echo 1 >>$F/file |
| 1163 |
./onetouch 946753200 $F/file |
| 1164 |
$O/ftpcopy ftp://127.0.0.1:50000/file client/ |
| 1165 |
cmp client/file $F/file |
| 1166 |
|
| 1167 |
echo '--- ftpcopy --no-resume works as expected' |
| 1168 |
rm -f client/file |
| 1169 |
echo 123 >client/file |
| 1170 |
dd conv=notrunc if=$F/file of=client/file bs=1024 count=30 \ |
| 1171 |
>/dev/null 2>/dev/null |
| 1172 |
$O/ftpcopy --no-resume ftp://127.0.0.1:50000/file client/ |
| 1173 |
cmp client/file $F/file |
| 1174 |
|
| 1175 |
svc -dtx $N/server/ftpd |
| 1176 |
sleep 1 # give supervise time to exit. otherwise race with supervise/status file |
| 1177 |
#cat $N/server.log |grep -v ^tcpserver |
| 1178 |
rm onetouch |
| 1179 |
|
| 1180 |
cd $O || exit 1 |
| 1181 |
rm -rf tmp.check |
| 1182 |
|
| 1183 |
exit 0 |