diff options
author | Volker Lendecke <vl@samba.org> | 2009-04-18 13:31:20 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2009-04-18 13:58:48 +0200 |
commit | c9bc1728f971318ab291639f34b326157e918f5f (patch) | |
tree | b31b6334f35ffcda7d6f7e43a4feaf16df9fc3cf /source3/rpc_server | |
parent | fd558b37f601b5286f227a77aa593255d75c2484 (diff) | |
download | samba-c9bc1728f971318ab291639f34b326157e918f5f.tar.gz samba-c9bc1728f971318ab291639f34b326157e918f5f.tar.bz2 samba-c9bc1728f971318ab291639f34b326157e918f5f.zip |
Add type-safe policy_handle_create/find
Diffstat (limited to 'source3/rpc_server')
-rw-r--r-- | source3/rpc_server/srv_lsa_hnd.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_lsa_hnd.c b/source3/rpc_server/srv_lsa_hnd.c index f233376488..e1582840c3 100644 --- a/source3/rpc_server/srv_lsa_hnd.c +++ b/source3/rpc_server/srv_lsa_hnd.c @@ -280,3 +280,48 @@ bool pipe_access_check(pipes_struct *p) return True; } + +NTSTATUS _policy_handle_create(struct pipes_struct *p, struct policy_handle *hnd, + void *pdata, size_t data_size, const char *type) +{ + void **ppdata = (void **)pdata; + void *data; + + if (p->pipe_handles->count > MAX_OPEN_POLS) { + DEBUG(0, ("policy_handle_create: ERROR: too many handles (%d) " + "on pipe %s.\n", (int)p->pipe_handles->count, + get_pipe_name_from_iface(&p->syntax))); + return NT_STATUS_INSUFFICIENT_RESOURCES; + } + + data = talloc_size(talloc_tos(), data_size); + if (data == NULL) { + return NT_STATUS_NO_MEMORY; + } + talloc_set_name(data, type); + + if (!create_policy_hnd(p, hnd, data)) { + TALLOC_FREE(data); + return NT_STATUS_NO_MEMORY; + } + *ppdata = data; + return NT_STATUS_OK; +} + +void *_policy_handle_find(struct pipes_struct *p, + const struct policy_handle *hnd, + const char *name) +{ + void *data; + + if (find_policy_by_hnd_internal(p, hnd, &data) == NULL) { + return NULL; + } + if (strcmp(name, talloc_get_name(data)) != 0) { + DEBUG(10, ("expected %s, got %s\n", name, + talloc_get_name(data))); + return NULL; + } + DEBUG(10, ("found handle of type %s\n", talloc_get_name(data))); + return data; +} |