这篇教程C++ talloc_strdup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中talloc_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ talloc_strdup函数的具体用法?C++ talloc_strdup怎么用?C++ talloc_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了talloc_strdup函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: demux_open_tvstatic int demux_open_tv(demuxer_t *demuxer, enum demux_check check){ tvi_handle_t *tvh; sh_video_t *sh_video; sh_audio_t *sh_audio = NULL; const tvi_functions_t *funcs; if (check > DEMUX_CHECK_REQUEST || demuxer->stream->type != STREAMTYPE_TV) return -1; tv_param_t *params = m_sub_options_copy(demuxer, &tv_params_conf, demuxer->opts->tv_params); struct tv_stream_params *sparams = demuxer->stream->priv; if (sparams->channel && sparams->channel[0]) { talloc_free(params->channel); params->channel = talloc_strdup(NULL, sparams->channel); } if (sparams->input >= 0) params->input = sparams->input; assert(demuxer->priv==NULL); if(!(tvh=tv_begin(params, demuxer->log))) return -1; if (!tvh->functions->init(tvh->priv)) return -1; tvh->demuxer = demuxer; if (!open_tv(tvh)){ tv_uninit(tvh); return -1; } funcs = tvh->functions; demuxer->priv=tvh; struct sh_stream *sh_v = new_sh_stream(demuxer, STREAM_VIDEO); sh_video = sh_v->video; /* get IMAGE FORMAT */ int fourcc; funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &fourcc); if (fourcc == MP_FOURCC_MJPEG) { sh_v->codec = "mjpeg"; } else { sh_v->codec = "rawvideo"; sh_v->format = fourcc; } /* set FPS and FRAMETIME */ if(!sh_video->fps) { float tmp; if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &tmp) != TVI_CONTROL_TRUE) sh_video->fps = 25.0f; /* on PAL */ else sh_video->fps = tmp; } if (tvh->tv_param->fps != -1.0f) sh_video->fps = tvh->tv_param->fps; /* If playback only mode, go to immediate mode, fail silently */ if(tvh->tv_param->immediate == 1) { funcs->control(tvh->priv, TVI_CONTROL_IMMEDIATE, 0); tvh->tv_param->audio = 0; } /* set width */ funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w); /* set height */ funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h); demuxer->seekable = 0; /* here comes audio init */ if (tvh->tv_param->audio && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) { int audio_format; /* yeah, audio is present */ funcs->control(tvh->priv, TVI_CONTROL_AUD_SET_SAMPLERATE, &tvh->tv_param->audiorate); if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE) goto no_audio; switch(audio_format) { case AF_FORMAT_U8: case AF_FORMAT_S8: case AF_FORMAT_U16_LE: case AF_FORMAT_U16_BE: case AF_FORMAT_S16_LE: case AF_FORMAT_S16_BE: case AF_FORMAT_S32_LE: case AF_FORMAT_S32_BE: break; case AF_FORMAT_MPEG2: default://.........这里部分代码省略.........
开发者ID:AbhiDGamer,项目名称:mpv,代码行数:101,
示例2: map_populate_groupsstatic NTSTATUS map_populate_groups(TALLOC_CTX *mem_ctx, GROUPMAP *groupmap, ACCOUNTMAP *accountmap, const char *sid, const char *suffix, const char *builtin_sid){ char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ','); /* Map the groups created by populate_ldap_for_ldif */ groupmap[0].rid = 512; groupmap[0].gidNumber = 512; groupmap[0].sambaSID = talloc_asprintf(mem_ctx, "%s-512", sid); groupmap[0].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Admins,ou=%s,%s", group_attr, suffix); if (groupmap[0].sambaSID == NULL || groupmap[0].group_dn == NULL) { goto err; } accountmap[0].rid = 512; accountmap[0].cn = talloc_strdup(mem_ctx, "Domain Admins"); if (accountmap[0].cn == NULL) { goto err; } groupmap[1].rid = 513; groupmap[1].gidNumber = 513; groupmap[1].sambaSID = talloc_asprintf(mem_ctx, "%s-513", sid); groupmap[1].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Users,ou=%s,%s", group_attr, suffix); if (groupmap[1].sambaSID == NULL || groupmap[1].group_dn == NULL) { goto err; } accountmap[1].rid = 513; accountmap[1].cn = talloc_strdup(mem_ctx, "Domain Users"); if (accountmap[1].cn == NULL) { goto err; } groupmap[2].rid = 514; groupmap[2].gidNumber = 514; groupmap[2].sambaSID = talloc_asprintf(mem_ctx, "%s-514", sid); groupmap[2].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Guests,ou=%s,%s", group_attr, suffix); if (groupmap[2].sambaSID == NULL || groupmap[2].group_dn == NULL) { goto err; } accountmap[2].rid = 514; accountmap[2].cn = talloc_strdup(mem_ctx, "Domain Guests"); if (accountmap[2].cn == NULL) { goto err; } groupmap[3].rid = 515; groupmap[3].gidNumber = 515; groupmap[3].sambaSID = talloc_asprintf(mem_ctx, "%s-515", sid); groupmap[3].group_dn = talloc_asprintf(mem_ctx, "cn=Domain Computers,ou=%s,%s", group_attr, suffix); if (groupmap[3].sambaSID == NULL || groupmap[3].group_dn == NULL) { goto err; } accountmap[3].rid = 515; accountmap[3].cn = talloc_strdup(mem_ctx, "Domain Computers"); if (accountmap[3].cn == NULL) { goto err; } groupmap[4].rid = 544; groupmap[4].gidNumber = 544; groupmap[4].sambaSID = talloc_asprintf(mem_ctx, "%s-544", builtin_sid); groupmap[4].group_dn = talloc_asprintf(mem_ctx, "cn=Administrators,ou=%s,%s", group_attr, suffix); if (groupmap[4].sambaSID == NULL || groupmap[4].group_dn == NULL) { goto err; } accountmap[4].rid = 515; accountmap[4].cn = talloc_strdup(mem_ctx, "Administrators"); if (accountmap[4].cn == NULL) { goto err; } groupmap[5].rid = 550; groupmap[5].gidNumber = 550; groupmap[5].sambaSID = talloc_asprintf(mem_ctx, "%s-550", builtin_sid); groupmap[5].group_dn = talloc_asprintf(mem_ctx, "cn=Print Operators,ou=%s,%s", group_attr, suffix); if (groupmap[5].sambaSID == NULL || groupmap[5].group_dn == NULL) { goto err; } accountmap[5].rid = 550; accountmap[5].cn = talloc_strdup(mem_ctx, "Print Operators"); if (accountmap[5].cn == NULL) { goto err; }//.........这里部分代码省略.........
开发者ID:berte,项目名称:mediaplayer,代码行数:101,
示例3: ldif_init_contextstatic NTSTATUS ldif_init_context(TALLOC_CTX *mem_ctx, enum netr_SamDatabaseID database_id, const char *ldif_filename, const char *domain_sid_str, struct samsync_ldif_context **ctx){ NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct samsync_ldif_context *r; const char *add_template = "/tmp/add.ldif.XXXXXX"; const char *mod_template = "/tmp/mod.ldif.XXXXXX"; const char *builtin_sid = "S-1-5-32"; /* Get other smb.conf data */ if (!(lp_workgroup()) || !*(lp_workgroup())) { DEBUG(0,("workgroup missing from smb.conf--exiting/n")); exit(1); } /* Get the ldap suffix */ if (!(lp_ldap_suffix()) || !*(lp_ldap_suffix())) { DEBUG(0,("ldap suffix missing from smb.conf--exiting/n")); exit(1); } if (*ctx && (*ctx)->initialized) { return NT_STATUS_OK; } r = TALLOC_ZERO_P(mem_ctx, struct samsync_ldif_context); NT_STATUS_HAVE_NO_MEMORY(r); /* Get the ldap suffix */ r->suffix = lp_ldap_suffix(); /* Ensure we have an output file */ if (ldif_filename) { r->ldif_file = fopen(ldif_filename, "a"); } else { r->ldif_file = stdout; } if (!r->ldif_file) { fprintf(stderr, "Could not open %s/n", ldif_filename); DEBUG(1, ("Could not open %s/n", ldif_filename)); status = NT_STATUS_UNSUCCESSFUL; goto done; } r->add_template = talloc_strdup(mem_ctx, add_template); r->mod_template = talloc_strdup(mem_ctx, mod_template); if (!r->add_template || !r->mod_template) { status = NT_STATUS_NO_MEMORY; goto done; } r->add_name = talloc_strdup(mem_ctx, add_template); r->mod_name = talloc_strdup(mem_ctx, mod_template); if (!r->add_name || !r->mod_name) { status = NT_STATUS_NO_MEMORY; goto done; } /* Open the add and mod ldif files */ if (!(r->add_file = fdopen(smb_mkstemp(r->add_name),"w"))) { DEBUG(1, ("Could not open %s/n", r->add_name)); status = NT_STATUS_UNSUCCESSFUL; goto done; } if (!(r->mod_file = fdopen(smb_mkstemp(r->mod_name),"w"))) { DEBUG(1, ("Could not open %s/n", r->mod_name)); status = NT_STATUS_UNSUCCESSFUL; goto done; } /* Allocate initial memory for groupmap and accountmap arrays */ r->groupmap = TALLOC_ZERO_ARRAY(mem_ctx, GROUPMAP, 8); r->accountmap = TALLOC_ZERO_ARRAY(mem_ctx, ACCOUNTMAP, 8); if (r->groupmap == NULL || r->accountmap == NULL) { DEBUG(1,("GROUPMAP talloc failed/n")); status = NT_STATUS_NO_MEMORY; goto done; } /* Remember how many we malloced */ r->num_alloced = 8; /* Initial database population */ if (database_id == SAM_DATABASE_DOMAIN) { status = populate_ldap_for_ldif(domain_sid_str, r->suffix, builtin_sid, r->add_file); if (!NT_STATUS_IS_OK(status)) { goto done; } status = map_populate_groups(mem_ctx, r->groupmap, r->accountmap,//.........这里部分代码省略.........
开发者ID:berte,项目名称:mediaplayer,代码行数:101,
示例4: recreate_graphstatic bool recreate_graph(struct af_instance *af, struct mp_audio *config){ void *tmp = talloc_new(NULL); struct priv *p = af->priv; AVFilterContext *in = NULL, *out = NULL, *f_format = NULL; if (bstr0(p->cfg_graph).len == 0) { MP_FATAL(af, "lavfi: no filter graph set/n"); return false; } destroy_graph(af); MP_VERBOSE(af, "lavfi: create graph: '%s'/n", p->cfg_graph); AVFilterGraph *graph = avfilter_graph_alloc(); if (!graph) goto error; if (mp_set_avopts(af->log, graph, p->cfg_avopts) < 0) goto error; AVFilterInOut *outputs = avfilter_inout_alloc(); AVFilterInOut *inputs = avfilter_inout_alloc(); if (!outputs || !inputs) goto error; // Build list of acceptable output sample formats. libavfilter will insert // conversion filters if needed. static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8P, AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }; char *fmtstr = talloc_strdup(tmp, ""); for (int n = 0; sample_fmts[n] != AV_SAMPLE_FMT_NONE; n++) { const char *name = av_get_sample_fmt_name(sample_fmts[n]); if (name) { const char *s = fmtstr[0] ? "|" : ""; fmtstr = talloc_asprintf_append_buffer(fmtstr, "%s%s", s, name); } } char *src_args = talloc_asprintf(tmp, "sample_rate=%d:sample_fmt=%s:time_base=%d/%d:" "channel_layout=0x%"PRIx64, config->rate, av_get_sample_fmt_name(af_to_avformat(config->format)), 1, config->rate, mp_chmap_to_lavc(&config->channels)); if (avfilter_graph_create_filter(&in, avfilter_get_by_name("abuffer"), "src", src_args, NULL, graph) < 0) goto error; if (avfilter_graph_create_filter(&out, avfilter_get_by_name("abuffersink"), "out", NULL, NULL, graph) < 0) goto error; if (avfilter_graph_create_filter(&f_format, avfilter_get_by_name("aformat"), "format", fmtstr, NULL, graph) < 0) goto error; if (avfilter_link(f_format, 0, out, 0) < 0) goto error; outputs->name = av_strdup("in"); outputs->filter_ctx = in; inputs->name = av_strdup("out"); inputs->filter_ctx = f_format; if (graph_parse(graph, p->cfg_graph, inputs, outputs, NULL) < 0) goto error; if (avfilter_graph_config(graph, NULL) < 0) goto error; p->in = in; p->out = out; p->graph = graph; assert(out->nb_inputs == 1); assert(in->nb_outputs == 1); talloc_free(tmp); return true;error: MP_FATAL(af, "Can't configure libavfilter graph./n"); avfilter_graph_free(&graph); talloc_free(tmp); return false;}
开发者ID:in1t3r,项目名称:mpv,代码行数:93,
示例5: reg_load_treestatic WERROR reg_load_tree(REGF_FILE *regfile, const char *topkeypath, REGF_NK_REC *key){ REGF_NK_REC *subkey; struct registry_key_handle registry_key; struct regval_ctr *values; struct regsubkey_ctr *subkeys; int i; char *path = NULL; WERROR result = WERR_OK; /* initialize the struct registry_key_handle structure */ registry_key.ops = reghook_cache_find(topkeypath); if (!registry_key.ops) { DEBUG(0, ("reg_load_tree: Failed to assign registry_ops " "to [%s]/n", topkeypath)); return WERR_BADFILE; } registry_key.name = talloc_strdup(regfile->mem_ctx, topkeypath); if (!registry_key.name) { DEBUG(0, ("reg_load_tree: Talloc failed for reg_key.name!/n")); return WERR_NOMEM; } /* now start parsing the values and subkeys */ result = regsubkey_ctr_init(regfile->mem_ctx, &subkeys); W_ERROR_NOT_OK_RETURN(result); result = regval_ctr_init(subkeys, &values); W_ERROR_NOT_OK_RETURN(result); /* copy values into the struct regval_ctr */ for (i=0; i<key->num_values; i++) { regval_ctr_addvalue(values, key->values[i].valuename, key->values[i].type, key->values[i].data, (key->values[i].data_size & ~VK_DATA_IN_OFFSET)); } /* copy subkeys into the struct regsubkey_ctr */ key->subkey_index = 0; while ((subkey = regfio_fetch_subkey( regfile, key ))) { result = regsubkey_ctr_addkey(subkeys, subkey->keyname); if (!W_ERROR_IS_OK(result)) { TALLOC_FREE(subkeys); return result; } } /* write this key and values out */ if (!store_reg_values(®istry_key, values) || !store_reg_keys(®istry_key, subkeys)) { DEBUG(0,("reg_load_tree: Failed to load %s!/n", topkeypath)); result = WERR_REG_IO_FAILURE; } TALLOC_FREE(subkeys); if (!W_ERROR_IS_OK(result)) { return result; } /* now continue to load each subkey registry tree */ key->subkey_index = 0; while ((subkey = regfio_fetch_subkey(regfile, key))) { path = talloc_asprintf(regfile->mem_ctx, "%s//%s", topkeypath, subkey->keyname); if (path == NULL) { return WERR_NOMEM; } result = reg_load_tree(regfile, path, subkey); if (!W_ERROR_IS_OK(result)) { break; } } return result;}
开发者ID:AIdrifter,项目名称:samba,代码行数:88,
示例6: passwd_to_SamInfo3//.........这里部分代码省略......... */ /* * This can lead to a primary group of S-1-22-2-XX which * will be rejected by other Samba code. */ gid_to_sid(&group_sid, pwd->pw_gid); } /* * If we are a unix group, or a wellknown/builtin alias, * set the group_sid to the * 'Domain Users' RID of 513 which will always resolve to a * name. */ if (sid_check_is_in_unix_groups(&group_sid) || sid_check_is_in_builtin(&group_sid) || sid_check_is_in_wellknown_domain(&group_sid)) { if (sid_check_is_in_unix_users(&user_sid)) { sid_compose(&group_sid, get_global_sam_sid(), DOMAIN_RID_USERS); } else { sid_copy(&domain_sid, &user_sid); sid_split_rid(&domain_sid, NULL); sid_compose(&group_sid, &domain_sid, DOMAIN_RID_USERS); } } /* Make sure we have a valid group sid */ is_null = is_null_sid(&group_sid); if (is_null) { status = NT_STATUS_NO_SUCH_USER; goto done; } /* Construct a netr_SamInfo3 from the information we have */ info3 = talloc_zero(tmp_ctx, struct netr_SamInfo3); if (!info3) { status = NT_STATUS_NO_MEMORY; goto done; } info3->base.account_name.string = talloc_strdup(info3, unix_username); if (info3->base.account_name.string == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } ZERO_STRUCT(domain_sid); status = SamInfo3_handle_sids(unix_username, &user_sid, &group_sid, info3, &domain_sid, extra); if (!NT_STATUS_IS_OK(status)) { goto done; } info3->base.domain_sid = dom_sid_dup(info3, &domain_sid); if (info3->base.domain_sid == NULL) { status = NT_STATUS_NO_MEMORY; goto done; } ok = sid_peek_check_rid(&domain_sid, &group_sid, &info3->base.primary_gid); if (!ok) { DEBUG(1, ("The primary group domain sid(%s) does not " "match the domain sid(%s) for %s(%s)/n", sid_string_dbg(&group_sid), sid_string_dbg(&domain_sid), unix_username, sid_string_dbg(&user_sid))); status = NT_STATUS_INVALID_SID; goto done; } info3->base.acct_flags = ACB_NORMAL; if (num_sids) { status = group_sids_to_info3(info3, user_sids, num_sids); if (!NT_STATUS_IS_OK(status)) { goto done; } } *pinfo3 = talloc_steal(mem_ctx, info3); status = NT_STATUS_OK;done: talloc_free(tmp_ctx); return status;}
开发者ID:encukou,项目名称:samba,代码行数:101,
示例7: talloc_strdup#ifdef PCAP_RAW_SOCKETS/** Build PCAP filter string to pass to libpcap based on listen section * Will be called by init_pcap. * * @param this listen section * @return PCAP filter string */static const char *dhcp_pcap_filter_build(rad_listen_t *this){ dhcp_socket_t *sock = this->data; char *filter; /* * Set the port filter */ filter = talloc_strdup(this, "(udp and dst port "); if (sock->lsock.my_port) { filter = talloc_asprintf_append_buffer(filter, "%u)", sock->lsock.my_port); } else { filter = talloc_strdup_append_buffer(filter, "bootps)"); } if (!fr_ipaddr_is_inaddr_any(&sock->lsock.my_ipaddr)) { char buffer[INET_ADDRSTRLEN]; fr_inet_ntoh(&sock->lsock.my_ipaddr, buffer, sizeof(buffer)); if (sock->lsock.broadcast) { filter = talloc_asprintf_append_buffer(filter, " and (dst host %s or dst host 255.255.255.255)", buffer); } else { filter = talloc_asprintf_append_buffer(filter, " and dst host %s", buffer);
开发者ID:alagoutte,项目名称:freeradius-server,代码行数:31,
示例8: make_server_info_info3NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, const char *sent_nt_username, const char *domain, struct auth_serversupplied_info **server_info, const struct netr_SamInfo3 *info3){ static const char zeros[16] = {0, }; NTSTATUS nt_status = NT_STATUS_OK; char *found_username = NULL; const char *nt_domain; const char *nt_username; struct dom_sid user_sid; struct dom_sid group_sid; bool username_was_mapped; struct passwd *pwd; struct auth_serversupplied_info *result; TALLOC_CTX *tmp_ctx = talloc_stackframe(); /* Here is where we should check the list of trusted domains, and verify that the SID matches. */ if (!sid_compose(&user_sid, info3->base.domain_sid, info3->base.rid)) { nt_status = NT_STATUS_INVALID_PARAMETER; goto out; } if (!sid_compose(&group_sid, info3->base.domain_sid, info3->base.primary_gid)) { nt_status = NT_STATUS_INVALID_PARAMETER; goto out; } nt_username = talloc_strdup(tmp_ctx, info3->base.account_name.string); if (!nt_username) { /* If the server didn't give us one, just use the one we sent * them */ nt_username = sent_nt_username; } nt_domain = talloc_strdup(mem_ctx, info3->base.logon_domain.string); if (!nt_domain) { /* If the server didn't give us one, just use the one we sent * them */ nt_domain = domain; } /* If getpwnam() fails try the add user script (2.2.x behavior). We use the _unmapped_ username here in an attempt to provide consistent username mapping behavior between kerberos and NTLM[SSP] authentication in domain mode security. I.E. Username mapping should be applied to the fully qualified username (e.g. DOMAIN/user) and not just the login name. Yes this means we called map_username() unnecessarily in make_user_info_map() but that is how the current code is designed. Making the change here is the least disruptive place. -- jerry */ /* this call will try to create the user if necessary */ nt_status = check_account(tmp_ctx, nt_domain, nt_username, &found_username, &pwd, &username_was_mapped); if (!NT_STATUS_IS_OK(nt_status)) { /* Handle 'map to guest = Bad Uid */ if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NO_SUCH_USER) && (lp_security() == SEC_ADS || lp_security() == SEC_DOMAIN) && lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID) { DBG_NOTICE("Try to map %s to guest account", nt_username); nt_status = make_server_info_guest(tmp_ctx, &result); if (NT_STATUS_IS_OK(nt_status)) { *server_info = talloc_move(mem_ctx, &result); } } goto out; } result = make_server_info(tmp_ctx); if (result == NULL) { DEBUG(4, ("make_server_info failed!/n")); nt_status = NT_STATUS_NO_MEMORY; goto out; } result->unix_name = talloc_strdup(result, found_username); /* copy in the info3 */ result->info3 = copy_netr_SamInfo3(result, info3); if (result->info3 == NULL) { nt_status = NT_STATUS_NO_MEMORY; goto out; }//.........这里部分代码省略.........
开发者ID:urisimchoni,项目名称:samba,代码行数:101,
示例9: create_local_tokenNTSTATUS create_local_token(TALLOC_CTX *mem_ctx, const struct auth_serversupplied_info *server_info, DATA_BLOB *session_key, const char *smb_username, /* for ->sanitized_username, for %U subs */ struct auth_session_info **session_info_out){ struct security_token *t; NTSTATUS status; size_t i; struct dom_sid tmp_sid; struct auth_session_info *session_info; struct unixid *ids; fstring tmp; /* Ensure we can't possible take a code path leading to a * null defref. */ if (!server_info) { return NT_STATUS_LOGON_FAILURE; } session_info = talloc_zero(mem_ctx, struct auth_session_info); if (!session_info) { return NT_STATUS_NO_MEMORY; } session_info->unix_token = talloc_zero(session_info, struct security_unix_token); if (!session_info->unix_token) { TALLOC_FREE(session_info); return NT_STATUS_NO_MEMORY; } session_info->unix_token->uid = server_info->utok.uid; session_info->unix_token->gid = server_info->utok.gid; session_info->unix_info = talloc_zero(session_info, struct auth_user_info_unix); if (!session_info->unix_info) { TALLOC_FREE(session_info); return NT_STATUS_NO_MEMORY; } session_info->unix_info->unix_name = talloc_strdup(session_info, server_info->unix_name); if (!session_info->unix_info->unix_name) { TALLOC_FREE(session_info); return NT_STATUS_NO_MEMORY; } /* This is a potentially untrusted username for use in %U */ alpha_strcpy(tmp, smb_username, ". _-$", sizeof(tmp)); session_info->unix_info->sanitized_username = talloc_strdup(session_info->unix_info, tmp); if (session_key) { data_blob_free(&session_info->session_key); session_info->session_key = data_blob_talloc(session_info, session_key->data, session_key->length); if (!session_info->session_key.data && session_key->length) { return NT_STATUS_NO_MEMORY; } } else { session_info->session_key = data_blob_talloc( session_info, server_info->session_key.data, server_info->session_key.length); } /* We need to populate session_info->info with the information found in server_info->info3 */ status = make_user_info_SamBaseInfo(session_info, "", &server_info->info3->base, server_info->guest == false, &session_info->info); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("conversion of info3 into auth_user_info failed!/n")); TALLOC_FREE(session_info); return status; } if (server_info->security_token) { /* Just copy the token, it has already been finalised * (nasty hack to support a cached guest/system session_info */ session_info->security_token = dup_nt_token(session_info, server_info->security_token); if (!session_info->security_token) { TALLOC_FREE(session_info); return NT_STATUS_NO_MEMORY; } session_info->unix_token->ngroups = server_info->utok.ngroups; if (server_info->utok.ngroups != 0) { session_info->unix_token->groups = (gid_t *)talloc_memdup( session_info->unix_token, server_info->utok.groups, sizeof(gid_t)*session_info->unix_token->ngroups); } else { session_info->unix_token->groups = NULL; } *session_info_out = session_info; return NT_STATUS_OK; } /* * If winbind is not around, we can not make much use of the SIDs the//.........这里部分代码省略.........
开发者ID:urisimchoni,项目名称:samba,代码行数:101,
示例10: make_server_info/* This function MUST only used to create the cached server_info for * guest. * * This is a lossy conversion. Variables known to be lost so far * include: * * - nss_token (not needed because the only read doesn't happen * for the GUEST user, as this routine populates ->security_token * * - extra (not needed because the guest account must have valid RIDs per the output of get_guest_info3()) * * - The 'server_info' parameter allows the missing 'info3' to be copied across. */static struct auth_serversupplied_info *copy_session_info_serverinfo_guest(TALLOC_CTX *mem_ctx, const struct auth_session_info *src, struct auth_serversupplied_info *server_info){ struct auth_serversupplied_info *dst; dst = make_server_info(mem_ctx); if (dst == NULL) { return NULL; } /* This element must be provided to convert back to an auth_serversupplied_info */ SMB_ASSERT(src->unix_info); dst->guest = true; dst->system = false; /* This element must be provided to convert back to an * auth_serversupplied_info. This needs to be from the * auth_session_info because the group values in particular * may change during create_local_token() processing */ SMB_ASSERT(src->unix_token); dst->utok.uid = src->unix_token->uid; dst->utok.gid = src->unix_token->gid; dst->utok.ngroups = src->unix_token->ngroups; if (src->unix_token->ngroups != 0) { dst->utok.groups = (gid_t *)talloc_memdup( dst, src->unix_token->groups, sizeof(gid_t)*dst->utok.ngroups); } else { dst->utok.groups = NULL; } /* We must have a security_token as otherwise the lossy * conversion without nss_token would cause create_local_token * to take the wrong path */ SMB_ASSERT(src->security_token); dst->security_token = dup_nt_token(dst, src->security_token); if (!dst->security_token) { TALLOC_FREE(dst); return NULL; } dst->session_key = data_blob_talloc( dst, src->session_key.data, src->session_key.length); /* This is OK because this functions is only used for the * GUEST account, which has all-zero keys for both values */ dst->lm_session_key = data_blob_talloc(dst, src->session_key.data, src->session_key.length); dst->info3 = copy_netr_SamInfo3(dst, server_info->info3); if (!dst->info3) { TALLOC_FREE(dst); return NULL; } dst->unix_name = talloc_strdup(dst, src->unix_info->unix_name); if (!dst->unix_name) { TALLOC_FREE(dst); return NULL; } return dst;}
开发者ID:urisimchoni,项目名称:samba,代码行数:79,
示例11: talloc_strdupstruct passwd *smb_getpwnam( TALLOC_CTX *mem_ctx, const char *domuser, char **p_save_username, bool create ){ struct passwd *pw = NULL; char *p = NULL; char *username = NULL; /* we only save a copy of the username it has been mangled by winbindd use default domain */ *p_save_username = NULL; /* don't call map_username() here since it has to be done higher up the stack so we don't call it multiple times */ username = talloc_strdup(mem_ctx, domuser); if (!username) { return NULL; } p = strchr_m( username, *lp_winbind_separator() ); /* code for a DOMAIN/user string */ if ( p ) { pw = Get_Pwnam_alloc( mem_ctx, domuser ); if ( pw ) { /* make sure we get the case of the username correct */ /* work around 'winbind use default domain = yes' */ if ( lp_winbind_use_default_domain() && !strchr_m( pw->pw_name, *lp_winbind_separator() ) ) { char *domain; /* split the domain and username into 2 strings */ *p = '/0'; domain = username; *p_save_username = talloc_asprintf(mem_ctx, "%s%c%s", domain, *lp_winbind_separator(), pw->pw_name); if (!*p_save_username) { TALLOC_FREE(pw); return NULL; } } else { *p_save_username = talloc_strdup(mem_ctx, pw->pw_name); } /* whew -- done! */ return pw; } /* setup for lookup of just the username */ /* remember that p and username are overlapping memory */ p++; username = talloc_strdup(mem_ctx, p); if (!username) { return NULL; } } /* just lookup a plain username */ pw = Get_Pwnam_alloc(mem_ctx, username); /* Create local user if requested but only if winbindd is not running. We need to protect against cases where winbindd is failing and then prematurely creating users in /etc/passwd */ if ( !pw && create && !winbind_ping() ) { /* Don't add a machine account. */ if (username[strlen(username)-1] == '$') return NULL; _smb_create_user(NULL, username, NULL); pw = Get_Pwnam_alloc(mem_ctx, username); } /* one last check for a valid passwd struct */ if (pw) { *p_save_username = talloc_strdup(mem_ctx, pw->pw_name); } return pw;}
开发者ID:urisimchoni,项目名称:samba,代码行数:89,
示例12: sudosrv_get_user//.........这里部分代码省略......... if (user->count > 1) { DEBUG(SSSDBG_CRIT_FAILURE, ("getpwnam call returned more than one result !?!/n")); ret = EIO; goto done; } if (user->count == 0 && !dctx->check_provider) { /* if a multidomain search, try with next */ if (cmd_ctx->check_next) { dctx->check_provider = true; dom = get_next_domain(dom, false); if (dom) continue; } DEBUG(SSSDBG_MINOR_FAILURE, ("No results for getpwnam call/n")); ret = ENOENT; goto done; } /* One result found, check cache expiry */ if (user->count == 1) { cache_expire = ldb_msg_find_attr_as_uint64(user->msgs[0], SYSDB_CACHE_EXPIRE, 0); } /* If cache miss and we haven't checked DP yet OR the entry is * outdated, go to DP */ if ((user->count == 0 || cache_expire < time(NULL)) && dctx->check_provider) { dpreq = sss_dp_get_account_send(cli_ctx, cli_ctx->rctx, dom, false, SSS_DP_INITGROUPS, cmd_ctx->username, 0, NULL); if (!dpreq) { DEBUG(SSSDBG_CRIT_FAILURE, ("Out of memory sending data provider request/n")); ret = ENOMEM; goto done; } cb_ctx = talloc_zero(cli_ctx, struct dp_callback_ctx); if(!cb_ctx) { talloc_zfree(dpreq); ret = ENOMEM; goto done; } cb_ctx->callback = sudosrv_check_user_dp_callback; cb_ctx->ptr = dctx; cb_ctx->cctx = cli_ctx; cb_ctx->mem_ctx = cli_ctx; tevent_req_set_callback(dpreq, sudosrv_dp_send_acct_req_done, cb_ctx); /* tell caller we are in an async call */ ret = EAGAIN; goto done; } /* check uid */ uid = ldb_msg_find_attr_as_int(user->msgs[0], SYSDB_UIDNUM, 0); if (uid != cmd_ctx->uid) { /* if a multidomain search, try with next */ if (cmd_ctx->check_next) { dctx->check_provider = true; dom = get_next_domain(dom, false); if (dom) continue; } DEBUG(SSSDBG_MINOR_FAILURE, ("UID does not match/n")); ret = ENOENT; goto done; } /* user is stored in cache, remember cased and original name */ original_name = ldb_msg_find_attr_as_string(user->msgs[0], SYSDB_NAME, NULL); if (original_name == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, ("A user with no name?/n")); ret = EFAULT; goto done; } cmd_ctx->cased_username = talloc_move(cmd_ctx, &name); cmd_ctx->orig_username = talloc_strdup(cmd_ctx, original_name); if (cmd_ctx->orig_username == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, ("Out of memory/n")); ret = ENOMEM; goto done; } /* and set domain */ cmd_ctx->domain = dom; DEBUG(SSSDBG_TRACE_FUNC, ("Returning info for user [%[email C++ talloc_strndup函数代码示例 C++ talloc_steal函数代码示例
|