From 14ea8859904001075368bbfc52b803e46ef1a0a7 Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Tue, 27 May 2014 23:05:15 +0000 Subject: [PATCH] HDFS-6411. Merging change r1597895 from trunk git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1597896 13f79535-47bb-0310-9956-ffa450edef68 --- .../nfs/nfs3/response/ACCESS3Response.java | 6 ++-- .../hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java | 34 +++++++++++++++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/ACCESS3Response.java b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/ACCESS3Response.java index 8ba07aa5b37..5720fc64797 100644 --- a/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/ACCESS3Response.java +++ b/hadoop-common-project/hadoop-nfs/src/main/java/org/apache/hadoop/nfs/nfs3/response/ACCESS3Response.java @@ -46,10 +46,12 @@ public class ACCESS3Response extends NFS3Response { @Override public XDR writeHeaderAndResponse(XDR out, int xid, Verifier verifier) { super.writeHeaderAndResponse(out, xid, verifier); - out.writeBoolean(true); - postOpAttr.serialize(out); if (this.getStatus() == Nfs3Status.NFS3_OK) { + out.writeBoolean(true); + postOpAttr.serialize(out); out.writeInt(access); + } else { + out.writeBoolean(false); } return out; } diff --git a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java index f78598f13a2..62aa8cbedc0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java +++ b/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java @@ -124,6 +124,7 @@ import org.apache.hadoop.oncrpc.security.VerifierNone; import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.UserGroupInformation; +import org.apache.hadoop.security.authorize.AuthorizationException; import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.channel.Channel; @@ -270,6 +271,17 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface { Nfs3FileAttributes attrs = null; try { attrs = writeManager.getFileAttr(dfsClient, handle, iug); + } catch (RemoteException r) { + LOG.warn("Exception ", r); + IOException io = r.unwrapRemoteException(); + /** + * AuthorizationException can be thrown if the user can't be proxy'ed. + */ + if (io instanceof AuthorizationException) { + return new GETATTR3Response(Nfs3Status.NFS3ERR_ACCES); + } else { + return new GETATTR3Response(Nfs3Status.NFS3ERR_IO); + } } catch (IOException e) { LOG.info("Can't get file attribute, fileId=" + handle.getFileId(), e); response.setStatus(Nfs3Status.NFS3ERR_IO); @@ -499,6 +511,17 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface { securityHandler.getUid(), securityHandler.getGid(), attrs); return new ACCESS3Response(Nfs3Status.NFS3_OK, attrs, access); + } catch (RemoteException r) { + LOG.warn("Exception ", r); + IOException io = r.unwrapRemoteException(); + /** + * AuthorizationException can be thrown if the user can't be proxy'ed. + */ + if (io instanceof AuthorizationException) { + return new ACCESS3Response(Nfs3Status.NFS3ERR_ACCES); + } else { + return new ACCESS3Response(Nfs3Status.NFS3ERR_IO); + } } catch (IOException e) { LOG.warn("Exception ", e); return new ACCESS3Response(Nfs3Status.NFS3ERR_IO); @@ -1680,6 +1703,17 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface { return new FSSTAT3Response(Nfs3Status.NFS3_OK, attrs, totalBytes, freeBytes, freeBytes, maxFsObjects, maxFsObjects, maxFsObjects, 0); + } catch (RemoteException r) { + LOG.warn("Exception ", r); + IOException io = r.unwrapRemoteException(); + /** + * AuthorizationException can be thrown if the user can't be proxy'ed. + */ + if (io instanceof AuthorizationException) { + return new FSSTAT3Response(Nfs3Status.NFS3ERR_ACCES); + } else { + return new FSSTAT3Response(Nfs3Status.NFS3ERR_IO); + } } catch (IOException e) { LOG.warn("Exception ", e); return new FSSTAT3Response(Nfs3Status.NFS3ERR_IO); diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 8dccd2ad55b..bbb856188fc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -369,6 +369,9 @@ Release 2.4.1 - UNRELEASED HDFS-6397. NN shows inconsistent value in deadnode count. (Mohammad Kamrul Islam via kihwal) + HDFS-6411. nfs-hdfs-gateway mount raises I/O error and hangs when a + unauthorized user attempts to access it (brandonli) + Release 2.4.0 - 2014-04-07 INCOMPATIBLE CHANGES