[cosmetic] dprintf changes in acl, getattr, name_cache, namespace

This commit is contained in:
Olga Kornievskaia 2011-11-07 10:50:00 -05:00
parent 7f82baf13f
commit 9af1b590ff
4 changed files with 33 additions and 25 deletions

View file

@ -35,6 +35,8 @@
#include "nfs41_xdr.h" #include "nfs41_xdr.h"
//#define DEBUG_ACLS //#define DEBUG_ACLS
#define ACLLVL 2 /* dprintf level for acl logging */
static int parse_getacl(unsigned char *buffer, uint32_t length, static int parse_getacl(unsigned char *buffer, uint32_t length,
nfs41_upcall *upcall) nfs41_upcall *upcall)
{ {
@ -57,7 +59,7 @@ static int create_unknownsid(WELL_KNOWN_SID_TYPE type, PSID *sid,
*sid = NULL; *sid = NULL;
status = CreateWellKnownSid(type, NULL, *sid, sid_len); status = CreateWellKnownSid(type, NULL, *sid, sid_len);
dprintf(1, "create_unknownsid: CreateWellKnownSid type %d returned %d " dprintf(ACLLVL, "create_unknownsid: CreateWellKnownSid type %d returned %d "
"GetLastError %d sid len %d needed\n", type, status, "GetLastError %d sid len %d needed\n", type, status,
GetLastError(), *sid_len); GetLastError(), *sid_len);
if (status) if (status)
@ -98,7 +100,7 @@ static int map_name_2_sid(DWORD *sid_len, PSID *sid, LPCSTR name)
DWORD tmp = 0; DWORD tmp = 0;
status = LookupAccountName(NULL, name, NULL, sid_len, NULL, &tmp, &sid_type); status = LookupAccountName(NULL, name, NULL, sid_len, NULL, &tmp, &sid_type);
dprintf(1, "map_name_2_sid: LookupAccountName for %s returned %d " dprintf(ACLLVL, "map_name_2_sid: LookupAccountName for %s returned %d "
"GetLastError %d name len %d domain len %d\n", name, status, "GetLastError %d name len %d domain len %d\n", name, status,
GetLastError(), *sid_len, tmp); GetLastError(), *sid_len, tmp);
if (status) if (status)
@ -199,7 +201,7 @@ static int convert_nfs4acl_2_dacl(nfsacl41 *acl, int file_type,
} }
for (i = 0; i < acl->count; i++) { for (i = 0; i < acl->count; i++) {
convert_nfs4name_2_user_domain(acl->aces[i].who, &domain); convert_nfs4name_2_user_domain(acl->aces[i].who, &domain);
dprintf(1, "handle_getacl: for user=%s domain=%s\n", dprintf(ACLLVL, "handle_getacl: for user=%s domain=%s\n",
acl->aces[i].who, domain?domain:"<null>"); acl->aces[i].who, domain?domain:"<null>");
status = check_4_special_identifiers(acl->aces[i].who, &sids[i], status = check_4_special_identifiers(acl->aces[i].who, &sids[i],
&sid_len, &flag); &sid_len, &flag);
@ -227,7 +229,7 @@ static int convert_nfs4acl_2_dacl(nfsacl41 *acl, int file_type,
for (i = 0; i < acl->count; i++) { for (i = 0; i < acl->count; i++) {
// nfs4 acemask should be exactly the same as file access mask // nfs4 acemask should be exactly the same as file access mask
mask = acl->aces[i].acemask; mask = acl->aces[i].acemask;
dprintf(1, "access mask %x ace type %s\n", mask, dprintf(ACLLVL, "access mask %x ace type %s\n", mask,
acl->aces[i].acetype?"DENIED ACE":"ALLOWED ACE"); acl->aces[i].acetype?"DENIED ACE":"ALLOWED ACE");
if (acl->aces[i].acetype == ACE4_ACCESS_ALLOWED_ACE_TYPE) { if (acl->aces[i].acetype == ACE4_ACCESS_ALLOWED_ACE_TYPE) {
status = AddAccessAllowedAce(dacl, ACL_REVISION, mask, sids[i]); status = AddAccessAllowedAce(dacl, ACL_REVISION, mask, sids[i]);
@ -319,7 +321,7 @@ static int handle_getacl(nfs41_upcall *upcall)
if (args->query & OWNER_SECURITY_INFORMATION) { if (args->query & OWNER_SECURITY_INFORMATION) {
// parse user@domain. currently ignoring domain part XX // parse user@domain. currently ignoring domain part XX
convert_nfs4name_2_user_domain(info.owner, &domain); convert_nfs4name_2_user_domain(info.owner, &domain);
dprintf(1, "handle_getacl: OWNER_SECURITY_INFORMATION: for user=%s " dprintf(ACLLVL, "handle_getacl: OWNER_SECURITY_INFORMATION: for user=%s "
"domain=%s\n", info.owner, domain?domain:"<null>"); "domain=%s\n", info.owner, domain?domain:"<null>");
sid_len = 0; sid_len = 0;
status = map_name_2_sid(&sid_len, &osid, info.owner); status = map_name_2_sid(&sid_len, &osid, info.owner);
@ -335,7 +337,7 @@ static int handle_getacl(nfs41_upcall *upcall)
} }
if (args->query & GROUP_SECURITY_INFORMATION) { if (args->query & GROUP_SECURITY_INFORMATION) {
convert_nfs4name_2_user_domain(info.owner_group, &domain); convert_nfs4name_2_user_domain(info.owner_group, &domain);
dprintf(1, "handle_getacl: GROUP_SECURITY_INFORMATION: for %s " dprintf(ACLLVL, "handle_getacl: GROUP_SECURITY_INFORMATION: for %s "
"domain=%s\n", info.owner_group, domain?domain:"<null>"); "domain=%s\n", info.owner_group, domain?domain:"<null>");
sid_len = 0; sid_len = 0;
status = map_name_2_sid(&sid_len, &gsid, info.owner_group); status = map_name_2_sid(&sid_len, &gsid, info.owner_group);
@ -350,7 +352,7 @@ static int handle_getacl(nfs41_upcall *upcall)
} }
} }
if (args->query & DACL_SECURITY_INFORMATION) { if (args->query & DACL_SECURITY_INFORMATION) {
dprintf(1, "handle_getacl: DACL_SECURITY_INFORMATION\n"); dprintf(ACLLVL, "handle_getacl: DACL_SECURITY_INFORMATION\n");
status = convert_nfs4acl_2_dacl(info.acl, state->type, &dacl, &sids); status = convert_nfs4acl_2_dacl(info.acl, state->type, &dacl, &sids);
if (status) if (status)
goto out; goto out;
@ -449,7 +451,7 @@ static int is_well_known_sid(PSID sid, char *who)
status = IsWellKnownSid(sid, (WELL_KNOWN_SID_TYPE)i); status = IsWellKnownSid(sid, (WELL_KNOWN_SID_TYPE)i);
if (!status) continue; if (!status) continue;
else { else {
dprintf(1, "WELL_KNOWN_SID_TYPE %d\n", i); dprintf(ACLLVL, "WELL_KNOWN_SID_TYPE %d\n", i);
switch((WELL_KNOWN_SID_TYPE)i) { switch((WELL_KNOWN_SID_TYPE)i) {
case WinCreatorOwnerSid: case WinCreatorOwnerSid:
memcpy(who, ACE4_OWNER, strlen(ACE4_OWNER)+1); memcpy(who, ACE4_OWNER, strlen(ACE4_OWNER)+1);
@ -506,13 +508,13 @@ static void map_aceflags(BYTE win_aceflags, uint32_t *nfs4_aceflags)
*nfs4_aceflags |= ACE4_INHERIT_ONLY_ACE; *nfs4_aceflags |= ACE4_INHERIT_ONLY_ACE;
if (win_aceflags & INHERITED_ACE) if (win_aceflags & INHERITED_ACE)
*nfs4_aceflags |= ACE4_INHERITED_ACE; *nfs4_aceflags |= ACE4_INHERITED_ACE;
dprintf(1, "ACE FLAGS: %x nfs4 aceflags %x\n", dprintf(ACLLVL, "ACE FLAGS: %x nfs4 aceflags %x\n",
win_aceflags, *nfs4_aceflags); win_aceflags, *nfs4_aceflags);
} }
static void map_acemask(ACCESS_MASK mask, int file_type, uint32_t *nfs4_mask) static void map_acemask(ACCESS_MASK mask, int file_type, uint32_t *nfs4_mask)
{ {
dprintf(1, "ACE MASK: %x\n", mask); dprintf(ACLLVL, "ACE MASK: %x\n", mask);
print_windows_access_mask(0, mask); print_windows_access_mask(0, mask);
/* check if any GENERIC bits set */ /* check if any GENERIC bits set */
if (mask & 0xf000000) { if (mask & 0xf000000) {
@ -549,14 +551,14 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
status = 0; status = 0;
if (owner_sid) { if (owner_sid) {
if (EqualSid(sid, owner_sid)) { if (EqualSid(sid, owner_sid)) {
dprintf(1, "map_nfs4ace_who: this is owner's sid\n"); dprintf(ACLLVL, "map_nfs4ace_who: this is owner's sid\n");
memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1); memcpy(who_out, ACE4_OWNER, strlen(ACE4_OWNER)+1);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
} }
if (group_sid) { if (group_sid) {
if (EqualSid(sid, group_sid)) { if (EqualSid(sid, group_sid)) {
dprintf(1, "map_nfs4ace_who: this is group's sid\n"); dprintf(ACLLVL, "map_nfs4ace_who: this is group's sid\n");
memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1); memcpy(who_out, ACE4_GROUP, strlen(ACE4_GROUP)+1);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
@ -573,7 +575,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
status = LookupAccountSid(NULL, sid, who, &size, tmp_buf, status = LookupAccountSid(NULL, sid, who, &size, tmp_buf,
&tmp_size, &sid_type); &tmp_size, &sid_type);
dprintf(1, "map_nfs4ace_who: LookupAccountSid returned %d GetLastError " dprintf(ACLLVL, "map_nfs4ace_who: LookupAccountSid returned %d GetLastError "
"%d name len %d domain len %d\n", status, GetLastError(), "%d name len %d domain len %d\n", status, GetLastError(),
size, tmp_size); size, tmp_size);
if (status) if (status)
@ -601,7 +603,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, PSID group_sid, char *who_o
add_domain: add_domain:
memcpy(who_out+size, "@", sizeof(char)); memcpy(who_out+size, "@", sizeof(char));
memcpy(who_out+size+1, domain, strlen(domain)+1); memcpy(who_out+size+1, domain, strlen(domain)+1);
dprintf(1, "map_nfs4ace_who: who=%s\n", who_out); dprintf(ACLLVL, "map_nfs4ace_who: who=%s\n", who_out);
if (who) free(who); if (who) free(who);
status = ERROR_SUCCESS; status = ERROR_SUCCESS;
out: out:
@ -616,7 +618,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
{ {
int status; int status;
if (acl == NULL) { if (acl == NULL) {
dprintf(1, "this is a NULL dacl: all access to an object\n"); dprintf(ACLLVL, "this is a NULL dacl: all access to an object\n");
nfs4_acl->count = 1; nfs4_acl->count = 1;
nfs4_acl->aces = calloc(1, sizeof(nfsace4)); nfs4_acl->aces = calloc(1, sizeof(nfsace4));
if (nfs4_acl->aces == NULL) { if (nfs4_acl->aces == NULL) {
@ -636,7 +638,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
PACE_HEADER ace; PACE_HEADER ace;
PBYTE tmp_pointer; PBYTE tmp_pointer;
dprintf(1, "NON-NULL dacl with %d ACEs\n", acl->AceCount); dprintf(ACLLVL, "NON-NULL dacl with %d ACEs\n", acl->AceCount);
print_hexbuf_no_asci(3, (unsigned char *)"ACL\n", print_hexbuf_no_asci(3, (unsigned char *)"ACL\n",
(unsigned char *)acl, acl->AclSize); (unsigned char *)acl, acl->AclSize);
nfs4_acl->count = acl->AceCount; nfs4_acl->count = acl->AceCount;
@ -656,7 +658,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
tmp_pointer = (PBYTE)ace; tmp_pointer = (PBYTE)ace;
print_hexbuf_no_asci(3, (unsigned char *)"ACE\n", print_hexbuf_no_asci(3, (unsigned char *)"ACE\n",
(unsigned char *)ace, ace->AceSize); (unsigned char *)ace, ace->AceSize);
dprintf(1, "ACE TYPE: %x\n", ace->AceType); dprintf(ACLLVL, "ACE TYPE: %x\n", ace->AceType);
if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE) if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE)
nfs4_acl->aces[i].acetype = ACE4_ACCESS_ALLOWED_ACE_TYPE; nfs4_acl->aces[i].acetype = ACE4_ACCESS_ALLOWED_ACE_TYPE;
else if (ace->AceType == ACCESS_DENIED_ACE_TYPE) else if (ace->AceType == ACCESS_DENIED_ACE_TYPE)
@ -700,7 +702,7 @@ static int handle_setacl(nfs41_upcall *upcall)
if (args->query & OWNER_SECURITY_INFORMATION) { if (args->query & OWNER_SECURITY_INFORMATION) {
char owner[NFS4_OPAQUE_LIMIT]; char owner[NFS4_OPAQUE_LIMIT];
dprintf(1, "handle_setacl: OWNER_SECURITY_INFORMATION\n"); dprintf(ACLLVL, "handle_setacl: OWNER_SECURITY_INFORMATION\n");
status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default); status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
if (!status) { if (!status) {
status = GetLastError(); status = GetLastError();
@ -719,7 +721,7 @@ static int handle_setacl(nfs41_upcall *upcall)
} }
if (args->query & GROUP_SECURITY_INFORMATION) { if (args->query & GROUP_SECURITY_INFORMATION) {
char group[NFS4_OPAQUE_LIMIT]; char group[NFS4_OPAQUE_LIMIT];
dprintf(1, "handle_setacl: GROUP_SECURITY_INFORMATION\n"); dprintf(ACLLVL, "handle_setacl: GROUP_SECURITY_INFORMATION\n");
status = GetSecurityDescriptorGroup(args->sec_desc, &sid, &sid_default); status = GetSecurityDescriptorGroup(args->sec_desc, &sid, &sid_default);
if (!status) { if (!status) {
status = GetLastError(); status = GetLastError();
@ -739,7 +741,7 @@ static int handle_setacl(nfs41_upcall *upcall)
if (args->query & DACL_SECURITY_INFORMATION) { if (args->query & DACL_SECURITY_INFORMATION) {
BOOL dacl_present, dacl_default; BOOL dacl_present, dacl_default;
PACL acl; PACL acl;
dprintf(1, "handle_setacl: DACL_SECURITY_INFORMATION\n"); dprintf(ACLLVL, "handle_setacl: DACL_SECURITY_INFORMATION\n");
status = GetSecurityDescriptorDacl(args->sec_desc, &dacl_present, status = GetSecurityDescriptorDacl(args->sec_desc, &dacl_present,
&acl, &dacl_default); &acl, &dacl_default);
if (!status) { if (!status) {
@ -778,7 +780,7 @@ static int handle_setacl(nfs41_upcall *upcall)
nfs41_open_stateid_arg(state, &stateid); nfs41_open_stateid_arg(state, &stateid);
status = nfs41_setattr(state->session, &state->file, &stateid, &info); status = nfs41_setattr(state->session, &state->file, &stateid, &info);
if (status) { if (status) {
dprintf(1, "handle_setacl: nfs41_setattr() failed with error %s.\n", dprintf(ACLLVL, "handle_setacl: nfs41_setattr() failed with error %s.\n",
nfs_error_string(status)); nfs_error_string(status));
status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED); status = nfs_to_windows_error(status, ERROR_NOT_SUPPORTED);
} }

View file

@ -73,8 +73,9 @@ static int parse_getattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len)); status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
if (status) goto out; if (status) goto out;
dprintf(1, "parsing NFS41_FILE_QUERY: info_class=%d buf_len=%d\n", dprintf(1, "parsing NFS41_FILE_QUERY: info_class=%d buf_len=%d file=%.*s\n",
args->query_class, args->buf_len); args->query_class, args->buf_len, upcall->state_ref->path.len,
upcall->state_ref->path.path);
out: out:
return status; return status;
} }

View file

@ -1086,6 +1086,7 @@ out_unlock:
out_attributes: out_attributes:
/* in the presence of other links, we need to update numlinks /* in the presence of other links, we need to update numlinks
* regardless of a failure to find the target entry */ * regardless of a failure to find the target entry */
dprintf(NCLVL1, "nfs41_name_cache_remove: need to find attributes for %s\n", path);
attributes = attr_cache_search(&cache->attributes, fileid); attributes = attr_cache_search(&cache->attributes, fileid);
if (attributes) if (attributes)
attributes->numlinks--; attributes->numlinks--;
@ -1121,6 +1122,8 @@ int nfs41_name_cache_rename(
/* we can't create the dst entry without a parent */ /* we can't create the dst entry without a parent */
if (status || dst_parent->attributes == NULL) { if (status || dst_parent->attributes == NULL) {
/* if src exists, make it negative */ /* if src exists, make it negative */
dprintf(NCLVL1, "nfs41_name_cache_rename: adding negative cache "
"entry for %.*s\n", src_name->len, src_name->name);
status = name_cache_lookup(cache, 0, src_path, status = name_cache_lookup(cache, 0, src_path,
src_name->name + src_name->len, NULL, NULL, &src, NULL); src_name->name + src_name->len, NULL, NULL, &src, NULL);
if (status == NO_ERROR) { if (status == NO_ERROR) {
@ -1138,6 +1141,8 @@ int nfs41_name_cache_rename(
if (status || src->attributes == NULL) { if (status || src->attributes == NULL) {
/* remove dst if it exists */ /* remove dst if it exists */
struct name_cache_entry *dst; struct name_cache_entry *dst;
dprintf(NCLVL1, "nfs41_name_cache_rename: removing negative cache "
"entry for %.*s\n", dst_name->len, dst_name->name);
dst = name_cache_search(cache, dst_parent, dst_name); dst = name_cache_search(cache, dst_parent, dst_name);
if (dst) name_cache_unlink(cache, dst); if (dst) name_cache_unlink(cache, dst);
goto out_unlock; goto out_unlock;

View file

@ -99,7 +99,7 @@ void nfs41_root_ref(
{ {
const LONG count = InterlockedIncrement(&root->ref_count); const LONG count = InterlockedIncrement(&root->ref_count);
dprintf(2, "nfs41_root_ref() count %d\n", count); dprintf(NSLVL, "nfs41_root_ref() count %d\n", count);
} }
void nfs41_root_deref( void nfs41_root_deref(
@ -107,7 +107,7 @@ void nfs41_root_deref(
{ {
const LONG count = InterlockedDecrement(&root->ref_count); const LONG count = InterlockedDecrement(&root->ref_count);
dprintf(2, "nfs41_root_deref() count %d\n", count); dprintf(NSLVL, "nfs41_root_deref() count %d\n", count);
if (count == 0) if (count == 0)
root_free(root); root_free(root);
} }