#include "librpc/gen_ndr/ndr_epmapper_scompat.h"
#include "rpc_server/rpc_server.h"
+/* handle types for this module */
+enum handle_types {HTYPE_LOOKUP};
+
typedef uint32_t error_status_t;
/* An endpoint combined with an interface description */
goto done;
}
- ok = create_policy_hnd(p, r->out.entry_handle, eps);
+ ok = create_policy_hnd(p, r->out.entry_handle, HTYPE_LOOKUP, eps);
if (!ok) {
rc = EPMAPPER_STATUS_NO_MEMORY;
goto done;
}
/* end of "some algorithm" */
- ok = create_policy_hnd(p, r->out.entry_handle, eps);
+ ok = create_policy_hnd(p, r->out.entry_handle, HTYPE_LOOKUP, eps);
if (!ok) {
rc = EPMAPPER_STATUS_NO_MEMORY;
goto done;
/* create the policy handle */
- if ( !create_policy_hnd( p, hnd, elog ) ) {
+ if ( !create_policy_hnd( p, hnd, 0, elog ) ) {
TALLOC_FREE(elog);
return NT_STATUS_NO_MEMORY;
}
}
}
- if (!create_policy_hnd(p, handle, info)) {
+ if (!create_policy_hnd(p, handle, type, info)) {
talloc_free(info);
ZERO_STRUCTP(handle);
return NT_STATUS_NO_MEMORY;
return NT_STATUS_UNSUCCESSFUL;
}
- if (!create_policy_hnd(p, handle, mds_ctx)) {
+ if (!create_policy_hnd(p, handle, 0, mds_ctx)) {
talloc_free(mds_ctx);
ZERO_STRUCTP(handle);
return NT_STATUS_NO_MEMORY;
data_ptr is TALLOC_FREE()'ed
****************************************************************************/
-static struct dcesrv_handle_old *create_rpc_handle_internal(struct pipes_struct *p,
- struct policy_handle *hnd, void *data_ptr)
+static struct dcesrv_handle_old *create_rpc_handle_internal(
+ struct pipes_struct *p,
+ struct policy_handle *hnd,
+ uint8_t handle_type,
+ void *data_ptr)
{
struct dcesrv_handle_old *rpc_hnd = NULL;
static uint32_t pol_hnd_low = 0;
pol_hnd_high++;
}
- /* first bit must be null */
- SIVAL(&rpc_hnd->wire_handle.handle_type, 0 , 0);
+ SIVAL(&rpc_hnd->wire_handle.handle_type, 0 , handle_type);
/* second bit is incrementing */
SIVAL(&rpc_hnd->wire_handle.uuid.time_low, 0 , pol_hnd_low);
return rpc_hnd;
}
-bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd,
- void *data_ptr)
+bool create_policy_hnd(struct pipes_struct *p,
+ struct policy_handle *hnd,
+ uint8_t handle_type,
+ void *data_ptr)
{
struct dcesrv_handle_old *rpc_hnd = NULL;
- rpc_hnd = create_rpc_handle_internal(p, hnd, data_ptr);
+ rpc_hnd = create_rpc_handle_internal(p, hnd, handle_type, data_ptr);
if (rpc_hnd == NULL) {
return false;
}
return True;
}
-void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
- uint32_t access_granted, size_t data_size,
- const char *type, NTSTATUS *pstatus)
+void *_policy_handle_create(struct pipes_struct *p,
+ struct policy_handle *hnd,
+ uint8_t handle_type,
+ uint32_t access_granted,
+ size_t data_size,
+ const char *type,
+ NTSTATUS *pstatus)
{
struct dcesrv_handle_old *rpc_hnd = NULL;
void *data;
}
talloc_set_name_const(data, type);
- rpc_hnd = create_rpc_handle_internal(p, hnd, data);
+ rpc_hnd = create_rpc_handle_internal(p, hnd, handle_type, data);
if (rpc_hnd == NULL) {
TALLOC_FREE(data);
*pstatus = NT_STATUS_NO_MEMORY;
size_t num_pipe_handles(struct pipes_struct *p);
bool init_pipe_handles(struct pipes_struct *p, const struct ndr_syntax_id *syntax);
-bool create_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd, void *data_ptr);
+bool create_policy_hnd(struct pipes_struct *p,
+ struct policy_handle *hnd,
+ uint8_t handle_type,
+ void *data_ptr);
bool find_policy_by_hnd(struct pipes_struct *p, const struct policy_handle *hnd,
void **data_p);
bool close_policy_hnd(struct pipes_struct *p, struct policy_handle *hnd);
void close_policy_by_pipe(struct pipes_struct *p);
bool pipe_access_check(struct pipes_struct *p);
-void *_policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd,
- uint32_t access_granted, size_t data_size,
- const char *type, NTSTATUS *pstatus);
-#define policy_handle_create(_p, _hnd, _access, _type, _pstatus) \
- (_type *)_policy_handle_create((_p), (_hnd), (_access), sizeof(_type), #_type, \
+void *_policy_handle_create(struct pipes_struct *p,
+ struct policy_handle *hnd,
+ uint8_t handle_type,
+ uint32_t access_granted,
+ size_t data_size,
+ const char *type,
+ NTSTATUS *pstatus);
+#define policy_handle_create(_p, _hnd, _hnd_type, _access, _type, _pstatus) \
+ (_type *)_policy_handle_create((_p), (_hnd), (_hnd_type), (_access), sizeof(_type), #_type, \
(_pstatus))
void *_policy_handle_find(struct pipes_struct *p,
#define MAX_SAM_ENTRIES_W2K 0x400 /* 1024 */
#define MAX_SAM_ENTRIES_W95 50
+enum samr_handle {
+ SAMR_HANDLE_CONNECT,
+ SAMR_HANDLE_DOMAIN,
+ SAMR_HANDLE_USER,
+ SAMR_HANDLE_GROUP,
+ SAMR_HANDLE_ALIAS
+};
+
struct samr_connect_info {
uint8_t dummy;
};
return NT_STATUS_NO_SUCH_DOMAIN;
}
- dinfo = policy_handle_create(p, r->out.domain_handle, acc_granted,
- struct samr_domain_info, &status);
+ dinfo = policy_handle_create(p,
+ r->out.domain_handle,
+ SAMR_HANDLE_DOMAIN,
+ acc_granted,
+ struct samr_domain_info,
+ &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
/* If we did the rid admins hack above, allow access. */
acc_granted |= extra_access;
- uinfo = policy_handle_create(p, r->out.user_handle, acc_granted,
- struct samr_user_info, &nt_status);
+ uinfo = policy_handle_create(p,
+ r->out.user_handle,
+ SAMR_HANDLE_USER,
+ acc_granted,
+ struct samr_user_info,
+ &nt_status);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
return nt_status;
}
- uinfo = policy_handle_create(p, r->out.user_handle, acc_granted,
- struct samr_user_info, &nt_status);
+ uinfo = policy_handle_create(p,
+ r->out.user_handle,
+ SAMR_HANDLE_USER,
+ acc_granted,
+ struct samr_user_info,
+ &nt_status);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
/* set up the SAMR connect_anon response */
- (void)policy_handle_create(p, &hnd, acc_granted,
- struct samr_connect_info,
- &status);
+ (void)policy_handle_create(p,
+ &hnd,
+ SAMR_HANDLE_CONNECT,
+ acc_granted,
+ struct samr_connect_info,
+ &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
if ( !NT_STATUS_IS_OK(nt_status) )
return nt_status;
- (void)policy_handle_create(p, &hnd, acc_granted,
- struct samr_connect_info, &nt_status);
+ (void)policy_handle_create(p,
+ &hnd,
+ SAMR_HANDLE_CONNECT,
+ acc_granted,
+ struct samr_connect_info,
+ &nt_status);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
}
- ainfo = policy_handle_create(p, r->out.alias_handle, acc_granted,
- struct samr_alias_info, &status);
+ ainfo = policy_handle_create(p,
+ r->out.alias_handle,
+ SAMR_HANDLE_ALIAS,
+ acc_granted,
+ struct samr_alias_info,
+ &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
if ( !NT_STATUS_IS_OK(status) )
return status;
- ginfo = policy_handle_create(p, r->out.group_handle,
- GENERIC_RIGHTS_GROUP_ALL_ACCESS,
- struct samr_group_info, &status);
+ ginfo = policy_handle_create(p,
+ r->out.group_handle,
+ SAMR_HANDLE_GROUP,
+ GENERIC_RIGHTS_GROUP_ALL_ACCESS,
+ struct samr_group_info,
+ &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
return NT_STATUS_ACCESS_DENIED;
}
- ainfo = policy_handle_create(p, r->out.alias_handle,
- GENERIC_RIGHTS_ALIAS_ALL_ACCESS,
- struct samr_alias_info, &result);
+ ainfo = policy_handle_create(p,
+ r->out.alias_handle,
+ SAMR_HANDLE_ALIAS,
+ GENERIC_RIGHTS_ALIAS_ALL_ACCESS,
+ struct samr_alias_info,
+ &result);
if (!NT_STATUS_IS_OK(result)) {
return result;
}
TALLOC_FREE(map);
- ginfo = policy_handle_create(p, r->out.group_handle,
- acc_granted,
- struct samr_group_info, &status);
+ ginfo = policy_handle_create(p,
+ r->out.group_handle,
+ SAMR_HANDLE_GROUP,
+ acc_granted,
+ struct samr_group_info,
+ &status);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
talloc_set_destructor(new_printer, printer_entry_destructor);
/* This also steals the printer_handle on the policy_handle */
- if (!create_policy_hnd(p, hnd, new_printer)) {
+ if (!create_policy_hnd(p, hnd, 0, new_printer)) {
TALLOC_FREE(new_printer);
return WERR_INVALID_HANDLE;
}
/* store the SERVICE_INFO and create an open handle */
- if ( !create_policy_hnd( p, handle, info ) ) {
+ if ( !create_policy_hnd( p, handle, 0, info ) ) {
result = WERR_ACCESS_DENIED;
goto done;
}
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
+enum handle_types { HTYPE_REGVAL, HTYPE_REGKEY };
+
/******************************************************************
Find a registry key handle and return a struct registry_key *
*****************************************************************/
return result;
}
- if ( !create_policy_hnd( p, hnd, key ) ) {
+ if ( !create_policy_hnd( p, hnd, HTYPE_REGKEY, key ) ) {
return WERR_FILE_NOT_FOUND;
}
return result;
}
- if (!create_policy_hnd(p, r->out.new_handle, new_key)) {
+ if (!create_policy_hnd(p, r->out.new_handle, HTYPE_REGKEY, new_key)) {
TALLOC_FREE(new_key);
return WERR_FILE_NOT_FOUND;
}