From: Cyril H. <su...@li...> - 2012-08-08 10:56:44
|
The branch, master, has been updated via add3d337169ddbcc44c38be447b3094bacd6c513 (commit) from 47d716b2ee70d1101e77b2736705c40f71c31664 (commit) - Log ----------------------------------------------------------------- commit add3d337169ddbcc44c38be447b3094bacd6c513 Author: Simon Xu <xu....@or...> Date: Fri Aug 3 00:34:55 2012 +0800 fix container_ftp.pl container_ftp.pl has several problems: * ftp users can't cd to a temporary dir in /tmp * ftp->cwd($dir) will always fail * if we do 'chdir $dir', 'rmdir("$dir")' will fail * 'ftp->put' should be 'ftp->get' Wanlong Gao: Removed the tailing space added by the patch. Signed-off-by: Simon Xu <xu....@or...> Reviewed-by: DAN LI <li...@cn...> Signed-off-by: Wanlong Gao <gao...@cn...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/containers/netns/container_ftp.pl | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/containers/netns/container_ftp.pl b/testcases/kernel/containers/netns/container_ftp.pl index 89a35b5..15cf55e 100644 --- a/testcases/kernel/containers/netns/container_ftp.pl +++ b/testcases/kernel/containers/netns/container_ftp.pl @@ -23,6 +23,7 @@ use File::Temp 'tempdir'; use Net::FTP; +use File::Path; if ($#ARGV == -1) { print "usage: $0 host\n"; @@ -35,7 +36,7 @@ my $i = 0; my $kount = 51; my $file="junkfile"; -my $tmpdir = defined($ENV{TMPDIR}) ? $ENV{TMPDIR} : "/tmp"; +my $tmpdir = "/var/ftp"; my $dir; $dir = tempdir("container_ftp.XXXXXXX", DIR => $tmpdir); @@ -47,8 +48,7 @@ if (chmod(0777, $dir) == 0) { push @ERRORS, "Failed to change mode for temporary directory: $!\n"; printerr(); } -chdir $dir; -system("dd if=/dev/zero of=$file bs=512 count=10 > /dev/null 2>&1 "); +system("dd if=/dev/zero of=$dir/$file bs=512 count=10 > /dev/null 2>&1 "); while ( $i < $kount ) { @@ -61,13 +61,15 @@ while ( $i < $kount ) $ftp->quit if $newerr; printerr() if $newerr; - $ftp->cwd($dir) or $newerr=1; + $basedir = `basename "$dir"`; + chomp $basedir; + $ftp->cwd($basedir) or $newerr=1; push @ERRORS, "Can't cd $!\n" if $newerr; $ftp->quit if $newerr; printerr() if $newerr; $newname = $file . "_" . $i ; - $ftp->put($file,$newname) or $newerr=1; + $ftp->get($file,$newname) or $newerr=1; push @ERRORS, "Can't get file $file $!\n" if $newerr; printerr() if $newerr; @@ -82,6 +84,5 @@ sub printerr { } END { - unlink("$dir/$file"); - rmdir("$dir"); + rmtree("$dir"); } hooks/post-receive -- ltp |