Skip to content

Commit 9d3082e

Browse files
committed
Revert "HDFS-14884. Add sanity check that zone key equals feinfo key while setting Xattrs. Contributed by Mukul Kumar Singh." (#7529)
This reverts commit a901405. Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java (cherry picked from commit 5ccb0dc)
1 parent cc0580c commit 9d3082e

File tree

2 files changed

+1
-90
lines changed

2 files changed

+1
-90
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirXAttrOp.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.apache.hadoop.hdfs.server.namenode;
1919

2020
import org.apache.hadoop.HadoopIllegalArgumentException;
21-
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension;
2221
import org.apache.hadoop.fs.FileStatus;
2322
import org.apache.hadoop.fs.XAttr;
2423
import org.apache.hadoop.fs.XAttrSetFlag;
@@ -43,11 +42,10 @@
4342
import java.util.List;
4443
import java.util.ListIterator;
4544

45+
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.CRYPTO_XATTR_ENCRYPTION_ZONE;
4646
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.SECURITY_XATTR_UNREADABLE_BY_SUPERUSER;
4747
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.XATTR_SATISFY_STORAGE_POLICY;
48-
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.CRYPTO_XATTR_FILE_ENCRYPTION_INFO;
4948
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.XATTR_SNAPSHOT_DELETED;
50-
import static org.apache.hadoop.hdfs.server.common.HdfsServerConstants.CRYPTO_XATTR_ENCRYPTION_ZONE;
5149

5250
public class FSDirXAttrOp {
5351
private static final XAttr KEYID_XATTR =
@@ -283,25 +281,6 @@ public static INode unprotectedSetXAttrs(
283281
* If we're adding the encryption zone xattr, then add src to the list
284282
* of encryption zones.
285283
*/
286-
287-
if (CRYPTO_XATTR_FILE_ENCRYPTION_INFO.equals(xaName)) {
288-
HdfsProtos.PerFileEncryptionInfoProto fileProto = HdfsProtos.
289-
PerFileEncryptionInfoProto.parseFrom(xattr.getValue());
290-
String keyVersionName = fileProto.getEzKeyVersionName();
291-
String zoneKeyName = fsd.ezManager.getKeyName(iip);
292-
if (zoneKeyName == null) {
293-
throw new IOException("Cannot add raw feInfo XAttr to a file in a " +
294-
"non-encryption zone");
295-
}
296-
297-
if (!KeyProviderCryptoExtension.
298-
getBaseName(keyVersionName).equals(zoneKeyName)) {
299-
throw new IllegalArgumentException(String.format(
300-
"KeyVersion '%s' does not belong to the key '%s'",
301-
keyVersionName, zoneKeyName));
302-
}
303-
}
304-
305284
if (CRYPTO_XATTR_ENCRYPTION_ZONE.equals(xaName)) {
306285
final HdfsProtos.ZoneEncryptionInfoProto ezProto =
307286
HdfsProtos.ZoneEncryptionInfoProto.parseFrom(xattr.getValue());

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import java.util.Collection;
3636
import java.util.EnumSet;
3737
import java.util.List;
38-
import java.util.Map;
3938
import java.util.concurrent.Callable;
4039
import java.util.concurrent.CountDownLatch;
4140
import java.util.concurrent.ExecutionException;
@@ -68,7 +67,6 @@
6867
import org.apache.hadoop.fs.FileSystem;
6968
import org.apache.hadoop.fs.FileSystemTestHelper;
7069
import org.apache.hadoop.fs.FileSystemTestWrapper;
71-
import org.apache.hadoop.fs.FileUtil;
7270
import org.apache.hadoop.fs.FsServerDefaults;
7371
import org.apache.hadoop.fs.FsShell;
7472
import org.apache.hadoop.fs.Path;
@@ -330,72 +328,6 @@ public Object run() throws Exception {
330328
});
331329
}
332330

333-
/**
334-
* Tests encrypted files with same original content placed in two different
335-
* EZ are not same in encrypted form.
336-
*/
337-
@Test
338-
public void testEncryptionZonesDictCp() throws Exception {
339-
final String testkey1 = "testkey1";
340-
final String testkey2 = "testkey2";
341-
DFSTestUtil.createKey(testkey1, cluster, conf);
342-
DFSTestUtil.createKey(testkey2, cluster, conf);
343-
344-
final int len = 8196;
345-
final Path zone1 = new Path("/zone1");
346-
final Path zone1File = new Path(zone1, "file");
347-
final Path raw1File = new Path("/.reserved/raw/zone1/file");
348-
349-
final Path zone2 = new Path("/zone2");
350-
final Path zone2File = new Path(zone2, "file");
351-
final Path raw2File = new Path(zone2, "/.reserved/raw/zone2/file");
352-
353-
// 1. Create two encrypted zones
354-
fs.mkdirs(zone1, new FsPermission(700));
355-
dfsAdmin.createEncryptionZone(zone1, testkey1, NO_TRASH);
356-
357-
fs.mkdirs(zone2, new FsPermission(700));
358-
dfsAdmin.createEncryptionZone(zone2, testkey2, NO_TRASH);
359-
360-
// 2. Create a file in one of the zones
361-
DFSTestUtil.createFile(fs, zone1File, len, (short) 1, 0xFEED);
362-
// 3. Copy it to the other zone through /.raw/reserved
363-
FileUtil.copy(fs, raw1File, fs, raw2File, false, conf);
364-
Map<String, byte[]> attrs = fs.getXAttrs(raw1File);
365-
if (attrs != null) {
366-
for (Map.Entry<String, byte[]> entry : attrs.entrySet()) {
367-
String xattrName = entry.getKey();
368-
369-
try {
370-
fs.setXAttr(raw2File, xattrName, entry.getValue());
371-
fail("Exception should be thrown while setting: " +
372-
xattrName + " on file:" + raw2File);
373-
} catch (RemoteException e) {
374-
Assert.assertEquals(e.getClassName(),
375-
IllegalArgumentException.class.getCanonicalName());
376-
Assert.assertTrue(e.getMessage().
377-
contains("does not belong to the key"));
378-
}
379-
}
380-
}
381-
382-
assertEquals("File can be created on the root encryption zone " +
383-
"with correct length", len, fs.getFileStatus(zone1File).getLen());
384-
assertTrue("/zone1 dir is encrypted",
385-
fs.getFileStatus(zone1).isEncrypted());
386-
assertTrue("File is encrypted", fs.getFileStatus(zone1File).isEncrypted());
387-
388-
assertTrue("/zone2 dir is encrypted",
389-
fs.getFileStatus(zone2).isEncrypted());
390-
assertTrue("File is encrypted", fs.getFileStatus(zone2File).isEncrypted());
391-
392-
// 4. Now the decrypted contents of the files should be different.
393-
DFSTestUtil.verifyFilesNotEqual(fs, zone1File, zone2File, len);
394-
395-
// 5. Encrypted contents of the files should be same.
396-
DFSTestUtil.verifyFilesEqual(fs, raw1File, raw2File, len);
397-
}
398-
399331
/**
400332
* Make sure hdfs crypto -provisionTrash command creates a trash directory
401333
* with sticky bits.

0 commit comments

Comments
 (0)