The generic function already checks the handle type.
Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
return True;
}
-
-void *_policy_handle_find(struct pipes_struct *p,
- const struct policy_handle *hnd,
- uint8_t handle_type,
- const char *name, const char *location,
- NTSTATUS *pstatus)
-{
- struct dcesrv_handle_old *rpc_hnd = NULL;
- void *data;
-
- rpc_hnd = find_policy_by_hnd_internal(p, hnd, handle_type, &data);
- if (rpc_hnd == NULL) {
- *pstatus = NT_STATUS_INVALID_HANDLE;
- return NULL;
- }
- if (strcmp(name, talloc_get_name(data)) != 0) {
- DEBUG(10, ("expected %s, got %s\n", name,
- talloc_get_name(data)));
- *pstatus = NT_STATUS_INVALID_HANDLE;
- return NULL;
- }
-
- DEBUG(10, ("found handle of type %s\n", talloc_get_name(data)));
- *pstatus = NT_STATUS_OK;
- return data;
-}
void close_policy_by_pipe(struct pipes_struct *p);
bool pipe_access_check(struct pipes_struct *p);
-void *_policy_handle_find(struct pipes_struct *p,
- const struct policy_handle *hnd,
- uint8_t handle_type,
- const char *name, const char *location,
- NTSTATUS *pstatus);
-#define policy_handle_find(_p, _hnd, _hnd_type, _type, _pstatus) \
- (_type *)_policy_handle_find((_p), (_hnd), (_hnd_type), \
- #_type, __location__, (_pstatus))
-
#endif /* _RPC_PIPES_H_ */
{
struct samr_info *info = NULL;
NTSTATUS status;
+ bool ok;
- info = policy_handle_find(p,
- handle,
- handle_type,
- struct samr_info,
- &status);
- if (!NT_STATUS_IS_OK(status)) {
- goto fail;
+ ok = find_policy_by_hnd(p,
+ handle,
+ handle_type,
+ (void **)(void *)&info);
+ if (!ok) {
+ *pstatus = NT_STATUS_INVALID_HANDLE;
+ return NULL;
}
status = samr_handle_access_check(info->access_granted,
access_required,
access_granted);
if (!NT_STATUS_IS_OK(status)) {
- goto fail;
+ *pstatus = status;
+ return NULL;
}
*pstatus = NT_STATUS_OK;
return info;
-
-fail:
- *pstatus = status;
- return NULL;
}
static NTSTATUS make_samr_object_sd( TALLOC_CTX *ctx, struct security_descriptor **psd, size_t *sd_size,