[acls] setattr of owner and group attributes
This commit is contained in:
parent
f78cc24925
commit
71269e293c
2 changed files with 71 additions and 17 deletions
48
daemon/acl.c
48
daemon/acl.c
|
|
@ -569,6 +569,11 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, char *who_out, char *domain
|
||||||
status = GetLastError();
|
status = GetLastError();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
/* for ace mapping, we want to map owner's sid into "owner@"
|
||||||
|
* but for set_owner attribute we want to map owner into a user name
|
||||||
|
* same applies to group
|
||||||
|
*/
|
||||||
|
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(1, "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);
|
||||||
|
|
@ -583,6 +588,7 @@ static int map_nfs4ace_who(PSID sid, PSID owner_sid, char *who_out, char *domain
|
||||||
else
|
else
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
status = LookupAccountSid(NULL, sid, who, &size, tmp_buf,
|
status = LookupAccountSid(NULL, sid, who, &size, tmp_buf,
|
||||||
&tmp_size, &sid_type);
|
&tmp_size, &sid_type);
|
||||||
|
|
@ -708,17 +714,50 @@ static int handle_setacl(nfs41_upcall *upcall)
|
||||||
nfs41_file_info info;
|
nfs41_file_info info;
|
||||||
stateid_arg stateid;
|
stateid_arg stateid;
|
||||||
nfsacl41 nfs4_acl;
|
nfsacl41 nfs4_acl;
|
||||||
|
PSID sid = NULL;
|
||||||
|
BOOL sid_default;
|
||||||
|
|
||||||
ZeroMemory(&info, sizeof(info));
|
ZeroMemory(&info, sizeof(info));
|
||||||
|
|
||||||
if (args->query & OWNER_SECURITY_INFORMATION)
|
if (args->query & OWNER_SECURITY_INFORMATION) {
|
||||||
dprintf(1, "handle_setacl: OWNER_SECURITY_INFORMATION\n");
|
dprintf(1, "handle_setacl: OWNER_SECURITY_INFORMATION\n");
|
||||||
if (args->query & GROUP_SECURITY_INFORMATION)
|
status = GetSecurityDescriptorOwner(args->sec_desc, &sid, &sid_default);
|
||||||
|
if (!status) {
|
||||||
|
status = GetLastError();
|
||||||
|
eprintf("GetSecurityDescriptorOwner failed with %d\n", status);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
status = map_nfs4ace_who(sid, NULL, (char *)info.owner,
|
||||||
|
state->session->client->domain_name);
|
||||||
|
if (status)
|
||||||
|
goto out;
|
||||||
|
else {
|
||||||
|
info.owner_len = strlen((const char *)info.owner);
|
||||||
|
info.attrmask.arr[1] |= FATTR4_WORD1_OWNER;
|
||||||
|
info.attrmask.count = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (args->query & GROUP_SECURITY_INFORMATION) {
|
||||||
dprintf(1, "handle_setacl: GROUP_SECURITY_INFORMATION\n");
|
dprintf(1, "handle_setacl: GROUP_SECURITY_INFORMATION\n");
|
||||||
|
status = GetSecurityDescriptorGroup(args->sec_desc, &sid, &sid_default);
|
||||||
|
if (!status) {
|
||||||
|
status = GetLastError();
|
||||||
|
eprintf("GetSecurityDescriptorOwner failed with %d\n", status);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
status = map_nfs4ace_who(sid, NULL, (char *)info.owner_group,
|
||||||
|
state->session->client->domain_name);
|
||||||
|
if (status)
|
||||||
|
goto out;
|
||||||
|
else {
|
||||||
|
info.owner_group_len = strlen((const char *)info.owner_group);
|
||||||
|
info.attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
|
||||||
|
info.attrmask.count = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (args->query & DACL_SECURITY_INFORMATION) {
|
if (args->query & DACL_SECURITY_INFORMATION) {
|
||||||
BOOL dacl_present, dacl_default, sid_default;
|
BOOL dacl_present, dacl_default;
|
||||||
PACL acl;
|
PACL acl;
|
||||||
PSID sid;
|
|
||||||
dprintf(1, "handle_setacl: DACL_SECURITY_INFORMATION\n");
|
dprintf(1, "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);
|
||||||
|
|
@ -740,6 +779,7 @@ static int handle_setacl(nfs41_upcall *upcall)
|
||||||
else {
|
else {
|
||||||
info.acl = &nfs4_acl;
|
info.acl = &nfs4_acl;
|
||||||
info.attrmask.arr[0] |= FATTR4_WORD0_ACL;
|
info.attrmask.arr[0] |= FATTR4_WORD0_ACL;
|
||||||
|
if (!info.attrmask.count)
|
||||||
info.attrmask.count = 1;
|
info.attrmask.count = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2524,6 +2524,20 @@ static bool_t encode_file_attrs(
|
||||||
return FALSE;
|
return FALSE;
|
||||||
attrs->attrmask.arr[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
|
attrs->attrmask.arr[1] |= FATTR4_WORD1_TIME_MODIFY_SET;
|
||||||
}
|
}
|
||||||
|
if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER) {
|
||||||
|
unsigned char *ptr = &info->owner[0];
|
||||||
|
if (!xdr_bytes(&localxdr, &(char *)ptr, &info->owner_len,
|
||||||
|
NFS4_OPAQUE_LIMIT))
|
||||||
|
return FALSE;
|
||||||
|
attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER;
|
||||||
|
}
|
||||||
|
if (info->attrmask.arr[1] & FATTR4_WORD1_OWNER_GROUP) {
|
||||||
|
unsigned char *ptr = &info->owner_group[0];
|
||||||
|
if (!xdr_bytes(&localxdr, &(char *)ptr, &info->owner_group_len,
|
||||||
|
NFS4_OPAQUE_LIMIT))
|
||||||
|
return FALSE;
|
||||||
|
attrs->attrmask.arr[1] |= FATTR4_WORD1_OWNER_GROUP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (info->attrmask.count > 2) {
|
if (info->attrmask.count > 2) {
|
||||||
if (info->attrmask.arr[2] & FATTR4_WORD2_MODE_SET_MASKED) {
|
if (info->attrmask.arr[2] & FATTR4_WORD2_MODE_SET_MASKED) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue