Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
nfs4j
Commits
e4dbd0d0
Commit
e4dbd0d0
authored
Oct 19, 2011
by
Tigran Mkrtchyan
☕
Browse files
nfsv4: check for valid utf8 name on crate and link
parent
85d0a2ca
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/org/dcache/chimera/nfs/v4/OperationCREATE.java
View file @
e4dbd0d0
...
...
@@ -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
);
int
type
=
_args
.
opcreate
.
objtype
.
type
;
Inode
inode
=
null
;
try
{
St
at
parentStat
=
context
.
currentInode
().
statCache
(
);
St
ring
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."
);
}
...
...
src/org/dcache/chimera/nfs/v4/OperationLINK.java
View file @
e4dbd0d0
...
...
@@ -35,45 +35,42 @@ import org.slf4j.LoggerFactory;
public
class
OperationLINK
extends
AbstractNFSv4Operation
{
private
static
final
Logger
_log
=
LoggerFactory
.
getLogger
(
OperationLINK
.
class
);
private
static
final
Logger
_log
=
LoggerFactory
.
getLogger
(
OperationLINK
.
class
);
OperationLINK
(
nfs_argop4
args
)
{
super
(
args
,
nfs_opnum4
.
OP_LINK
);
}
OperationLINK
(
nfs_argop4
args
)
{
super
(
args
,
nfs_opnum4
.
OP_LINK
);
}
@Override
public
nfs_resop4
process
(
CompoundContext
context
)
{
@Override
public
nfs_resop4
process
(
CompoundContext
context
)
{
_result
.
oplink
=
new
LINK4res
();
_result
.
oplink
=
new
LINK4res
();
String
newName
=
new
String
(
_args
.
oplink
.
newname
.
value
.
value
.
value
);
try
{
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
,
context
.
getUser
().
getUID
(),
context
.
getUser
().
getGID
());
_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
.
status
=
nfsstat4
.
NFS4_OK
;
}
catch
(
ChimeraNFSException
hne
){
_result
.
oplink
.
status
=
hne
.
getStatus
();
}
catch
(
Exception
e
)
{
_log
.
error
(
"LINK: "
,
e
);
_result
.
oplink
.
status
=
nfsstat4
.
NFS4ERR_RESOURCE
;
}
return
_result
;
context
.
getFs
().
link
(
context
.
currentInode
(),
context
.
savedInode
(),
newName
,
context
.
getUser
().
getUID
(),
context
.
getUser
().
getGID
());
}
_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
.
status
=
nfsstat4
.
NFS4_OK
;
}
catch
(
ChimeraNFSException
hne
)
{
_result
.
oplink
.
status
=
hne
.
getStatus
();
}
catch
(
Exception
e
)
{
_log
.
error
(
"LINK: "
,
e
);
_result
.
oplink
.
status
=
nfsstat4
.
NFS4ERR_RESOURCE
;
}
return
_result
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment