summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-12-01 19:51:27 +0100
committerGünther Deschner <gd@samba.org>2008-12-01 21:56:28 +0100
commit24fec0a8d727a51ffe214af5ee62bb7a730ce539 (patch)
treef595e2b070b269bcaff32928dc4fbc9891d34964 /source3
parentc7c591c19fc4d17a900a0f15df9973b801c076c3 (diff)
downloadsamba-24fec0a8d727a51ffe214af5ee62bb7a730ce539.tar.gz
samba-24fec0a8d727a51ffe214af5ee62bb7a730ce539.tar.bz2
samba-24fec0a8d727a51ffe214af5ee62bb7a730ce539.zip
s3-samr: avoid code duplication for identical code in _samr_Connect2, 4 and 5.
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/rpc_server/srv_samr_nt.c93
1 files changed, 15 insertions, 78 deletions
diff --git a/source3/rpc_server/srv_samr_nt.c b/source3/rpc_server/srv_samr_nt.c
index 11aa4e3609..4b913bace1 100644
--- a/source3/rpc_server/srv_samr_nt.c
+++ b/source3/rpc_server/srv_samr_nt.c
@@ -3535,48 +3535,13 @@ NTSTATUS _samr_Connect2(pipes_struct *p,
NTSTATUS _samr_Connect4(pipes_struct *p,
struct samr_Connect4 *r)
{
- struct samr_info *info = NULL;
- SEC_DESC *psd = NULL;
- uint32 acc_granted;
- uint32 des_access = r->in.access_mask;
- NTSTATUS nt_status;
- size_t sd_size;
-
-
- DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
-
- /* Access check */
-
- if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_Connect4\n"));
- return NT_STATUS_ACCESS_DENIED;
- }
-
- map_max_allowed_access(p->server_info->ptok, &des_access);
-
- make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
- se_map_generic(&des_access, &sam_generic_mapping);
+ struct samr_Connect2 c;
- nt_status = access_check_samr_object(psd, p->server_info->ptok,
- NULL, 0, des_access, &acc_granted, "_samr_Connect4");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
-
- /* associate the user's SID and access granted with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
- return NT_STATUS_NO_MEMORY;
-
- info->acc_granted = acc_granted;
- info->status = r->in.access_mask; /* ??? */
-
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-
- DEBUG(5,("_samr_Connect4: %d\n", __LINE__));
+ c.in.system_name = r->in.system_name;
+ c.in.access_mask = r->in.access_mask;
+ c.out.connect_handle = r->out.connect_handle;
- return NT_STATUS_OK;
+ return _samr_Connect2(p, &c);
}
/*******************************************************************
@@ -3586,50 +3551,22 @@ NTSTATUS _samr_Connect4(pipes_struct *p,
NTSTATUS _samr_Connect5(pipes_struct *p,
struct samr_Connect5 *r)
{
- struct samr_info *info = NULL;
- SEC_DESC *psd = NULL;
- uint32 acc_granted;
- uint32 des_access = r->in.access_mask;
- NTSTATUS nt_status;
- size_t sd_size;
+ NTSTATUS status;
+ struct samr_Connect2 c;
struct samr_ConnectInfo1 info1;
- DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
+ info1.client_version = SAMR_CONNECT_AFTER_W2K;
+ info1.unknown2 = 0;
- /* Access check */
+ c.in.system_name = r->in.system_name;
+ c.in.access_mask = r->in.access_mask;
+ c.out.connect_handle = r->out.connect_handle;
- if (!pipe_access_check(p)) {
- DEBUG(3, ("access denied to samr_Connect5\n"));
- return NT_STATUS_ACCESS_DENIED;
+ status = _samr_Connect2(p, &c);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
}
- map_max_allowed_access(p->server_info->ptok, &des_access);
-
- make_samr_object_sd(p->mem_ctx, &psd, &sd_size, &sam_generic_mapping, NULL, 0);
- se_map_generic(&des_access, &sam_generic_mapping);
-
- nt_status = access_check_samr_object(psd, p->server_info->ptok,
- NULL, 0, des_access, &acc_granted, "_samr_Connect5");
-
- if ( !NT_STATUS_IS_OK(nt_status) )
- return nt_status;
-
- /* associate the user's SID and access granted with the new handle. */
- if ((info = get_samr_info_by_sid(NULL)) == NULL)
- return NT_STATUS_NO_MEMORY;
-
- info->acc_granted = acc_granted;
- info->status = r->in.access_mask; /* ??? */
-
- /* get a (unique) handle. open a policy on it. */
- if (!create_policy_hnd(p, r->out.connect_handle, free_samr_info, (void *)info))
- return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-
- DEBUG(5,("_samr_Connect5: %d\n", __LINE__));
-
- info1.client_version = SAMR_CONNECT_AFTER_W2K;
- info1.unknown2 = 0;
-
*r->out.level_out = 1;
r->out.info_out->info1 = info1;