You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by wa...@apache.org on 2014/07/23 22:45:13 UTC
svn commit: r1612941 - in
/hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src:
main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java
test/java/org/apache/hadoop/hdfs/nfs/nfs3/TestClientAccessPrivilege.java
Author: wang
Date: Wed Jul 23 20:45:10 2014
New Revision: 1612941
URL: http://svn.apache.org/r1612941
Log:
Merge from trunk to branch pt 2
Added:
hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/java/org/apache/hadoop/hdfs/nfs/nfs3/TestClientAccessPrivilege.java
- copied unchanged from r1612915, hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-nfs/src/test/java/org/apache/hadoop/hdfs/nfs/nfs3/TestClientAccessPrivilege.java
Modified:
hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java
Modified: hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java?rev=1612941&r1=1612940&r2=1612941&view=diff
==============================================================================
--- hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java (original)
+++ hadoop/common/branches/fs-encryption/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java Wed Jul 23 20:45:10 2014
@@ -1051,8 +1051,12 @@ public class RpcProgramNfs3 extends RpcP
@Override
public REMOVE3Response remove(XDR xdr, RpcInfo info) {
+ return remove(xdr, getSecurityHandler(info), info.remoteAddress());
+ }
+
+ @VisibleForTesting
+ REMOVE3Response remove(XDR xdr, SecurityHandler securityHandler, SocketAddress remoteAddress) {
REMOVE3Response response = new REMOVE3Response(Nfs3Status.NFS3_OK);
- SecurityHandler securityHandler = getSecurityHandler(info);
DFSClient dfsClient = clientCache.getDfsClient(securityHandler.getUser());
if (dfsClient == null) {
response.setStatus(Nfs3Status.NFS3ERR_SERVERFAULT);
@@ -1083,17 +1087,19 @@ public class RpcProgramNfs3 extends RpcP
return new REMOVE3Response(Nfs3Status.NFS3ERR_STALE);
}
+ WccData errWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
+ preOpDirAttr);
+ if (!checkAccessPrivilege(remoteAddress, AccessPrivilege.READ_WRITE)) {
+ return new REMOVE3Response(Nfs3Status.NFS3ERR_ACCES, errWcc);
+ }
+
String fileIdPath = dirFileIdPath + "/" + fileName;
HdfsFileStatus fstat = Nfs3Utils.getFileStatus(dfsClient, fileIdPath);
if (fstat == null) {
- WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
- preOpDirAttr);
- return new REMOVE3Response(Nfs3Status.NFS3ERR_NOENT, dirWcc);
+ return new REMOVE3Response(Nfs3Status.NFS3ERR_NOENT, errWcc);
}
if (fstat.isDir()) {
- WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
- preOpDirAttr);
- return new REMOVE3Response(Nfs3Status.NFS3ERR_ISDIR, dirWcc);
+ return new REMOVE3Response(Nfs3Status.NFS3ERR_ISDIR, errWcc);
}
boolean result = dfsClient.delete(fileIdPath, false);