/* basic testing of streams calls */ BOOL torture_raw_streams(struct torture_context *torture) { struct smbcli_state *cli; BOOL ret = True; TALLOC_CTX *mem_ctx; if (!torture_open_connection(&cli, 0)) { return False; } mem_ctx = talloc_init("torture_raw_streams"); if (!torture_setup_dir(cli, BASEDIR)) { return False; } ret &= test_stream_io(cli, mem_ctx); smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); torture_close_connection(cli); talloc_free(mem_ctx); return ret; }
static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_t mode) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_CHMOD(handle, path, mode); if (!path) return ret; if (!(ctx = talloc_init("chmod_file"))) return ret; if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path, &orig_path, &adbl_info, &orig_info, false) != 0) goto exit_chmod; if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", orig_path)); goto exit_chmod; } chmod(adbl_path, ADOUBLEMODE); exit_chmod: talloc_destroy(ctx); return ret; }
static int atalk_rmdir(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { bool add = False; TALLOC_CTX *ctx = 0; const char *path = smb_fname->base_name; char *dpath; if (!handle->conn->cwd || !path) goto exit_rmdir; /* due to there is no way to change bDeleteVetoFiles variable * from this module, gotta use talloc stuff.. */ strstr_m(path, APPLEDOUBLE) ? (add = False) : (add = True); if (!(ctx = talloc_init("remove_directory"))) goto exit_rmdir; if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", handle->conn->cwd, path, add ? "/"APPLEDOUBLE : ""))) goto exit_rmdir; atalk_rrmdir(ctx, dpath); exit_rmdir: talloc_destroy(ctx); return SMB_VFS_NEXT_RMDIR(handle, smb_fname); }
static int atalk_lchown(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, uid_t uid, gid_t gid) { int ret = 0; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid); if (!(ctx = talloc_init("lchown_file"))) return ret; if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) goto exit_lchown; if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", orig_path)); goto exit_lchown; } if (lchown(adbl_path, uid, gid) == -1) { DEBUG(3, ("ATALK: lchown error %s\n", strerror(errno))); } exit_lchown: talloc_destroy(ctx); return ret; }
BOOL torture_rpc_epmapper(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; BOOL ret = True; mem_ctx = talloc_init("torture_rpc_epmapper"); status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_epmapper); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); return False; } if (!test_Lookup(p, mem_ctx)) { ret = False; } if (!test_Insert(p, mem_ctx)) { ret = False; } if (!test_InqObject(p, mem_ctx)) { ret = False; } talloc_free(mem_ctx); return ret; }
_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct ndr_syntax_id *syntax) { TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data"); struct ndr_pull *ndr; enum ndr_err_code ndr_err; uint16_t if_version=0; ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx); if (ndr == NULL) { talloc_free(mem_ctx); return NT_STATUS_NO_MEMORY; } ndr->flags |= LIBNDR_FLAG_NOALIGN; ndr_err = ndr_pull_GUID(ndr, NDR_SCALARS | NDR_BUFFERS, &syntax->uuid); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(mem_ctx); return ndr_map_error2ntstatus(ndr_err); } ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { talloc_free(mem_ctx); return ndr_map_error2ntstatus(ndr_err); } syntax->if_version = if_version; talloc_free(mem_ctx); return NT_STATUS_OK; }
/** * Respond to a POOL_USAGE message by sending back string form of memory * usage stats. **/ static void msg_pool_usage(struct messaging_context *msg_ctx, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data) { struct msg_pool_usage_state state; SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE); DEBUG(2,("Got POOL_USAGE\n")); state.mem_ctx = talloc_init("msg_pool_usage"); if (!state.mem_ctx) { return; } state.len = 0; state.buflen = 512; state.s = NULL; talloc_report_depth_cb(NULL, 0, -1, msg_pool_usage_helper, &state); if (!state.s) { talloc_destroy(state.mem_ctx); return; } messaging_send_buf(msg_ctx, src, MSG_POOL_USAGE, (uint8 *)state.s, strlen(state.s)+1); talloc_destroy(state.mem_ctx); }
/**************************************************************************** prints a struct security_token to debug output. ****************************************************************************/ void security_token_debug(int dbg_lev, const struct security_token *token) { TALLOC_CTX *mem_ctx; int i; if (!token) { DEBUG(dbg_lev, ("Security token: (NULL)\n")); return; } mem_ctx = talloc_init("security_token_debug()"); if (!mem_ctx) { return; } DEBUG(dbg_lev, ("Security token of user %s\n", dom_sid_string(mem_ctx, token->user_sid) )); DEBUGADD(dbg_lev, (" SIDs (%lu):\n", (unsigned long)token->num_sids)); for (i = 0; i < token->num_sids; i++) { DEBUGADD(dbg_lev, (" SID[%3lu]: %s\n", (unsigned long)i, dom_sid_string(mem_ctx, token->sids[i]))); } security_token_debug_privileges(dbg_lev, token); talloc_free(mem_ctx); }
static PyObject *samr_delete_dom_user(PyObject *self, PyObject *args, PyObject *kw) { samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self; static char *kwlist[] = { NULL }; NTSTATUS ntstatus; TALLOC_CTX *mem_ctx; PyObject *result = NULL; if (!PyArg_ParseTupleAndKeywords( args, kw, "", kwlist)) return NULL; if (!(mem_ctx = talloc_init("samr_delete_dom_user"))) { PyErr_SetString(samr_error, "unable to init talloc context"); return NULL; } ntstatus = rpccli_samr_delete_dom_user( user_hnd->cli, mem_ctx, &user_hnd->user_pol); if (!NT_STATUS_IS_OK(ntstatus)) { PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus)); goto done; } Py_INCREF(Py_None); result = Py_None; done: talloc_destroy(mem_ctx); return result; }
struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type) { TALLOC_CTX *mem_ctx = NULL; FAKE_FILE_HANDLE *fh = NULL; int i; for (i=0; fake_files[i].name!=NULL; i++) { if (fake_files[i].type==type) { DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name)); if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) { DEBUG(0,("talloc_init(fake_file_handle) failed.\n")); return NULL; } if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) { DEBUG(0,("talloc_zero() failed.\n")); talloc_destroy(mem_ctx); return NULL; } fh->type = type; fh->mem_ctx = mem_ctx; if (fake_files[i].init_pd) fh->pd = fake_files[i].init_pd(fh->mem_ctx); fh->free_pd = fake_files[i].free_pd; return fh; } } return NULL; }
bool torture_usermod(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct policy_handle h; struct lsa_String domain_name; struct dom_sid2 sid; uint32_t rid; int i; char *name; TALLOC_CTX *mem_ctx; bool ret = true; struct dcerpc_binding_handle *b; mem_ctx = talloc_init("test_userdel"); status = torture_rpc_connection(torture, &p, &ndr_table_samr); torture_assert_ntstatus_ok(torture, status, "RPC connect"); b = p->binding_handle; domain_name.string = lpcfg_workgroup(torture->lp_ctx); name = talloc_strdup(mem_ctx, TEST_USERNAME); if (!test_domain_open(torture, b, &domain_name, mem_ctx, &h, &sid)) { ret = false; goto done; } if (!test_user_create(torture, b, mem_ctx, &h, name, &rid)) { ret = false; goto done; } for (i = USER_FIELD_FIRST; i <= USER_FIELD_LAST; i++) { struct libnet_rpc_usermod m; if (!test_usermod(torture, p, mem_ctx, &h, i, &m, &name)) { ret = false; goto cleanup; } if (!test_compare(torture, p, mem_ctx, &h, &m, name)) { ret = false; goto cleanup; } } cleanup: if (!test_user_cleanup(torture, b, mem_ctx, &h, TEST_USERNAME)) { ret = false; goto done; } done: talloc_free(mem_ctx); return ret; }
/** * Respond to a POOL_USAGE message by sending back string form of memory * usage stats. **/ void msg_pool_usage(int msg_type, struct process_id src_pid, void *UNUSED(buf), size_t UNUSED(len), void *private_data) { struct msg_pool_usage_state state; SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE); DEBUG(2,("Got POOL_USAGE\n")); state.mem_ctx = talloc_init("msg_pool_usage"); if (!state.mem_ctx) { return; } state.len = 0; state.buflen = 512; state.s = NULL; talloc_report_depth_cb(NULL, 0, -1, msg_pool_usage_helper, &state); if (!state.s) { talloc_destroy(state.mem_ctx); return; } message_send_pid(src_pid, MSG_POOL_USAGE, state.s, strlen(state.s)+1, True); talloc_destroy(state.mem_ctx); }
static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv) { TALLOC_CTX *mem_ctx; DOM_SID *domain_sid, member; if ( (argc != 1) || c->display_usage || !string_to_sid(&member, argv[0]) ) { d_printf("%s\n%s", _("Usage:"), _("net groupmap memberof sid\n")); return -1; } mem_ctx = talloc_init("net_groupmap_memberships"); if (mem_ctx == NULL) { d_fprintf(stderr, _("talloc_init failed\n")); return -1; } domain_sid = get_global_sam_sid(); if (domain_sid == NULL) { d_fprintf(stderr, _("Could not get domain sid\n")); return -1; } if (!print_alias_memberships(mem_ctx, domain_sid, &member) || !print_alias_memberships(mem_ctx, &global_sid_Builtin, &member)) return -1; talloc_destroy(mem_ctx); return 0; }
static NTSTATUS raw_smbcli_ntcreate(struct smbcli_tree *tree, const char *fname, int *fnum) { union smb_open io; TALLOC_CTX *mem_ctx; NTSTATUS status; mem_ctx = talloc_init("raw_t2open"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; memset(&io, '\0', sizeof(io)); io.generic.level = RAW_OPEN_NTCREATEX; io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; io.ntcreatex.in.root_fid.fnum = 0; io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; io.ntcreatex.in.alloc_size = 0; io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE; io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE; io.ntcreatex.in.create_options = 0; io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS; io.ntcreatex.in.security_flags = 0; io.ntcreatex.in.fname = fname; status = smb_raw_open(tree, mem_ctx, &io); talloc_free(mem_ctx); if (fnum && NT_STATUS_IS_OK(status)) { *fnum = io.openx.out.file.fnum; } return status; }
static NTSTATUS enum_local_groups(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx, uint32 *num_entries, struct acct_info **info) { uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED; CLI_POLICY_HND *hnd; POLICY_HND dom_pol; NTSTATUS result; int retry; *num_entries = 0; *info = NULL; retry = 0; do { if ( !NT_STATUS_IS_OK(result = cm_get_sam_handle(domain, &hnd)) ) return result; result = cli_samr_open_domain( hnd->cli, mem_ctx, &hnd->pol, des_access, &domain->sid, &dom_pol); } while (!NT_STATUS_IS_OK(result) && (retry++ < 1) && hnd && hnd->cli && hnd->cli->fd == -1); if ( !NT_STATUS_IS_OK(result)) return result; do { struct acct_info *info2 = NULL; uint32 count = 0, start = *num_entries; TALLOC_CTX *mem_ctx2; mem_ctx2 = talloc_init("enum_dom_local_groups[rpc]"); result = cli_samr_enum_als_groups( hnd->cli, mem_ctx2, &dom_pol, &start, 0xFFFF, &info2, &count); if ( !NT_STATUS_IS_OK(result) && !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES) ) { talloc_destroy(mem_ctx2); break; } (*info) = TALLOC_REALLOC_ARRAY(mem_ctx, *info, struct acct_info, (*num_entries) + count); if (! *info) { talloc_destroy(mem_ctx2); cli_samr_close(hnd->cli, mem_ctx, &dom_pol); return NT_STATUS_NO_MEMORY; } memcpy(&(*info)[*num_entries], info2, count*sizeof(*info2)); (*num_entries) += count; talloc_destroy(mem_ctx2); } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); cli_samr_close(hnd->cli, mem_ctx, &dom_pol); return result; }
bool torture_samba3_caseinsensitive(struct torture_context *torture) { struct smbcli_state *cli; TALLOC_CTX *mem_ctx; NTSTATUS status; const char *dirname = "insensitive"; const char *ucase_dirname = "InSeNsItIvE"; const char *fname = "foo"; char *fpath; int fnum; int counter = 0; bool ret = true; if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) { d_printf("talloc_init failed\n"); return false; } if (!torture_open_connection(&cli, torture, 0)) { goto done; } smbcli_deltree(cli->tree, dirname); status = smbcli_mkdir(cli->tree, dirname); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status)); goto done; } if (!(fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname))) { goto done; } fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { d_printf("Could not create file %s: %s\n", fpath, smbcli_errstr(cli->tree)); goto done; } smbcli_close(cli->tree, fnum); smbcli_list(cli->tree, talloc_asprintf( mem_ctx, "%s\\*", ucase_dirname), FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN |FILE_ATTRIBUTE_SYSTEM, count_fn, (void *)&counter); if (counter == 3) { ret = true; } else { d_fprintf(stderr, "expected 3 entries, got %d\n", counter); ret = false; } done: talloc_free(mem_ctx); return ret; }
static TALLOC_CTX *get_ctx(io_struct *ps) { if (ps->ctx == NULL) { ps->ctx = talloc_init(); } return ps->ctx; }
int main(int argc, char **argv) { CacServerHandle *hnd = NULL; TALLOC_CTX *mem_ctx = NULL; struct SamOpenUser ou; fstring tmp; mem_ctx = talloc_init("cac_samgroup"); hnd = cac_NewServerHandle(True); cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn); cac_parse_cmd_line(argc, argv, hnd); if(!cac_Connect(hnd, NULL)) { fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status)); exit(-1); } struct SamOpenDomain sod; ZERO_STRUCT(sod); sod.in.access = MAXIMUM_ALLOWED_ACCESS; if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) { fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status)); goto done; } ZERO_STRUCT(ou); printf("Enter username: "******"Could not open user. Error: %s\n", nt_errstr(hnd->status)); goto done; } /*enable the user*/ if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) { fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status)); } done: cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd); cac_FreeHandle(hnd); talloc_destroy(mem_ctx); return 0; }
static int net_lookup_dsgetdcname(struct net_context *c, int argc, const char **argv) { NTSTATUS status; const char *domain_name = NULL; const char *site_name = NULL; uint32_t flags = 0; struct netr_DsRGetDCNameInfo *info = NULL; TALLOC_CTX *mem_ctx; char *s = NULL; if (argc < 1 || argc > 3) { d_printf("%s\n%s", _("Usage:"), _(" net lookup dsgetdcname " "<name> <flags> <sitename>\n")); return -1; } mem_ctx = talloc_init("net_lookup_dsgetdcname"); if (!mem_ctx) { return -1; } domain_name = argv[0]; if (argc >= 2) { sscanf(argv[1], "%x", &flags); } if (flags == 0) { flags = DS_DIRECTORY_SERVICE_REQUIRED; } if (argc == 3) { site_name = argv[2]; } if (!c->msg_ctx) { d_fprintf(stderr, _("Could not initialise message context. " "Try running as root\n")); return -1; } status = dsgetdcname(mem_ctx, c->msg_ctx, domain_name, NULL, site_name, flags, &info); if (!NT_STATUS_IS_OK(status)) { d_printf(_("failed with: %s\n"), nt_errstr(status)); TALLOC_FREE(mem_ctx); return -1; } s = NDR_PRINT_STRUCT_STRING(mem_ctx, netr_DsRGetDCNameInfo, info); printf("%s\n", s); TALLOC_FREE(s); TALLOC_FREE(mem_ctx); return 0; }
BOOL torture_async_bind(struct torture_context *torture) { NTSTATUS status; TALLOC_CTX *mem_ctx; struct event_context *evt_ctx; int i; const char *binding_string; struct cli_credentials *creds; extern int torture_numasync; struct composite_context **bind_req; struct dcerpc_pipe **pipe; const struct dcerpc_interface_table **table; if (!torture_setting_bool(torture, "async", False)) { printf("async bind test disabled - enable async tests to use\n"); return True; } binding_string = torture_setting_string(torture, "binding", NULL); /* talloc context */ mem_ctx = talloc_init("torture_async_bind"); if (mem_ctx == NULL) return False; bind_req = talloc_array(torture, struct composite_context*, torture_numasync); if (bind_req == NULL) return False; pipe = talloc_array(torture, struct dcerpc_pipe*, torture_numasync); if (pipe == NULL) return False; table = talloc_array(torture, const struct dcerpc_interface_table*, torture_numasync); if (table == NULL) return False; /* event context */ evt_ctx = event_context_init(mem_ctx); if (evt_ctx == NULL) return False; /* credentials */ creds = cmdline_credentials; /* send bind requests */ for (i = 0; i < torture_numasync; i++) { table[i] = &dcerpc_table_lsarpc; bind_req[i] = dcerpc_pipe_connect_send(mem_ctx, binding_string, table[i], creds, evt_ctx); } /* recv bind requests */ for (i = 0; i < torture_numasync; i++) { status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]); if (!NT_STATUS_IS_OK(status)) { printf("async rpc connection failed: %s\n", nt_errstr(status)); return False; } } talloc_free(mem_ctx); return True; }
static bool test_generate_random_str(struct torture_context *tctx) { TALLOC_CTX *mem_ctx = talloc_init(__FUNCTION__); char *r = generate_random_str(mem_ctx, 10); torture_assert_int_equal(tctx, strlen(r), 10, "right length generated"); r = generate_random_str(mem_ctx, 5); torture_assert_int_equal(tctx, strlen(r), 5, "right length generated"); return true; }
bool torture_domain_open_samr(struct torture_context *torture) { NTSTATUS status; struct libnet_context *ctx; TALLOC_CTX *mem_ctx; struct policy_handle domain_handle, handle; struct libnet_DomainOpen io; struct samr_Close r; const char *domain_name; bool ret = true; mem_ctx = talloc_init("test_domainopen_lsa"); ctx = libnet_context_init(torture->ev, torture->lp_ctx); ctx->cred = cmdline_credentials; /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ domain_name = lp_workgroup(torture->lp_ctx); /* * Testing synchronous version */ printf("opening domain\n"); io.in.type = DOMAIN_SAMR; io.in.domain_name = domain_name; io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; status = libnet_DomainOpen(ctx, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { printf("Composite domain open failed - %s\n", nt_errstr(status)); ret = false; goto done; } domain_handle = ctx->samr.handle; r.in.handle = &domain_handle; r.out.handle = &handle; printf("closing domain handle\n"); status = dcerpc_samr_Close(ctx->samr.pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); ret = false; goto done; } done: talloc_free(mem_ctx); talloc_free(ctx); return ret; }
BOOL torture_domain_open_samr(struct torture_context *torture) { NTSTATUS status; const char *binding; struct libnet_context *ctx; struct event_context *evt_ctx=NULL; TALLOC_CTX *mem_ctx; struct policy_handle domain_handle, handle; struct lsa_String name; struct libnet_DomainOpen io; struct samr_Close r; BOOL ret = True; mem_ctx = talloc_init("test_domainopen_lsa"); binding = torture_setting_string(torture, "binding", NULL); ctx = libnet_context_init(evt_ctx); ctx->cred = cmdline_credentials; name.string = lp_workgroup(); /* * Testing synchronous version */ printf("opening domain\n"); io.in.type = DOMAIN_SAMR; io.in.domain_name = name.string; io.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; status = libnet_DomainOpen(ctx, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { printf("Composite domain open failed - %s\n", nt_errstr(status)); ret = False; goto done; } domain_handle = ctx->samr.handle; r.in.handle = &domain_handle; r.out.handle = &handle; printf("closing domain handle\n"); status = dcerpc_samr_Close(ctx->samr.pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); ret = False; goto done; } done: talloc_free(mem_ctx); talloc_free(ctx); return ret; }
bool torture_useradd(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct policy_handle h; struct lsa_String domain_name; struct dom_sid2 sid; const char *name = TEST_USERNAME; TALLOC_CTX *mem_ctx; bool ret = true; struct dcerpc_binding_handle *b; mem_ctx = talloc_init("test_useradd"); status = torture_rpc_connection(torture, &p, &ndr_table_samr); torture_assert_ntstatus_ok(torture, status, "RPC connect failed"); b = p->binding_handle; domain_name.string = lpcfg_workgroup(torture->lp_ctx); if (!test_domain_open(torture, b, &domain_name, mem_ctx, &h, &sid)) { ret = false; goto done; } if (!test_useradd(torture, p, mem_ctx, &h, name)) { ret = false; goto done; } if (!test_user_cleanup(torture, b, mem_ctx, &h, name)) { ret = false; goto done; } if (!test_domain_open(torture, b, &domain_name, mem_ctx, &h, &sid)) { ret = false; goto done; } if (!test_useradd_async(torture, p, mem_ctx, &h, name)) { ret = false; goto done; } if (!test_user_cleanup(torture, b, mem_ctx, &h, name)) { ret = false; goto done; } done: talloc_free(mem_ctx); return ret; }
TALLOC_CTX *main_loop_talloc_get(void) { if (!main_loop_talloc) { main_loop_talloc = talloc_init("main loop talloc (mainly parse_misc)"); if (!main_loop_talloc) smb_panic("main_loop_talloc: malloc fail\n"); } return main_loop_talloc; }
static BOOL init_afs_acl(struct afs_acl *acl) { ZERO_STRUCT(*acl); acl->ctx = talloc_init("afs_acl"); if (acl->ctx == NULL) { DEBUG(10, ("Could not init afs_acl")); return False; } return True; }
static bool create_send_ctx(void) { if (!send_ctx) send_ctx = talloc_init("print notify queue"); if (!send_ctx) return False; return True; }
static int atalk_unlink(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path) { int ret = 0, i; char *adbl_path = 0; char *orig_path = 0; SMB_STRUCT_STAT adbl_info; SMB_STRUCT_STAT orig_info; TALLOC_CTX *ctx; ret = SMB_VFS_NEXT_UNLINK(handle, conn, path); if (!conn || !path) return ret; /* no .AppleDouble sync if veto or hide list is empty, * otherwise "Cannot find the specified file" error will be caused */ if (!conn->veto_list) return ret; if (!conn->hide_list) return ret; for (i = 0; conn->veto_list[i].name; i ++) { if (strstr(conn->veto_list[i].name, APPLEDOUBLE)) break; } if (!conn->veto_list[i].name) { for (i = 0; conn->hide_list[i].name; i ++) { if (strstr(conn->hide_list[i].name, APPLEDOUBLE)) break; else { DEBUG(3, ("ATALK: %s is not hidden, skipped..\n", APPLEDOUBLE)); return ret; } } } if (!(ctx = talloc_init("unlink_file"))) return ret; if (atalk_build_paths(ctx, conn->origpath, path, &adbl_path, &orig_path, &adbl_info, &orig_info) != 0) return ret; if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) { DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); goto exit_unlink; } atalk_unlink_file(adbl_path); exit_unlink: talloc_destroy(ctx); return ret; }
void free_pipe_context(pipes_struct *p) { if (p->mem_ctx) { DEBUG(3,("free_pipe_context: destroying talloc pool of size %lu\n", (unsigned long)talloc_pool_size(p->mem_ctx) )); talloc_destroy_pool(p->mem_ctx); } else { p->mem_ctx = talloc_init("pipe %s %p", p->name, p); if (p->mem_ctx == NULL) p->fault_state = True; } }
static void on_connect_activate(GtkMenuItem *menuitem, gpointer user_data) { TALLOC_CTX *mem_ctx = talloc_init("gwsvcctl_connect"); svcctl_pipe = gtk_connect_rpc_interface(mem_ctx, ev_ctx, lp_ctx, &ndr_table_svcctl); if (svcctl_pipe == NULL) return; gtk_widget_set_sensitive (new_service, TRUE); /* FIXME: Fetch list of services and display */ }