parse_samr.c
来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,438 行 · 第 1/5 页
C
2,438 行
/* * Unix SMB/CIFS implementation. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-2000, * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, * Copyright (C) Paul Ashton 1997-2000, * Copyright (C) Elrond 2000, * Copyright (C) Jeremy Allison 2001, * Copyright (C) Jean Fran鏾is Micouleau 1998-2001, * Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2002. * * 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_PARSE/*******************************************************************inits a SAMR_Q_CLOSE_HND structure.********************************************************************/void init_samr_q_close_hnd(SAMR_Q_CLOSE_HND * q_c, POLICY_HND *hnd){ DEBUG(5, ("init_samr_q_close_hnd\n")); q_c->pol = *hnd;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_close_hnd(const char *desc, SAMR_Q_CLOSE_HND * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_close_hnd"); depth++; if(!prs_align(ps)) return False; return smb_io_pol_hnd("pol", &q_u->pol, ps, depth);}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_close_hnd(const char *desc, SAMR_R_CLOSE_HND * r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_r_close_hnd"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) return False; if(!prs_ntstatus("status", ps, depth, &r_u->status)) return False; return True;}/*******************************************************************inits a SAMR_Q_LOOKUP_DOMAIN structure.********************************************************************/void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u, POLICY_HND *pol, char *dom_name){ DEBUG(5, ("init_samr_q_lookup_domain\n")); q_u->connect_pol = *pol; init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE); init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_lookup_domain(const char *desc, SAMR_Q_LOOKUP_DOMAIN * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_lookup_domain"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("connect_pol", &q_u->connect_pol, ps, depth)) return False; if(!smb_io_unihdr("hdr_domain", &q_u->hdr_domain, ps, depth)) return False; if(!smb_io_unistr2("uni_domain", &q_u->uni_domain, q_u->hdr_domain.buffer, ps, depth)) return False; return True;}/*******************************************************************inits a SAMR_R_LOOKUP_DOMAIN structure.********************************************************************/void init_samr_r_lookup_domain(SAMR_R_LOOKUP_DOMAIN * r_u, DOM_SID *dom_sid, NTSTATUS status){ DEBUG(5, ("init_samr_r_lookup_domain\n")); r_u->status = status; r_u->ptr_sid = 0; if (NT_STATUS_IS_OK(status)) { r_u->ptr_sid = 1; init_dom_sid2(&r_u->dom_sid, dom_sid); }}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_lookup_domain(const char *desc, SAMR_R_LOOKUP_DOMAIN * r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_r_lookup_domain"); depth++; if(!prs_align(ps)) return False; if(!prs_uint32("ptr", ps, depth, &r_u->ptr_sid)) return False; if (r_u->ptr_sid != 0) { if(!smb_io_dom_sid2("sid", &r_u->dom_sid, ps, depth)) return False; if(!prs_align(ps)) return False; } if(!prs_ntstatus("status", ps, depth, &r_u->status)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/void init_samr_q_remove_sid_foreign_domain(SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, POLICY_HND *dom_pol, DOM_SID *sid){ DEBUG(5, ("samr_init_samr_q_remove_sid_foreign_domain\n")); q_u->dom_pol = *dom_pol; init_dom_sid2(&q_u->sid, sid);}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_remove_sid_foreign_domain(const char *desc, SAMR_Q_REMOVE_SID_FOREIGN_DOMAIN * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_remove_sid_foreign_domain"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth)) return False; if(!smb_io_dom_sid2("sid", &q_u->sid, ps, depth)) return False; if(!prs_align(ps)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_remove_sid_foreign_domain(const char *desc, SAMR_R_REMOVE_SID_FOREIGN_DOMAIN * r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_r_remove_sid_foreign_domain"); depth++; if(!prs_align(ps)) return False; if(!prs_ntstatus("status", ps, depth, &r_u->status)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/void init_samr_q_open_domain(SAMR_Q_OPEN_DOMAIN * q_u, POLICY_HND *pol, uint32 flags, const DOM_SID *sid){ DEBUG(5, ("samr_init_samr_q_open_domain\n")); q_u->pol = *pol; q_u->flags = flags; init_dom_sid2(&q_u->dom_sid, sid);}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_open_domain(const char *desc, SAMR_Q_OPEN_DOMAIN * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_open_domain"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) return False; if(!prs_uint32("flags", ps, depth, &q_u->flags)) return False; if(!smb_io_dom_sid2("sid", &q_u->dom_sid, ps, depth)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_open_domain(const char *desc, SAMR_R_OPEN_DOMAIN * r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_r_open_domain"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("domain_pol", &r_u->domain_pol, ps, depth)) return False; if(!prs_ntstatus("status", ps, depth, &r_u->status)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/void init_samr_q_get_usrdom_pwinfo(SAMR_Q_GET_USRDOM_PWINFO * q_u, POLICY_HND *user_pol){ DEBUG(5, ("samr_init_samr_q_get_usrdom_pwinfo\n")); q_u->user_pol = *user_pol;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_get_usrdom_pwinfo(const char *desc, SAMR_Q_GET_USRDOM_PWINFO * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_get_usrdom_pwinfo"); depth++; if(!prs_align(ps)) return False; return smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth);}/******************************************************************* Init.********************************************************************/void init_samr_r_get_usrdom_pwinfo(SAMR_R_GET_USRDOM_PWINFO *r_u, NTSTATUS status){ DEBUG(5, ("init_samr_r_get_usrdom_pwinfo\n")); r_u->unknown_0 = 0x0000; /* * used to be * r_u->unknown_1 = 0x0015; * but for trusts. */ r_u->unknown_1 = 0x01D1; r_u->unknown_1 = 0x0015; r_u->unknown_2 = 0x00000000; r_u->status = status;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_r_get_usrdom_pwinfo(const char *desc, SAMR_R_GET_USRDOM_PWINFO * r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_r_get_usrdom_pwinfo"); depth++; if(!prs_align(ps)) return False; if(!prs_uint16("unknown_0", ps, depth, &r_u->unknown_0)) return False; if(!prs_uint16("unknown_1", ps, depth, &r_u->unknown_1)) return False; if(!prs_uint32("unknown_2", ps, depth, &r_u->unknown_2)) return False; if(!prs_ntstatus("status ", ps, depth, &r_u->status)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_set_sec_obj(const char *desc, SAMR_Q_SET_SEC_OBJ * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_set_sec_obj"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) return False; if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) return False; if(!sec_io_desc_buf("sec_desc", &q_u->buf, ps, depth)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/void init_samr_q_query_sec_obj(SAMR_Q_QUERY_SEC_OBJ * q_u, POLICY_HND *user_pol, uint32 sec_info){ DEBUG(5, ("samr_init_samr_q_query_sec_obj\n")); q_u->user_pol = *user_pol; q_u->sec_info = sec_info;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_query_sec_obj(const char *desc, SAMR_Q_QUERY_SEC_OBJ * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_query_sec_obj"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth)) return False; if(!prs_uint32("sec_info", ps, depth, &q_u->sec_info)) return False; return True;}/*******************************************************************reads or writes a structure.********************************************************************/void init_samr_q_query_dom_info(SAMR_Q_QUERY_DOMAIN_INFO * q_u, POLICY_HND *domain_pol, uint16 switch_value){ DEBUG(5, ("samr_init_samr_q_query_dom_info\n")); q_u->domain_pol = *domain_pol; q_u->switch_value = switch_value;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_query_dom_info(const char *desc, SAMR_Q_QUERY_DOMAIN_INFO * q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "samr_io_q_query_dom_info"); depth++; if(!prs_align(ps)) return False; if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth))
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?