Skip to content

Commit

Permalink
pysmbd: fix use of sysacl API
Browse files Browse the repository at this point in the history
Fix pysmbd to use the sysacl (POSIX ACL support) as intended, and
not assume too much about the inner structure and implementation
of the permissions in the sysacl API.

This will allow the inner structure to change in a following commit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13176

Signed-off-by: Uri Simchoni <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
urisimchoni authored and jrasamba committed Dec 21, 2017
1 parent 6a6f095 commit d6f5ee6
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions source3/smbd/pysmbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,39 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx,
return status;
}

static int set_acl_entry_perms(SMB_ACL_ENTRY_T entry, mode_t perm_mask)
{
SMB_ACL_PERMSET_T perms = NULL;

if (sys_acl_get_permset(entry, &perms) != 0) {
return -1;
}

if (sys_acl_clear_perms(perms) != 0) {
return -1;
}

if ((perm_mask & SMB_ACL_READ) != 0 &&
sys_acl_add_perm(perms, SMB_ACL_READ) != 0) {
return -1;
}

if ((perm_mask & SMB_ACL_WRITE) != 0 &&
sys_acl_add_perm(perms, SMB_ACL_WRITE) != 0) {
return -1;
}

if ((perm_mask & SMB_ACL_EXECUTE) != 0 &&
sys_acl_add_perm(perms, SMB_ACL_EXECUTE) != 0) {
return -1;
}

if (sys_acl_set_permset(entry, perms) != 0) {
return -1;
}

return 0;
}

static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
{
Expand Down Expand Up @@ -261,7 +294,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
return NULL;
}

if (sys_acl_set_permset(entry, &mode_user) != 0) {
if (set_acl_entry_perms(entry, mode_user) != 0) {
TALLOC_FREE(frame);
return NULL;
}
Expand All @@ -276,7 +309,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
return NULL;
}

if (sys_acl_set_permset(entry, &mode_group) != 0) {
if (set_acl_entry_perms(entry, mode_group) != 0) {
TALLOC_FREE(frame);
return NULL;
}
Expand All @@ -291,7 +324,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
return NULL;
}

if (sys_acl_set_permset(entry, &mode_other) != 0) {
if (set_acl_entry_perms(entry, mode_other) != 0) {
TALLOC_FREE(frame);
return NULL;
}
Expand All @@ -312,7 +345,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
return NULL;
}

if (sys_acl_set_permset(entry, &mode_group) != 0) {
if (set_acl_entry_perms(entry, mode_group) != 0) {
TALLOC_FREE(frame);
return NULL;
}
Expand All @@ -328,7 +361,7 @@ static SMB_ACL_T make_simple_acl(gid_t gid, mode_t chmod_mode)
return NULL;
}

if (sys_acl_set_permset(entry, &mode) != 0) {
if (set_acl_entry_perms(entry, mode) != 0) {
TALLOC_FREE(frame);
return NULL;
}
Expand Down

0 comments on commit d6f5ee6

Please sign in to comment.