Commit e4dbd0d0 authored by Tigran Mkrtchyan's avatar Tigran Mkrtchyan
Browse files

nfsv4: check for valid utf8 name on crate and link

parent 85d0a2ca
......@@ -49,22 +49,18 @@ public class OperationCREATE extends AbstractNFSv4Operation {
CREATE4res res = new CREATE4res();
fattr4 objAttr = _args.opcreate.createattrs;
int type = _args.opcreate.objtype.type;
String name = new String(_args.opcreate.objname.value.value.value);
Inode inode = null;
try {
Stat parentStat = context.currentInode().statCache();
String name = NameFilter.convert(_args.opcreate.objname.value.value.value);
Stat parentStat = context.currentInode().statCache();
UnixAcl fileAcl = new UnixAcl(parentStat.getUid(), parentStat.getGid(), parentStat.getMode() & 0777);
if (!context.getAclHandler().isAllowed(fileAcl, context.getUser(), AclHandler.ACL_INSERT)) {
throw new ChimeraNFSException(nfsstat4.NFS4ERR_ACCESS, "Permission denied.");
}
......
......@@ -46,14 +46,13 @@ public class OperationLINK extends AbstractNFSv4Operation {
_result.oplink = new LINK4res();
String newName = new String(_args.oplink.newname.value.value.value);
try {
String newName = NameFilter.convert(_args.oplink.newname.value.value.value);
Stat parentStat = context.currentInode().statCache();
UnixAcl acl = new UnixAcl(parentStat.getUid(), parentStat.getGid(),parentStat.getMode() & 0777 );
if ( ! context.getAclHandler().isAllowed(acl, context.getUser(), AclHandler.ACL_INSERT ) ) {
throw new ChimeraNFSException( nfsstat4.NFS4ERR_ACCESS, "Permission denied." );
UnixAcl acl = new UnixAcl(parentStat.getUid(), parentStat.getGid(), parentStat.getMode() & 0777);
if (!context.getAclHandler().isAllowed(acl, context.getUser(), AclHandler.ACL_INSERT)) {
throw new ChimeraNFSException(nfsstat4.NFS4ERR_ACCESS, "Permission denied.");
}
context.getFs().link(context.currentInode(), context.savedInode(), newName,
......@@ -62,18 +61,16 @@ public class OperationLINK extends AbstractNFSv4Operation {
_result.oplink.resok4 = new LINK4resok();
_result.oplink.resok4.cinfo = new change_info4();
_result.oplink.resok4.cinfo.atomic = true;
_result.oplink.resok4.cinfo.before = new changeid4( new uint64_t( context.savedInode().statCache().getMTime()));
_result.oplink.resok4.cinfo.after = new changeid4( new uint64_t( System.currentTimeMillis()) );
_result.oplink.resok4.cinfo.before = new changeid4(new uint64_t(context.savedInode().statCache().getMTime()));
_result.oplink.resok4.cinfo.after = new changeid4(new uint64_t(System.currentTimeMillis()));
_result.oplink.status = nfsstat4.NFS4_OK;
}catch(ChimeraNFSException hne){
} catch (ChimeraNFSException hne) {
_result.oplink.status = hne.getStatus();
}catch(Exception e) {
} catch (Exception e) {
_log.error("LINK: ", e);
_result.oplink.status = nfsstat4.NFS4ERR_RESOURCE;
}
return _result;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment