HDFS-9123. Copying from the root to a subdirectory should be forbidden. (Wei-Chiu Chuang via Yongjun Zhang)
(cherry picked from commit 3187dbd7a8
)
This commit is contained in:
parent
85c73d159e
commit
16ae3f5d46
|
@ -238,7 +238,13 @@ abstract class CommandWithDestination extends FsCommand {
|
||||||
e.setTargetPath(dstPath.toString());
|
e.setTargetPath(dstPath.toString());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
if (dstPath.startsWith(srcPath+Path.SEPARATOR)) {
|
// When a path is normalized, all trailing slashes are removed
|
||||||
|
// except for the root
|
||||||
|
if(!srcPath.endsWith(Path.SEPARATOR)) {
|
||||||
|
srcPath += Path.SEPARATOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dstPath.startsWith(srcPath)) {
|
||||||
PathIOException e = new PathIOException(src.toString(),
|
PathIOException e = new PathIOException(src.toString(),
|
||||||
"is a subdirectory of itself");
|
"is a subdirectory of itself");
|
||||||
e.setTargetPath(target.toString());
|
e.setTargetPath(target.toString());
|
||||||
|
|
|
@ -1062,6 +1062,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HDFS-9076. Log full path instead of inodeId in DFSClient
|
HDFS-9076. Log full path instead of inodeId in DFSClient
|
||||||
#closeAllFilesBeingWritten() (Surendra Singh Lilhore via vinayakumarb)
|
#closeAllFilesBeingWritten() (Surendra Singh Lilhore via vinayakumarb)
|
||||||
|
|
||||||
|
HDFS-9123. Copying from the root to a subdirectory should be forbidden.
|
||||||
|
(Wei-Chiu Chuang via Yongjun Zhang)
|
||||||
|
|
||||||
Release 2.7.2 - UNRELEASED
|
Release 2.7.2 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -1331,6 +1331,19 @@ public class TestDFSShell {
|
||||||
e.getLocalizedMessage());
|
e.getLocalizedMessage());
|
||||||
}
|
}
|
||||||
assertEquals(0, val);
|
assertEquals(0, val);
|
||||||
|
|
||||||
|
// this should fail
|
||||||
|
args1[0] = "-cp";
|
||||||
|
args1[1] = "/";
|
||||||
|
args1[2] = "/test";
|
||||||
|
val = 0;
|
||||||
|
try {
|
||||||
|
val = shell.run(args1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Exception raised from DFSShell.run " +
|
||||||
|
e.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
assertEquals(1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify -test -f negative case (missing file)
|
// Verify -test -f negative case (missing file)
|
||||||
|
|
Loading…
Reference in New Issue