deny setattr for size if not opened for write

proposes an alternate solution for attempts to set file size without an open sta
teid.  instead of acquiring one by sending OPEN, fail the request with ACCESS_DE
NIED

according the MS File System Algorithms documentation for setting FileAllocation
Information and FileEndOfFileInformation [http://msdn.microsoft.com/en-us/librar
y/ff469355%28v=PROT.10%29.aspx]:
"If Open.GrantedAccess does not contain FILE_WRITE_DATA, the operation MUST be f
ailed with STATUS_ACCESS_DENIED"

-removes open_owner_id, access_mask, access_mode from setattr upcall arguments
-moves map_access_2_allowdeny() back to open.c as a static function, since handl
e_setattr() was its only other call site
This commit is contained in:
Olga Kornievskaia 2011-06-27 12:01:24 -04:00 committed by unknown
parent 9f2587c3b3
commit 2db91a3001
6 changed files with 53 additions and 104 deletions

View file

@ -52,19 +52,11 @@ static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
}
status = safe_read(&buffer, &length, args->buf, args->buf_len);
if (status) goto out_free;
status = safe_read(&buffer, &length, &args->open_owner_id, sizeof(ULONG));
if (status) goto out_free;
status = safe_read(&buffer, &length, &args->access_mask, sizeof(ULONG));
if (status) goto out_free;
status = safe_read(&buffer, &length, &args->access_mode, sizeof(ULONG));
if (status) goto out_free;
args->root = upcall->root_ref;
args->state = upcall->state_ref;
dprintf(1, "parsing NFS41_FILE_SET: filename='%s' info_class=%d "
"buf_len=%d\nopen_owner_id=%d access_mask=%x access_mode=%x\n",
args->path, args->set_class, args->buf_len, args->open_owner_id,
args->access_mask, args->access_mode);
"buf_len=%d\n", args->path, args->set_class, args->buf_len);
out:
return status;
out_free:
@ -467,29 +459,6 @@ static int handle_setattr(nfs41_upcall *upcall)
nfs41_open_state *state = upcall->state_ref;
int status;
switch (args->set_class) {
case FileAllocationInformation:
case FileEndOfFileInformation:
if (!state->do_close) {
// get a stateid
StringCchPrintfA((LPSTR)state->owner.owner, NFS4_OPAQUE_LIMIT,
"%u", args->open_owner_id);
state->owner.owner_len = (uint32_t)strlen(
(const char*)state->owner.owner);
map_access_2_allowdeny(args->access_mask, args->access_mode,
&state->share_access, &state->share_deny);
status = nfs41_open(state->session, state->share_access,
state->share_deny, OPEN4_NOCREATE, 0, 0, TRUE, state, NULL);
if (status) {
dprintf(1, "nfs41_open() failed with %s\n", nfs_error_string(status));
status = nfs_to_windows_error(status, ERROR_FILE_NOT_FOUND);
goto out;
} else
client_state_add(state);
state->do_close = 1;
}
}
switch (args->set_class) {
case FileBasicInformation:
status = handle_nfs41_setattr(args);
@ -513,7 +482,7 @@ static int handle_setattr(nfs41_upcall *upcall)
status = ERROR_NOT_SUPPORTED;
break;
}
out:
free(args->buf);
return status;
}