nfs4: Check if user is allowed to use open state
This commit is contained in:
@@ -805,13 +805,20 @@ Inode::ReturnDelegation(bool truncate)
|
||||
|
||||
MutexLocker stateLocker(fStateLock);
|
||||
fOpenState->fDelegation = NULL;
|
||||
ReleaseOpenState();
|
||||
|
||||
delete fDelegation;
|
||||
fDelegation = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Inode::ReleaseOpenState()
|
||||
{
|
||||
if (fOpenState->ReleaseReference() == 1) {
|
||||
fFileSystem->RemoveOpenFile(fOpenState);
|
||||
fOpenState = NULL;
|
||||
}
|
||||
|
||||
delete fDelegation;
|
||||
fDelegation = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -93,6 +93,8 @@ public:
|
||||
protected:
|
||||
Inode();
|
||||
|
||||
void ReleaseOpenState();
|
||||
|
||||
status_t CreateState(const char* name, int mode,
|
||||
int perms, OpenState* state,
|
||||
OpenDelegationData* data);
|
||||
|
||||
@@ -130,13 +130,24 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
||||
status_t result = OpenFile(fOpenState, O_RDWR, &data);
|
||||
if (result != B_OK) {
|
||||
locker.Lock();
|
||||
if (fOpenState->ReleaseReference() == 1) {
|
||||
fFileSystem->RemoveOpenFile(fOpenState);
|
||||
fOpenState = NULL;
|
||||
}
|
||||
ReleaseOpenState();
|
||||
return result;
|
||||
}
|
||||
fOpenState->fMode = O_RDWR;
|
||||
} else {
|
||||
int newMode = mode & O_RWMASK;
|
||||
uint32 allowed = 0;
|
||||
if (newMode == O_RDWR || newMode == O_RDONLY)
|
||||
allowed |= R_OK;
|
||||
if (newMode == O_RDWR || newMode == O_WRONLY)
|
||||
allowed |= W_OK;
|
||||
|
||||
status_t result = Access(allowed);
|
||||
if (result != B_OK) {
|
||||
locker.Lock();
|
||||
ReleaseOpenState();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,12 +184,7 @@ Inode::Close(OpenFileCookie* cookie)
|
||||
SyncAndCommit();
|
||||
|
||||
MutexLocker _(fStateLock);
|
||||
if (cookie->fOpenState != NULL) {
|
||||
if (cookie->fOpenState->ReleaseReference() == 1) {
|
||||
fFileSystem->RemoveOpenFile(fOpenState);
|
||||
fOpenState = NULL;
|
||||
}
|
||||
}
|
||||
ReleaseOpenState();
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user