|
@@ -22,22 +22,23 @@ import java.io.IOException;
|
|
|
import java.net.InetAddress;
|
|
|
import java.nio.ByteBuffer;
|
|
|
import java.util.EnumSet;
|
|
|
-import java.util.List;
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.CreateFlag;
|
|
|
import org.apache.hadoop.fs.FSDataInputStream;
|
|
|
-import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
|
|
|
-import org.apache.hadoop.fs.Options;
|
|
|
import org.apache.hadoop.fs.FileSystem.Statistics;
|
|
|
import org.apache.hadoop.fs.FileUtil;
|
|
|
import org.apache.hadoop.fs.FsStatus;
|
|
|
+import org.apache.hadoop.fs.Options;
|
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
|
import org.apache.hadoop.hdfs.DFSClient;
|
|
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
|
|
import org.apache.hadoop.hdfs.DFSInputStream;
|
|
|
+import org.apache.hadoop.hdfs.client.HdfsDataOutputStream;
|
|
|
+import org.apache.hadoop.hdfs.nfs.security.AccessPrivilege;
|
|
|
+import org.apache.hadoop.hdfs.nfs.security.NfsExports;
|
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
@@ -125,6 +126,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
private final IdUserGroup iug;// = new IdUserGroup();
|
|
|
private final DFSClientCache clientCache;
|
|
|
|
|
|
+ private final NfsExports exports;
|
|
|
+
|
|
|
/**
|
|
|
* superUserClient should always impersonate HDFS file system owner to send
|
|
|
* requests which requires supergroup privilege. This requires the same user
|
|
@@ -138,17 +141,19 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
private Statistics statistics;
|
|
|
private String writeDumpDir; // The dir save dump files
|
|
|
|
|
|
- public RpcProgramNfs3(List<String> exports) throws IOException {
|
|
|
- this(exports, new Configuration());
|
|
|
+ public RpcProgramNfs3() throws IOException {
|
|
|
+ this(new Configuration());
|
|
|
}
|
|
|
|
|
|
- public RpcProgramNfs3(List<String> exports, Configuration config)
|
|
|
+ public RpcProgramNfs3(Configuration config)
|
|
|
throws IOException {
|
|
|
super("NFS3", "localhost", Nfs3Constant.PORT, Nfs3Constant.PROGRAM,
|
|
|
Nfs3Constant.VERSION, Nfs3Constant.VERSION, 100);
|
|
|
|
|
|
config.set(FsPermission.UMASK_LABEL, "000");
|
|
|
iug = new IdUserGroup();
|
|
|
+
|
|
|
+ exports = NfsExports.getInstance(config);
|
|
|
writeManager = new WriteManager(iug, config);
|
|
|
clientCache = new DFSClientCache(config);
|
|
|
superUserClient = new DFSClient(NameNode.getAddress(config), config);
|
|
@@ -185,7 +190,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
/******************************************************
|
|
|
* RPC call handlers
|
|
|
******************************************************/
|
|
|
-
|
|
|
+
|
|
|
+ @Override
|
|
|
public NFS3Response nullProcedure() {
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("NFS NULL");
|
|
@@ -193,8 +199,16 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
return new VoidResponse(Nfs3Status.NFS3_OK);
|
|
|
}
|
|
|
|
|
|
- public GETATTR3Response getattr(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public GETATTR3Response getattr(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
GETATTR3Response response = new GETATTR3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -267,7 +281,9 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public SETATTR3Response setattr(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public SETATTR3Response setattr(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
SETATTR3Response response = new SETATTR3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -298,34 +314,39 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
String fileIdPath = Nfs3Utils.getFileIdPath(handle);
|
|
|
- WccAttr preOpAttr = null;
|
|
|
+ Nfs3FileAttributes preOpAttr = null;
|
|
|
try {
|
|
|
- preOpAttr = Nfs3Utils.getWccAttr(dfsClient, fileIdPath);
|
|
|
+ preOpAttr = Nfs3Utils.getFileAttr(dfsClient, fileIdPath, iug);
|
|
|
if (preOpAttr == null) {
|
|
|
LOG.info("Can't get path for fileId:" + handle.getFileId());
|
|
|
response.setStatus(Nfs3Status.NFS3ERR_STALE);
|
|
|
return response;
|
|
|
}
|
|
|
+ WccAttr preOpWcc = Nfs3Utils.getWccAttr(preOpAttr);
|
|
|
if (request.isCheck()) {
|
|
|
if (!preOpAttr.getCtime().equals(request.getCtime())) {
|
|
|
- WccData wccData = Nfs3Utils.createWccData(preOpAttr, dfsClient,
|
|
|
- fileIdPath, iug);
|
|
|
+ WccData wccData = new WccData(preOpWcc, preOpAttr);
|
|
|
return new SETATTR3Response(Nfs3Status.NFS3ERR_NOT_SYNC, wccData);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // check the write access privilege
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new SETATTR3Response(Nfs3Status.NFS3ERR_ACCES, new WccData(
|
|
|
+ preOpWcc, preOpAttr));
|
|
|
+ }
|
|
|
|
|
|
setattrInternal(dfsClient, fileIdPath, request.getAttr(), true);
|
|
|
Nfs3FileAttributes postOpAttr = Nfs3Utils.getFileAttr(dfsClient,
|
|
|
fileIdPath, iug);
|
|
|
- WccData wccData = new WccData(preOpAttr, postOpAttr);
|
|
|
+ WccData wccData = new WccData(preOpWcc, postOpAttr);
|
|
|
return new SETATTR3Response(Nfs3Status.NFS3_OK, wccData);
|
|
|
-
|
|
|
} catch (IOException e) {
|
|
|
LOG.warn("Exception ", e);
|
|
|
WccData wccData = null;
|
|
|
try {
|
|
|
- wccData = Nfs3Utils
|
|
|
- .createWccData(preOpAttr, dfsClient, fileIdPath, iug);
|
|
|
+ wccData = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(preOpAttr),
|
|
|
+ dfsClient, fileIdPath, iug);
|
|
|
} catch (IOException e1) {
|
|
|
LOG.info("Can't get postOpAttr for fileIdPath: " + fileIdPath);
|
|
|
}
|
|
@@ -337,8 +358,15 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public LOOKUP3Response lookup(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public LOOKUP3Response lookup(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
LOOKUP3Response response = new LOOKUP3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -392,8 +420,15 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ACCESS3Response access(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public ACCESS3Response access(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
ACCESS3Response response = new ACCESS3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -434,12 +469,20 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public READLINK3Response readlink(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ public READLINK3Response readlink(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
return new READLINK3Response(Nfs3Status.NFS3ERR_NOTSUPP);
|
|
|
}
|
|
|
|
|
|
- public READ3Response read(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public READ3Response read(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
READ3Response response = new READ3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -528,8 +571,9 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public WRITE3Response write(XDR xdr, Channel channel, int xid,
|
|
|
- RpcAuthSys authSys) {
|
|
|
+ RpcAuthSys authSys, InetAddress client) {
|
|
|
WRITE3Response response = new WRITE3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -570,6 +614,13 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
LOG.error("Can't get path for fileId:" + handle.getFileId());
|
|
|
return new WRITE3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new WRITE3Response(Nfs3Status.NFS3ERR_ACCES, new WccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpAttr), preOpAttr), 0, stableHow,
|
|
|
+ Nfs3Constant.WRITE_COMMIT_VERF);
|
|
|
+ }
|
|
|
+
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("requesed offset=" + offset + " and current filesize="
|
|
|
+ preOpAttr.getSize());
|
|
@@ -596,7 +647,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public CREATE3Response create(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public CREATE3Response create(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
CREATE3Response response = new CREATE3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -631,16 +683,22 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
|
|
|
HdfsDataOutputStream fos = null;
|
|
|
String dirFileIdPath = Nfs3Utils.getFileIdPath(dirHandle);
|
|
|
- WccAttr preOpDirAttr = null;
|
|
|
+ Nfs3FileAttributes preOpDirAttr = null;
|
|
|
Nfs3FileAttributes postOpObjAttr = null;
|
|
|
FileHandle fileHandle = null;
|
|
|
WccData dirWcc = null;
|
|
|
try {
|
|
|
- preOpDirAttr = Nfs3Utils.getWccAttr(dfsClient, dirFileIdPath);
|
|
|
+ preOpDirAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);
|
|
|
if (preOpDirAttr == null) {
|
|
|
LOG.error("Can't get path for dirHandle:" + dirHandle);
|
|
|
return new CREATE3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new CREATE3Response(Nfs3Status.NFS3ERR_ACCES, null,
|
|
|
+ preOpDirAttr, new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ preOpDirAttr));
|
|
|
+ }
|
|
|
|
|
|
String fileIdPath = Nfs3Utils.getFileIdPath(dirHandle) + "/" + fileName;
|
|
|
SetAttr3 setAttr3 = request.getObjAttr();
|
|
@@ -649,9 +707,9 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
SetAttrField.MODE) ? new FsPermission((short) setAttr3.getMode())
|
|
|
: FsPermission.getDefault().applyUMask(umask);
|
|
|
|
|
|
- EnumSet<CreateFlag> flag = (createMode != Nfs3Constant.CREATE_EXCLUSIVE) ? EnumSet
|
|
|
- .of(CreateFlag.CREATE, CreateFlag.OVERWRITE) : EnumSet
|
|
|
- .of(CreateFlag.CREATE);
|
|
|
+ EnumSet<CreateFlag> flag = (createMode != Nfs3Constant.CREATE_EXCLUSIVE) ?
|
|
|
+ EnumSet.of(CreateFlag.CREATE, CreateFlag.OVERWRITE) :
|
|
|
+ EnumSet.of(CreateFlag.CREATE);
|
|
|
|
|
|
fos = new HdfsDataOutputStream(dfsClient.create(fileIdPath, permission,
|
|
|
flag, false, replication, blockSize, null, bufferSize, null),
|
|
@@ -668,8 +726,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
postOpObjAttr = Nfs3Utils.getFileAttr(dfsClient, fileIdPath, iug);
|
|
|
- dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient, dirFileIdPath,
|
|
|
- iug);
|
|
|
+ dirWcc = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ dfsClient, dirFileIdPath, iug);
|
|
|
} catch (IOException e) {
|
|
|
LOG.error("Exception", e);
|
|
|
if (fos != null) {
|
|
@@ -682,8 +740,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
if (dirWcc == null) {
|
|
|
try {
|
|
|
- dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ dirWcc = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ dfsClient, dirFileIdPath, iug);
|
|
|
} catch (IOException e1) {
|
|
|
LOG.error("Can't get postOpDirAttr for dirFileId:"
|
|
|
+ dirHandle.getFileId());
|
|
@@ -712,7 +770,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
dirWcc);
|
|
|
}
|
|
|
|
|
|
- public MKDIR3Response mkdir(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public MKDIR3Response mkdir(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
MKDIR3Response response = new MKDIR3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -739,17 +798,22 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
String dirFileIdPath = Nfs3Utils.getFileIdPath(dirHandle);
|
|
|
- WccAttr preOpDirAttr = null;
|
|
|
+ Nfs3FileAttributes preOpDirAttr = null;
|
|
|
Nfs3FileAttributes postOpDirAttr = null;
|
|
|
Nfs3FileAttributes postOpObjAttr = null;
|
|
|
FileHandle objFileHandle = null;
|
|
|
try {
|
|
|
- preOpDirAttr = Nfs3Utils.getWccAttr(dfsClient, dirFileIdPath);
|
|
|
+ preOpDirAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);
|
|
|
if (preOpDirAttr == null) {
|
|
|
LOG.info("Can't get path for dir fileId:" + dirHandle.getFileId());
|
|
|
return new MKDIR3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new MKDIR3Response(Nfs3Status.NFS3ERR_ACCES, null, preOpDirAttr,
|
|
|
+ new WccData(Nfs3Utils.getWccAttr(preOpDirAttr), preOpDirAttr));
|
|
|
+ }
|
|
|
+
|
|
|
final String fileIdPath = dirFileIdPath + "/" + fileName;
|
|
|
SetAttr3 setAttr3 = request.getObjAttr();
|
|
|
FsPermission permission = setAttr3.getUpdateFields().contains(
|
|
@@ -757,8 +821,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
: FsPermission.getDefault().applyUMask(umask);
|
|
|
|
|
|
if (!dfsClient.mkdirs(fileIdPath, permission, false)) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ WccData dirWcc = Nfs3Utils.createWccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpDirAttr), dfsClient, dirFileIdPath, iug);
|
|
|
return new MKDIR3Response(Nfs3Status.NFS3ERR_IO, null, null, dirWcc);
|
|
|
}
|
|
|
|
|
@@ -771,8 +835,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
|
|
|
postOpObjAttr = Nfs3Utils.getFileAttr(dfsClient, fileIdPath, iug);
|
|
|
objFileHandle = new FileHandle(postOpObjAttr.getFileId());
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ WccData dirWcc = Nfs3Utils.createWccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpDirAttr), dfsClient, dirFileIdPath, iug);
|
|
|
return new MKDIR3Response(Nfs3Status.NFS3_OK, new FileHandle(
|
|
|
postOpObjAttr.getFileId()), postOpObjAttr, dirWcc);
|
|
|
} catch (IOException e) {
|
|
@@ -785,7 +849,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
LOG.info("Can't get postOpDirAttr for " + dirFileIdPath);
|
|
|
}
|
|
|
}
|
|
|
- WccData dirWcc = new WccData(preOpDirAttr, postOpDirAttr);
|
|
|
+ WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ postOpDirAttr);
|
|
|
if (e instanceof AccessControlException) {
|
|
|
return new MKDIR3Response(Nfs3Status.NFS3ERR_PERM, objFileHandle,
|
|
|
postOpObjAttr, dirWcc);
|
|
@@ -796,12 +861,12 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public READDIR3Response mknod(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ public READDIR3Response mknod(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
return new READDIR3Response(Nfs3Status.NFS3ERR_NOTSUPP);
|
|
|
}
|
|
|
|
|
|
- public REMOVE3Response remove(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public REMOVE3Response remove(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
REMOVE3Response response = new REMOVE3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -825,10 +890,10 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
String dirFileIdPath = Nfs3Utils.getFileIdPath(dirHandle);
|
|
|
- WccAttr preOpDirAttr = null;
|
|
|
+ Nfs3FileAttributes preOpDirAttr = null;
|
|
|
Nfs3FileAttributes postOpDirAttr = null;
|
|
|
try {
|
|
|
- preOpDirAttr = Nfs3Utils.getWccAttr(dfsClient, dirFileIdPath);
|
|
|
+ preOpDirAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);
|
|
|
if (preOpDirAttr == null) {
|
|
|
LOG.info("Can't get path for dir fileId:" + dirHandle.getFileId());
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3ERR_STALE);
|
|
@@ -838,24 +903,23 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
HdfsFileStatus fstat = Nfs3Utils.getFileStatus(dfsClient,
|
|
|
fileIdPath);
|
|
|
if (fstat == null) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ preOpDirAttr);
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3ERR_NOENT, dirWcc);
|
|
|
}
|
|
|
if (fstat.isDir()) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ preOpDirAttr);
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3ERR_ISDIR, dirWcc);
|
|
|
}
|
|
|
|
|
|
- if (dfsClient.delete(fileIdPath, false) == false) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ boolean result = dfsClient.delete(fileIdPath, false);
|
|
|
+ WccData dirWcc = Nfs3Utils.createWccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpDirAttr), dfsClient, dirFileIdPath, iug);
|
|
|
+
|
|
|
+ if (!result) {
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3ERR_ACCES, dirWcc);
|
|
|
}
|
|
|
-
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3_OK, dirWcc);
|
|
|
} catch (IOException e) {
|
|
|
LOG.warn("Exception ", e);
|
|
@@ -867,7 +931,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
LOG.info("Can't get postOpDirAttr for " + dirFileIdPath);
|
|
|
}
|
|
|
}
|
|
|
- WccData dirWcc = new WccData(preOpDirAttr, postOpDirAttr);
|
|
|
+ WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ postOpDirAttr);
|
|
|
if (e instanceof AccessControlException) {
|
|
|
return new REMOVE3Response(Nfs3Status.NFS3ERR_PERM, dirWcc);
|
|
|
} else {
|
|
@@ -876,7 +941,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public RMDIR3Response rmdir(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public RMDIR3Response rmdir(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
RMDIR3Response response = new RMDIR3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -901,45 +967,43 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
String dirFileIdPath = Nfs3Utils.getFileIdPath(dirHandle);
|
|
|
- WccAttr preOpDirAttr = null;
|
|
|
+ Nfs3FileAttributes preOpDirAttr = null;
|
|
|
Nfs3FileAttributes postOpDirAttr = null;
|
|
|
try {
|
|
|
- preOpDirAttr = Nfs3Utils.getWccAttr(dfsClient, dirFileIdPath);
|
|
|
+ preOpDirAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);
|
|
|
if (preOpDirAttr == null) {
|
|
|
LOG.info("Can't get path for dir fileId:" + dirHandle.getFileId());
|
|
|
return new RMDIR3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
+
|
|
|
+ WccData errWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ preOpDirAttr);
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new RMDIR3Response(Nfs3Status.NFS3ERR_ACCES, errWcc);
|
|
|
+ }
|
|
|
|
|
|
String fileIdPath = dirFileIdPath + "/" + fileName;
|
|
|
HdfsFileStatus fstat = Nfs3Utils.getFileStatus(dfsClient,
|
|
|
fileIdPath);
|
|
|
if (fstat == null) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
- return new RMDIR3Response(Nfs3Status.NFS3ERR_NOENT, dirWcc);
|
|
|
+ return new RMDIR3Response(Nfs3Status.NFS3ERR_NOENT, errWcc);
|
|
|
}
|
|
|
if (!fstat.isDir()) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
- return new RMDIR3Response(Nfs3Status.NFS3ERR_NOTDIR, dirWcc);
|
|
|
+ return new RMDIR3Response(Nfs3Status.NFS3ERR_NOTDIR, errWcc);
|
|
|
}
|
|
|
|
|
|
if (fstat.getChildrenNum() > 0) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
- return new RMDIR3Response(Nfs3Status.NFS3ERR_NOTEMPTY, dirWcc);
|
|
|
+ return new RMDIR3Response(Nfs3Status.NFS3ERR_NOTEMPTY, errWcc);
|
|
|
}
|
|
|
|
|
|
- if (dfsClient.delete(fileIdPath, false) == false) {
|
|
|
- WccData dirWcc = Nfs3Utils.createWccData(preOpDirAttr, dfsClient,
|
|
|
- dirFileIdPath, iug);
|
|
|
+ boolean result = dfsClient.delete(fileIdPath, false);
|
|
|
+ WccData dirWcc = Nfs3Utils.createWccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpDirAttr), dfsClient, dirFileIdPath, iug);
|
|
|
+ if (!result) {
|
|
|
return new RMDIR3Response(Nfs3Status.NFS3ERR_ACCES, dirWcc);
|
|
|
}
|
|
|
|
|
|
- postOpDirAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);
|
|
|
- WccData wccData = new WccData(preOpDirAttr, postOpDirAttr);
|
|
|
- return new RMDIR3Response(Nfs3Status.NFS3_OK, wccData);
|
|
|
-
|
|
|
+ return new RMDIR3Response(Nfs3Status.NFS3_OK, dirWcc);
|
|
|
} catch (IOException e) {
|
|
|
LOG.warn("Exception ", e);
|
|
|
// Try to return correct WccData
|
|
@@ -950,7 +1014,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
LOG.info("Can't get postOpDirAttr for " + dirFileIdPath);
|
|
|
}
|
|
|
}
|
|
|
- WccData dirWcc = new WccData(preOpDirAttr, postOpDirAttr);
|
|
|
+ WccData dirWcc = new WccData(Nfs3Utils.getWccAttr(preOpDirAttr),
|
|
|
+ postOpDirAttr);
|
|
|
if (e instanceof AccessControlException) {
|
|
|
return new RMDIR3Response(Nfs3Status.NFS3ERR_PERM, dirWcc);
|
|
|
} else {
|
|
@@ -959,7 +1024,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public RENAME3Response rename(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public RENAME3Response rename(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
RENAME3Response response = new RENAME3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -987,23 +1053,31 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
|
|
|
String fromDirFileIdPath = Nfs3Utils.getFileIdPath(fromHandle);
|
|
|
String toDirFileIdPath = Nfs3Utils.getFileIdPath(toHandle);
|
|
|
- WccAttr fromPreOpAttr = null;
|
|
|
- WccAttr toPreOpAttr = null;
|
|
|
+ Nfs3FileAttributes fromPreOpAttr = null;
|
|
|
+ Nfs3FileAttributes toPreOpAttr = null;
|
|
|
WccData fromDirWcc = null;
|
|
|
WccData toDirWcc = null;
|
|
|
try {
|
|
|
- fromPreOpAttr = Nfs3Utils.getWccAttr(dfsClient, fromDirFileIdPath);
|
|
|
+ fromPreOpAttr = Nfs3Utils.getFileAttr(dfsClient, fromDirFileIdPath, iug);
|
|
|
if (fromPreOpAttr == null) {
|
|
|
LOG.info("Can't get path for fromHandle fileId:"
|
|
|
+ fromHandle.getFileId());
|
|
|
return new RENAME3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
|
|
|
- toPreOpAttr = Nfs3Utils.getWccAttr(dfsClient, toDirFileIdPath);
|
|
|
+ toPreOpAttr = Nfs3Utils.getFileAttr(dfsClient, toDirFileIdPath, iug);
|
|
|
if (toPreOpAttr == null) {
|
|
|
LOG.info("Can't get path for toHandle fileId:" + toHandle.getFileId());
|
|
|
return new RENAME3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ WccData fromWcc = new WccData(Nfs3Utils.getWccAttr(fromPreOpAttr),
|
|
|
+ fromPreOpAttr);
|
|
|
+ WccData toWcc = new WccData(Nfs3Utils.getWccAttr(toPreOpAttr),
|
|
|
+ toPreOpAttr);
|
|
|
+ return new RENAME3Response(Nfs3Status.NFS3ERR_ACCES, fromWcc, toWcc);
|
|
|
+ }
|
|
|
|
|
|
String src = fromDirFileIdPath + "/" + fromName;
|
|
|
String dst = toDirFileIdPath + "/" + toName;
|
|
@@ -1011,20 +1085,20 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
dfsClient.rename(src, dst, Options.Rename.NONE);
|
|
|
|
|
|
// Assemble the reply
|
|
|
- fromDirWcc = Nfs3Utils.createWccData(fromPreOpAttr, dfsClient,
|
|
|
- fromDirFileIdPath, iug);
|
|
|
- toDirWcc = Nfs3Utils.createWccData(toPreOpAttr, dfsClient,
|
|
|
- toDirFileIdPath, iug);
|
|
|
+ fromDirWcc = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(fromPreOpAttr),
|
|
|
+ dfsClient, fromDirFileIdPath, iug);
|
|
|
+ toDirWcc = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(toPreOpAttr),
|
|
|
+ dfsClient, toDirFileIdPath, iug);
|
|
|
return new RENAME3Response(Nfs3Status.NFS3_OK, fromDirWcc, toDirWcc);
|
|
|
-
|
|
|
} catch (IOException e) {
|
|
|
LOG.warn("Exception ", e);
|
|
|
// Try to return correct WccData
|
|
|
try {
|
|
|
- fromDirWcc = Nfs3Utils.createWccData(fromPreOpAttr, dfsClient,
|
|
|
- fromDirFileIdPath, iug);
|
|
|
- toDirWcc = Nfs3Utils.createWccData(toPreOpAttr, dfsClient,
|
|
|
- toDirFileIdPath, iug);
|
|
|
+ fromDirWcc = Nfs3Utils.createWccData(
|
|
|
+ Nfs3Utils.getWccAttr(fromPreOpAttr), dfsClient, fromDirFileIdPath,
|
|
|
+ iug);
|
|
|
+ toDirWcc = Nfs3Utils.createWccData(Nfs3Utils.getWccAttr(toPreOpAttr),
|
|
|
+ dfsClient, toDirFileIdPath, iug);
|
|
|
} catch (IOException e1) {
|
|
|
LOG.info("Can't get postOpDirAttr for " + fromDirFileIdPath + " or"
|
|
|
+ toDirFileIdPath);
|
|
@@ -1038,16 +1112,25 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public SYMLINK3Response symlink(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ public SYMLINK3Response symlink(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
return new SYMLINK3Response(Nfs3Status.NFS3ERR_NOTSUPP);
|
|
|
}
|
|
|
|
|
|
- public READDIR3Response link(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ public READDIR3Response link(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
return new READDIR3Response(Nfs3Status.NFS3ERR_NOTSUPP);
|
|
|
}
|
|
|
|
|
|
- public READDIR3Response readdir(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public READDIR3Response readdir(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
READDIR3Response response = new READDIR3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -1180,7 +1263,12 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
dirStatus.getModificationTime(), dirList);
|
|
|
}
|
|
|
|
|
|
- public READDIRPLUS3Response readdirplus(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ public READDIRPLUS3Response readdirplus(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ return new READDIRPLUS3Response(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -1325,8 +1413,15 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
dirStatus.getModificationTime(), dirListPlus);
|
|
|
}
|
|
|
|
|
|
- public FSSTAT3Response fsstat(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public FSSTAT3Response fsstat(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
FSSTAT3Response response = new FSSTAT3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -1376,8 +1471,15 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public FSINFO3Response fsinfo(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public FSINFO3Response fsinfo(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
FSINFO3Response response = new FSINFO3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -1421,8 +1523,16 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public PATHCONF3Response pathconf(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public PATHCONF3Response pathconf(XDR xdr, RpcAuthSys authSys,
|
|
|
+ InetAddress client) {
|
|
|
PATHCONF3Response response = new PATHCONF3Response(Nfs3Status.NFS3_OK);
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_ONLY)) {
|
|
|
+ response.setStatus(Nfs3Status.NFS3ERR_ACCES);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
|
if (dfsClient == null) {
|
|
@@ -1461,7 +1571,8 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public COMMIT3Response commit(XDR xdr, RpcAuthSys authSys) {
|
|
|
+ @Override
|
|
|
+ public COMMIT3Response commit(XDR xdr, RpcAuthSys authSys, InetAddress client) {
|
|
|
COMMIT3Response response = new COMMIT3Response(Nfs3Status.NFS3_OK);
|
|
|
String uname = authSysCheck(authSys);
|
|
|
DFSClient dfsClient = clientCache.get(uname);
|
|
@@ -1486,13 +1597,20 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
|
|
|
String fileIdPath = Nfs3Utils.getFileIdPath(handle);
|
|
|
- WccAttr preOpAttr = null;
|
|
|
+ Nfs3FileAttributes preOpAttr = null;
|
|
|
try {
|
|
|
- preOpAttr = Nfs3Utils.getWccAttr(dfsClient, fileIdPath);
|
|
|
+ preOpAttr = Nfs3Utils.getFileAttr(dfsClient, fileIdPath, iug);
|
|
|
if (preOpAttr == null) {
|
|
|
LOG.info("Can't get path for fileId:" + handle.getFileId());
|
|
|
return new COMMIT3Response(Nfs3Status.NFS3ERR_STALE);
|
|
|
}
|
|
|
+
|
|
|
+ if (!checkAccessPrivilege(client, AccessPrivilege.READ_WRITE)) {
|
|
|
+ return new COMMIT3Response(Nfs3Status.NFS3ERR_ACCES, new WccData(
|
|
|
+ Nfs3Utils.getWccAttr(preOpAttr), preOpAttr),
|
|
|
+ Nfs3Constant.WRITE_COMMIT_VERF);
|
|
|
+ }
|
|
|
+
|
|
|
long commitOffset = (request.getCount() == 0) ? 0
|
|
|
: (request.getOffset() + request.getCount());
|
|
|
|
|
@@ -1504,7 +1622,7 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
}
|
|
|
Nfs3FileAttributes postOpAttr = writeManager.getFileAttr(dfsClient,
|
|
|
handle, iug);
|
|
|
- WccData fileWcc = new WccData(preOpAttr, postOpAttr);
|
|
|
+ WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr), postOpAttr);
|
|
|
return new COMMIT3Response(status, fileWcc,
|
|
|
Nfs3Constant.WRITE_COMMIT_VERF);
|
|
|
|
|
@@ -1516,7 +1634,7 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
} catch (IOException e1) {
|
|
|
LOG.info("Can't get postOpAttr for fileId: " + handle.getFileId());
|
|
|
}
|
|
|
- WccData fileWcc = new WccData(preOpAttr, postOpAttr);
|
|
|
+ WccData fileWcc = new WccData(Nfs3Utils.getWccAttr(preOpAttr), postOpAttr);
|
|
|
return new COMMIT3Response(Nfs3Status.NFS3ERR_IO, fileWcc,
|
|
|
Nfs3Constant.WRITE_COMMIT_VERF);
|
|
|
}
|
|
@@ -1554,47 +1672,47 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
if (nfsproc3 == NFSPROC3.NULL) {
|
|
|
response = nullProcedure();
|
|
|
} else if (nfsproc3 == NFSPROC3.GETATTR) {
|
|
|
- response = getattr(xdr, authSys);
|
|
|
+ response = getattr(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.SETATTR) {
|
|
|
- response = setattr(xdr, authSys);
|
|
|
+ response = setattr(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.LOOKUP) {
|
|
|
- response = lookup(xdr, authSys);
|
|
|
+ response = lookup(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.ACCESS) {
|
|
|
- response = access(xdr, authSys);
|
|
|
+ response = access(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.READLINK) {
|
|
|
- response = readlink(xdr, authSys);
|
|
|
+ response = readlink(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.READ) {
|
|
|
- response = read(xdr, authSys);
|
|
|
+ response = read(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.WRITE) {
|
|
|
- response = write(xdr, channel, xid, authSys);
|
|
|
+ response = write(xdr, channel, xid, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.CREATE) {
|
|
|
- response = create(xdr, authSys);
|
|
|
+ response = create(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.MKDIR) {
|
|
|
- response = mkdir(xdr, authSys);
|
|
|
+ response = mkdir(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.SYMLINK) {
|
|
|
- response = symlink(xdr, authSys);
|
|
|
+ response = symlink(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.MKNOD) {
|
|
|
- response = mknod(xdr, authSys);
|
|
|
+ response = mknod(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.REMOVE) {
|
|
|
- response = remove(xdr, authSys);
|
|
|
+ response = remove(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.RMDIR) {
|
|
|
- response = rmdir(xdr, authSys);
|
|
|
+ response = rmdir(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.RENAME) {
|
|
|
- response = rename(xdr, authSys);
|
|
|
+ response = rename(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.LINK) {
|
|
|
- response = link(xdr, authSys);
|
|
|
+ response = link(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.READDIR) {
|
|
|
- response = readdir(xdr, authSys);
|
|
|
+ response = readdir(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.READDIRPLUS) {
|
|
|
- response = readdirplus(xdr, authSys);
|
|
|
+ response = readdirplus(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.FSSTAT) {
|
|
|
- response = fsstat(xdr, authSys);
|
|
|
+ response = fsstat(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.FSINFO) {
|
|
|
- response = fsinfo(xdr, authSys);
|
|
|
+ response = fsinfo(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.PATHCONF) {
|
|
|
- response = pathconf(xdr, authSys);
|
|
|
+ response = pathconf(xdr, authSys, client);
|
|
|
} else if (nfsproc3 == NFSPROC3.COMMIT) {
|
|
|
- response = commit(xdr, authSys);
|
|
|
+ response = commit(xdr, authSys, client);
|
|
|
} else {
|
|
|
// Invalid procedure
|
|
|
RpcAcceptedReply.voidReply(out, xid,
|
|
@@ -1611,4 +1729,17 @@ public class RpcProgramNfs3 extends RpcProgram implements Nfs3Interface {
|
|
|
final NFSPROC3 nfsproc3 = NFSPROC3.fromValue(call.getProcedure());
|
|
|
return nfsproc3 == null || nfsproc3.isIdempotent();
|
|
|
}
|
|
|
+
|
|
|
+ private boolean checkAccessPrivilege(final InetAddress client,
|
|
|
+ final AccessPrivilege expected) {
|
|
|
+ AccessPrivilege access = exports.getAccessPrivilege(client);
|
|
|
+ if (access == AccessPrivilege.NONE) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (access == AccessPrivilege.READ_ONLY
|
|
|
+ && expected == AccessPrivilege.READ_WRITE) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|