parse_lsa.c
来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,414 行 · 第 1/5 页
C
2,414 行
BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_getsystemaccount"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("access", ps, depth, &out->access)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure.********************************************************************/BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_setsystemaccount"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) return False; if(!prs_uint32("access", ps, depth, &out->access)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_SETSYSTEMACCOUNT structure.********************************************************************/BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_setsystemaccount"); depth++; if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}static void init_lsa_string( LSA_STRING *uni, const char *string ){ init_unistr2(&uni->unistring, string, UNI_FLAGS_NONE); init_uni_hdr(&uni->hdr, &uni->unistring);}void init_lsa_q_lookup_priv_value(LSA_Q_LOOKUP_PRIV_VALUE *q_u, POLICY_HND *hnd, const char *name){ memcpy(&q_u->pol, hnd, sizeof(q_u->pol)); init_lsa_string( &q_u->privname, name );}BOOL smb_io_lsa_string( const char *desc, LSA_STRING *string, prs_struct *ps, int depth ){ prs_debug(ps, depth, desc, "smb_io_lsa_string"); depth++; if(!smb_io_unihdr ("hdr", &string->hdr, ps, depth)) return False; if(!smb_io_unistr2("unistring", &string->unistring, string->hdr.buffer, ps, depth)) return False; return True;}/******************************************************************* Reads or writes an LSA_Q_LOOKUP_PRIV_VALUE structure.********************************************************************/BOOL lsa_io_q_lookup_priv_value(const char *desc, LSA_Q_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_lookup_priv_value"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) return False; if(!smb_io_lsa_string("privname", &out->privname, ps, depth)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_LOOKUP_PRIV_VALUE structure.********************************************************************/BOOL lsa_io_r_lookup_priv_value(const char *desc, LSA_R_LOOKUP_PRIV_VALUE *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_lookup_priv_value"); depth++; if(!prs_align(ps)) return False; if(!lsa_io_luid("luid", &out->luid, ps, depth)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Reads or writes an LSA_Q_ADDPRIVS structure.********************************************************************/BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_addprivs"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) return False; if(!prs_uint32("count", ps, depth, &out->count)) return False; if (UNMARSHALLING(ps) && out->count!=0) { if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set)))) return False; if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count))) return False; } if(!lsa_io_privilege_set(desc, &out->set, ps, depth)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_ADDPRIVS structure.********************************************************************/BOOL lsa_io_r_addprivs(const char *desc, LSA_R_ADDPRIVS *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_addprivs"); depth++; if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Reads or writes an LSA_Q_REMOVEPRIVS structure.********************************************************************/BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_removeprivs"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &out->pol, ps, depth)) return False; if(!prs_uint32("allrights", ps, depth, &out->allrights)) return False; if(!prs_uint32("ptr", ps, depth, &out->ptr)) return False; /* * JFM: I'm not sure at all if the count is inside the ptr * never seen one with ptr=0 */ if (out->ptr!=0) { if(!prs_uint32("count", ps, depth, &out->count)) return False; if (UNMARSHALLING(ps) && out->count!=0) { if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set)))) return False; if (!(out->set.set = PRS_ALLOC_MEM(ps, LUID_ATTR, out->count))) return False; } if(!lsa_io_privilege_set(desc, &out->set, ps, depth)) return False; } return True;}/******************************************************************* Reads or writes an LSA_R_REMOVEPRIVS structure.********************************************************************/BOOL lsa_io_r_removeprivs(const char *desc, LSA_R_REMOVEPRIVS *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_removeprivs"); depth++; if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}BOOL policy_handle_is_valid(const POLICY_HND *hnd){ POLICY_HND zero_pol; ZERO_STRUCT(zero_pol); return ((memcmp(&zero_pol, hnd, sizeof(POLICY_HND)) == 0) ? False : True );}/******************************************************************* Reads or writes an LSA_DNS_DOM_INFO structure.********************************************************************/BOOL lsa_io_dns_dom_info(const char *desc, LSA_DNS_DOM_INFO *info, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_dns_dom_info"); depth++; if(!prs_align(ps)) return False; if(!smb_io_unihdr("nb_name", &info->hdr_nb_dom_name, ps, depth)) return False; if(!smb_io_unihdr("dns_name", &info->hdr_dns_dom_name, ps, depth)) return False; if(!smb_io_unihdr("forest", &info->hdr_forest_name, ps, depth)) return False; if(!prs_align(ps)) return False; if ( !smb_io_uuid("dom_guid", &info->dom_guid, ps, depth) ) return False; if(!prs_align(ps)) return False; if(!prs_uint32("dom_sid", ps, depth, &info->ptr_dom_sid)) return False; if(!smb_io_unistr2("nb_name", &info->uni_nb_dom_name, info->hdr_nb_dom_name.buffer, ps, depth)) return False; if(!smb_io_unistr2("dns_name", &info->uni_dns_dom_name, info->hdr_dns_dom_name.buffer, ps, depth)) return False; if(!smb_io_unistr2("forest", &info->uni_forest_name, info->hdr_forest_name.buffer, ps, depth)) return False; if(!smb_io_dom_sid2("dom_sid", &info->dom_sid, ps, depth)) return False; return True; }/******************************************************************* Inits an LSA_Q_QUERY_INFO2 structure.********************************************************************/void init_q_query2(LSA_Q_QUERY_INFO2 *in, POLICY_HND *hnd, uint16 info_class){ DEBUG(5, ("init_q_query2\n")); memcpy(&in->pol, hnd, sizeof(in->pol)); in->info_class = info_class;}/******************************************************************* Reads or writes an LSA_Q_QUERY_DNSDOMINFO structure.********************************************************************/BOOL lsa_io_q_query_info2(const char *desc, LSA_Q_QUERY_INFO2 *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_query_info2"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &in->pol, ps, depth)) return False; if(!prs_uint16("info_class", ps, depth, &in->info_class)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_QUERY_DNSDOMINFO structure.********************************************************************/BOOL lsa_io_r_query_info2(const char *desc, LSA_R_QUERY_INFO2 *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_query_info2"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("ptr", ps, depth, &out->ptr)) return False; if(!prs_uint16("info_class", ps, depth, &out->info_class)) return False; switch(out->info_class) { case 0x000c: if (!lsa_io_dns_dom_info("info12", &out->info.dns_dom_info, ps, depth)) return False; break; default: DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n", out->info_class)); return False; } if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Inits an LSA_Q_ENUM_ACCT_RIGHTS structure.********************************************************************/void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *in, POLICY_HND *hnd, uint32 count, DOM_SID *sid){ DEBUG(5, ("init_q_enum_acct_rights\n")); in->pol = *hnd; init_dom_sid2(&in->sid, sid);}/***************************************************************************************************************************************/NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *privileges ){ uint32 i; char *privname; const char **privname_array = NULL; int num_priv = 0; for ( i=0; i<privileges->count; i++ ) { privname = luid_to_privilege_name( &privileges->set[i].luid ); if ( privname ) { if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) ) return NT_STATUS_NO_MEMORY; } } if ( num_priv ) { out->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); if ( !init_unistr4_array( out->rights, num_priv, privname_array ) ) return NT_STATUS_NO_MEMORY; out->count = num_priv; } return NT_STATUS_OK;}/*******************************************************************reads or writes a LSA_Q_ENUM_ACCT_RIGHTS structure.********************************************************************/BOOL lsa_io_q_enum_acct_rights(const char *desc, LSA_Q_ENUM_ACCT_RIGHTS *in, prs_struct *ps, int depth){ if (in == NULL) return False; prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights"); depth++; if (!smb_io_pol_hnd("", &in->pol, ps, depth)) return False; if(!smb_io_dom_sid2("sid", &in->sid, ps, depth)) return False; return True;}/*******************************************************************reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure.********************************************************************/BOOL lsa_io_r_enum_acct_rights(const char *desc, LSA_R_ENUM_ACCT_RIGHTS *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights"); depth++; if(!prs_uint32("count ", ps, depth, &out->count)) return False; if ( !prs_pointer("rights", ps, depth, (void**)&out->rights, sizeof(UNISTR4_ARRAY), (PRS_POINTER_CAST)prs_unistr4_array) ) return False; if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Inits an LSA_Q_ADD_ACCT_RIGHTS structure.********************************************************************/void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd, DOM_SID *sid, uint32 count, const char **rights ){ DEBUG(5, ("init_q_add_acct_rights\n")); in->pol = *hnd; init_dom_sid2(&in->sid, sid); in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); init_unistr4_array( in->rights, count, rights ); in->count = count;}/*******************************************************************reads or writes a LSA_Q_ADD_ACCT_RIGHTS structure.********************************************************************/BOOL lsa_io_q_add_acct_rights(const char *desc, LSA_Q_ADD_ACCT_RIGHTS *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights"); depth++; if (!smb_io_pol_hnd("", &in->pol, ps, depth)) return False; if(!smb_io_dom_si
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?