|
@@ -73,6 +73,7 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
import org.apache.hadoop.hdfs.protocol.LocatedBlocks;
|
|
import org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolTranslatorPB;
|
|
import org.apache.hadoop.hdfs.protocolPB.ClientDatanodeProtocolTranslatorPB;
|
|
|
|
+import org.apache.hadoop.hdfs.server.namenode.FSDirectory;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
import org.apache.hadoop.io.retry.RetryPolicies;
|
|
import org.apache.hadoop.io.retry.RetryPolicies;
|
|
import org.apache.hadoop.io.retry.RetryPolicy;
|
|
import org.apache.hadoop.io.retry.RetryPolicy;
|
|
@@ -210,13 +211,20 @@ public class DFSUtil {
|
|
String[] components = StringUtils.split(src, '/');
|
|
String[] components = StringUtils.split(src, '/');
|
|
for (int i = 0; i < components.length; i++) {
|
|
for (int i = 0; i < components.length; i++) {
|
|
String element = components[i];
|
|
String element = components[i];
|
|
- if (element.equals("..") ||
|
|
|
|
- element.equals(".") ||
|
|
|
|
|
|
+ if (element.equals(".") ||
|
|
(element.indexOf(":") >= 0) ||
|
|
(element.indexOf(":") >= 0) ||
|
|
(element.indexOf("/") >= 0)) {
|
|
(element.indexOf("/") >= 0)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ // ".." is allowed in path starting with /.reserved/.inodes
|
|
|
|
+ if (element.equals("..")) {
|
|
|
|
+ if (components.length > 4
|
|
|
|
+ && components[1].equals(FSDirectory.DOT_RESERVED_STRING)
|
|
|
|
+ && components[2].equals(FSDirectory.DOT_INODES_STRING)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
// The string may start or end with a /, but not have
|
|
// The string may start or end with a /, but not have
|
|
// "//" in the middle.
|
|
// "//" in the middle.
|
|
if (element.isEmpty() && i != components.length - 1 &&
|
|
if (element.isEmpty() && i != components.length - 1 &&
|