parse_lsa.c
来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,414 行 · 第 1/5 页
C
2,414 行
/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, * Copyright (C) Paul Ashton 1997, * Copyright (C) Andrew Bartlett 2002, * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002. * Copyright (C) Gerald )Jerry) Carter 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */#include "includes.h"#undef DBGC_CLASS#define DBGC_CLASS DBGC_RPC_PARSEstatic BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_struct *ps, int depth);/******************************************************************* Inits a LSA_TRANS_NAME structure.********************************************************************/void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name, uint16 sid_name_use, const char *name, uint32 idx){ trn->sid_name_use = sid_name_use; init_unistr2(uni_name, name, UNI_FLAGS_NONE); init_uni_hdr(&trn->hdr_name, uni_name); trn->domain_idx = idx;}/******************************************************************* Reads or writes a LSA_TRANS_NAME structure.********************************************************************/static BOOL lsa_io_trans_name(const char *desc, LSA_TRANS_NAME *trn, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_trans_name"); depth++; if(!prs_align(ps)) return False; if(!prs_uint16("sid_name_use", ps, depth, &trn->sid_name_use)) return False; if(!prs_align(ps)) return False; if(!smb_io_unihdr ("hdr_name", &trn->hdr_name, ps, depth)) return False; if(!prs_uint32("domain_idx ", ps, depth, &trn->domain_idx)) return False; return True;}/******************************************************************* Reads or writes a DOM_R_REF structure.********************************************************************/static BOOL lsa_io_dom_r_ref(const char *desc, DOM_R_REF *dom, prs_struct *ps, int depth){ unsigned int i; prs_debug(ps, depth, desc, "lsa_io_dom_r_ref"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("num_ref_doms_1", ps, depth, &dom->num_ref_doms_1)) /* num referenced domains? */ return False; if(!prs_uint32("ptr_ref_dom ", ps, depth, &dom->ptr_ref_dom)) /* undocumented buffer pointer. */ return False; if(!prs_uint32("max_entries ", ps, depth, &dom->max_entries)) /* 32 - max number of entries */ return False; SMB_ASSERT_ARRAY(dom->hdr_ref_dom, dom->num_ref_doms_1); if (dom->ptr_ref_dom != 0) { if(!prs_uint32("num_ref_doms_2", ps, depth, &dom->num_ref_doms_2)) /* 4 - num referenced domains? */ return False; SMB_ASSERT_ARRAY(dom->ref_dom, dom->num_ref_doms_2); for (i = 0; i < dom->num_ref_doms_1; i++) { fstring t; slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); if(!smb_io_unihdr(t, &dom->hdr_ref_dom[i].hdr_dom_name, ps, depth)) return False; slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i); if(!prs_uint32(t, ps, depth, &dom->hdr_ref_dom[i].ptr_dom_sid)) return False; } for (i = 0; i < dom->num_ref_doms_2; i++) { fstring t; if (dom->hdr_ref_dom[i].hdr_dom_name.buffer != 0) { slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); if(!smb_io_unistr2(t, &dom->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */ return False; if(!prs_align(ps)) return False; } if (dom->hdr_ref_dom[i].ptr_dom_sid != 0) { slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i); if(!smb_io_dom_sid2(t, &dom->ref_dom[i].ref_dom, ps, depth)) /* referenced domain SIDs */ return False; } } } return True;}/******************************************************************* Inits an LSA_SEC_QOS structure.********************************************************************/void init_lsa_sec_qos(LSA_SEC_QOS *qos, uint16 imp_lev, uint8 ctxt, uint8 eff){ DEBUG(5, ("init_lsa_sec_qos\n")); qos->len = 0x0c; /* length of quality of service block, in bytes */ qos->sec_imp_level = imp_lev; qos->sec_ctxt_mode = ctxt; qos->effective_only = eff;}/******************************************************************* Reads or writes an LSA_SEC_QOS structure.********************************************************************/static BOOL lsa_io_sec_qos(const char *desc, LSA_SEC_QOS *qos, prs_struct *ps, int depth){ uint32 start; prs_debug(ps, depth, desc, "lsa_io_obj_qos"); depth++; if(!prs_align(ps)) return False; start = prs_offset(ps); /* these pointers had _better_ be zero, because we don't know what they point to! */ if(!prs_uint32("len ", ps, depth, &qos->len)) /* 0x18 - length (in bytes) inc. the length field. */ return False; if(!prs_uint16("sec_imp_level ", ps, depth, &qos->sec_imp_level )) return False; if(!prs_uint8 ("sec_ctxt_mode ", ps, depth, &qos->sec_ctxt_mode )) return False; if(!prs_uint8 ("effective_only", ps, depth, &qos->effective_only)) return False; if (qos->len != prs_offset(ps) - start) { DEBUG(3,("lsa_io_sec_qos: length %x does not match size %x\n", qos->len, prs_offset(ps) - start)); } return True;}/******************************************************************* Inits an LSA_OBJ_ATTR structure.********************************************************************/static void init_lsa_obj_attr(LSA_OBJ_ATTR *attr, uint32 attributes, LSA_SEC_QOS *qos){ DEBUG(5, ("init_lsa_obj_attr\n")); attr->len = 0x18; /* length of object attribute block, in bytes */ attr->ptr_root_dir = 0; attr->ptr_obj_name = 0; attr->attributes = attributes; attr->ptr_sec_desc = 0; if (qos != NULL) { attr->ptr_sec_qos = 1; attr->sec_qos = qos; } else { attr->ptr_sec_qos = 0; attr->sec_qos = NULL; }}/******************************************************************* Reads or writes an LSA_OBJ_ATTR structure.********************************************************************/static BOOL lsa_io_obj_attr(const char *desc, LSA_OBJ_ATTR *attr, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_obj_attr"); depth++; if(!prs_align(ps)) return False; /* these pointers had _better_ be zero, because we don't know what they point to! */ if(!prs_uint32("len ", ps, depth, &attr->len)) /* 0x18 - length (in bytes) inc. the length field. */ return False; if(!prs_uint32("ptr_root_dir", ps, depth, &attr->ptr_root_dir)) /* 0 - root directory (pointer) */ return False; if(!prs_uint32("ptr_obj_name", ps, depth, &attr->ptr_obj_name)) /* 0 - object name (pointer) */ return False; if(!prs_uint32("attributes ", ps, depth, &attr->attributes)) /* 0 - attributes (undocumented) */ return False; if(!prs_uint32("ptr_sec_desc", ps, depth, &attr->ptr_sec_desc)) /* 0 - security descriptior (pointer) */ return False; if(!prs_uint32("ptr_sec_qos ", ps, depth, &attr->ptr_sec_qos )) /* security quality of service (pointer) */ return False; if (attr->ptr_sec_qos != 0) { if (UNMARSHALLING(ps)) if (!(attr->sec_qos = PRS_ALLOC_MEM(ps,LSA_SEC_QOS,1))) return False; if(!lsa_io_sec_qos("sec_qos", attr->sec_qos, ps, depth)) return False; } return True;}/******************************************************************* Inits an LSA_Q_OPEN_POL structure.********************************************************************/void init_q_open_pol(LSA_Q_OPEN_POL *in, uint16 system_name, uint32 attributes, uint32 desired_access, LSA_SEC_QOS *qos){ DEBUG(5, ("init_open_pol: attr:%d da:%d\n", attributes, desired_access)); in->ptr = 1; /* undocumented pointer */ in->des_access = desired_access; in->system_name = system_name; init_lsa_obj_attr(&in->attr, attributes, qos);}/******************************************************************* Reads or writes an LSA_Q_OPEN_POL structure.********************************************************************/BOOL lsa_io_q_open_pol(const char *desc, LSA_Q_OPEN_POL *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_open_pol"); depth++; if(!prs_uint32("ptr ", ps, depth, &in->ptr)) return False; if(!prs_uint16("system_name", ps, depth, &in->system_name)) return False; if(!prs_align( ps )) return False; if(!lsa_io_obj_attr("", &in->attr, ps, depth)) return False; if(!prs_uint32("des_access", ps, depth, &in->des_access)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_OPEN_POL structure.********************************************************************/BOOL lsa_io_r_open_pol(const char *desc, LSA_R_OPEN_POL *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_open_pol"); depth++; if(!smb_io_pol_hnd("", &out->pol, ps, depth)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Inits an LSA_Q_OPEN_POL2 structure.********************************************************************/void init_q_open_pol2(LSA_Q_OPEN_POL2 *in, const char *server_name, uint32 attributes, uint32 desired_access, LSA_SEC_QOS *qos){ DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes, desired_access)); in->ptr = 1; /* undocumented pointer */ in->des_access = desired_access; init_unistr2(&in->uni_server_name, server_name, UNI_STR_TERMINATE); init_lsa_obj_attr(&in->attr, attributes, qos);}/******************************************************************* Reads or writes an LSA_Q_OPEN_POL2 structure.********************************************************************/BOOL lsa_io_q_open_pol2(const char *desc, LSA_Q_OPEN_POL2 *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_open_pol2"); depth++; if(!prs_uint32("ptr ", ps, depth, &in->ptr)) return False; if(!smb_io_unistr2 ("", &in->uni_server_name, in->ptr, ps, depth)) return False; if(!lsa_io_obj_attr("", &in->attr, ps, depth)) return False; if(!prs_uint32("des_access", ps, depth, &in->des_access)) return False; return True;}/******************************************************************* Reads or writes an LSA_R_OPEN_POL2 structure.********************************************************************/BOOL lsa_io_r_open_pol2(const char *desc, LSA_R_OPEN_POL2 *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_open_pol2"); depth++; if(!smb_io_pol_hnd("", &out->pol, ps, depth)) return False; if(!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/*******************************************************************makes an LSA_Q_QUERY_SEC_OBJ structure.********************************************************************/void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *in, const POLICY_HND *hnd, uint32 sec_info){ DEBUG(5, ("init_q_query_sec_obj\n")); in->pol = *hnd; in->sec_info = sec_info; return;}/******************************************************************* Reads or writes an LSA_Q_QUERY_SEC_OBJ structure.********************************************************************/BOOL lsa_io_q_query_sec_obj(const char *desc, LSA_Q_QUERY_SEC_OBJ *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj"); depth++; if (!smb_io_pol_hnd("", &in->pol, ps, depth)) return False; if (!prs_uint32("sec_info", ps, depth, &in->sec_info)) return False; return True;} /******************************************************************* Reads or writes a LSA_R_QUERY_SEC_OBJ structure.********************************************************************/BOOL lsa_io_r_query_sec_obj(const char *desc, LSA_R_QUERY_SEC_OBJ *out, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_r_query_sec_obj"); depth++; if (!prs_align(ps)) return False; if (!prs_uint32("ptr", ps, depth, &out->ptr)) return False; if (out->ptr != 0) { if (!sec_io_desc_buf("sec", &out->buf, ps, depth)) return False; } if (!prs_ntstatus("status", ps, depth, &out->status)) return False; return True;}/******************************************************************* Inits an LSA_Q_QUERY_INFO structure.********************************************************************/void init_q_query(LSA_Q_QUERY_INFO *in, POLICY_HND *hnd, uint16 info_class){ DEBUG(5, ("init_q_query\n")); memcpy(&in->pol, hnd, sizeof(in->pol)); in->info_class = info_class;}/******************************************************************* Reads or writes an LSA_Q_QUERY_INFO structure.********************************************************************/BOOL lsa_io_q_query(const char *desc, LSA_Q_QUERY_INFO *in, prs_struct *ps, int depth){ prs_debug(ps, depth, desc, "lsa_io_q_query"); depth++; if(!smb_io_pol_hnd("", &in->pol, ps, depth)) return False; if(!prs_uint16("info_class", ps, depth, &in->info_class)) return False; return True;}/*******************************************************************makes an LSA_Q_ENUM_TRUST_DOM structure.********************************************************************/BOOL init_q_enum_trust_dom(LSA_Q_ENUM_TRUST_DOM * q_e, POLICY_HND *pol, uint32 enum_context, uint32 preferred_len){ DEBUG(5, ("init_q_enum_trust_dom\n")); q_e->pol = *pol; q_e->enum_context = enum_context; q_e->preferred_len = preferred_len; return True;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?