diff options
Diffstat (limited to 'source4/rpc_parse')
-rw-r--r-- | source4/rpc_parse/parse_dfs.c | 546 | ||||
-rw-r--r-- | source4/rpc_parse/parse_ds.c | 122 | ||||
-rw-r--r-- | source4/rpc_parse/parse_lsa.c | 2525 | ||||
-rw-r--r-- | source4/rpc_parse/parse_misc.c | 1784 | ||||
-rw-r--r-- | source4/rpc_parse/parse_net.c | 2971 | ||||
-rw-r--r-- | source4/rpc_parse/parse_prs.c | 1329 | ||||
-rw-r--r-- | source4/rpc_parse/parse_reg.c | 1872 | ||||
-rw-r--r-- | source4/rpc_parse/parse_rpc.c | 1106 | ||||
-rw-r--r-- | source4/rpc_parse/parse_samr.c | 7448 | ||||
-rw-r--r-- | source4/rpc_parse/parse_sec.c | 1028 | ||||
-rw-r--r-- | source4/rpc_parse/parse_spoolss.c | 7751 | ||||
-rw-r--r-- | source4/rpc_parse/parse_srv.c | 3590 | ||||
-rw-r--r-- | source4/rpc_parse/parse_wks.c | 178 |
13 files changed, 0 insertions, 32250 deletions
diff --git a/source4/rpc_parse/parse_dfs.c b/source4/rpc_parse/parse_dfs.c deleted file mode 100644 index 6f13500359..0000000000 --- a/source4/rpc_parse/parse_dfs.c +++ /dev/null @@ -1,546 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * MSDfs RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-2000, - * Copyright (C) Luke Kenneth Casson Leighton 1996-2000, - * Copyright (C) Shirish Kalele 2000. - * Copyright (C) Jeremy Allison 2001. - * - * 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" -#include "nterr.h" -#include "rpc_parse.h" - -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE - -/******************************************************************* -Make a DFS_Q_DFS_QUERY structure -*******************************************************************/ - -void init_dfs_q_dfs_exist(DFS_Q_DFS_EXIST *q_d) -{ - q_d->dummy = 0; -} - -/************************************************************* - Read/write a DFS_Q_DFS_EXIST structure - dummy... - ************************************************************/ - -BOOL dfs_io_q_dfs_exist(const char *desc, DFS_Q_DFS_EXIST *q_d, prs_struct *ps, int depth) -{ - if(q_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_q_dfs_exist"); - - return True; -} - -/************************************************************* - Read/write a DFS_R_DFS_EXIST structure - ************************************************************/ - -BOOL dfs_io_r_dfs_exist(const char *desc, DFS_R_DFS_EXIST *q_d, prs_struct *ps, int depth) -{ - if(q_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_r_dfs_exist"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("exist flag", ps, 0, &q_d->status)) - return False; - - return True; -} - -/******************************************************************* -Make a DFS_Q_DFS_REMOVE structure -*******************************************************************/ - -BOOL init_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, const char *entrypath, - const char *servername, const char *sharename) -{ - DEBUG(5,("init_dfs_q_dfs_remove\n")); - init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1); - init_unistr2(&q_d->ServerName, servername, strlen(servername)+1); - init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1); - q_d->ptr_ServerName = q_d->ptr_ShareName = 1; - return True; -} - -/******************************************************************* -Read/write a DFS_Q_DFS_REMOVE structure -*******************************************************************/ - -BOOL dfs_io_q_dfs_remove(const char *desc, DFS_Q_DFS_REMOVE *q_d, prs_struct *ps, int depth) -{ - if(q_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_q_dfs_remove"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("DfsEntryPath",&q_d->DfsEntryPath, 1, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_ServerName", ps, depth, &q_d->ptr_ServerName)) - return False; - if(q_d->ptr_ServerName) - if (!smb_io_unistr2("ServerName",&q_d->ServerName, q_d->ptr_ServerName, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_ShareName", ps, depth, &q_d->ptr_ShareName)) - return False; - if(q_d->ptr_ShareName) - if (!smb_io_unistr2("ShareName",&q_d->ShareName, q_d->ptr_ShareName, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -Read/write a DFS_R_DFS_REMOVE structure -*******************************************************************/ - -BOOL dfs_io_r_dfs_remove(const char *desc, DFS_R_DFS_REMOVE *r_d, prs_struct *ps, int depth) -{ - if(r_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_r_dfs_remove"); - depth++; - - if(!prs_werror("status", ps, depth, &r_d->status)) - return False; - - return True; -} - -/******************************************************************* -Make a DFS_Q_DFS_ADD structure -*******************************************************************/ - -BOOL init_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, const char *entrypath, - const char *servername, const char *sharename, - const char *comment, uint32 flags) -{ - DEBUG(5,("init_dfs_q_dfs_add\n")); - q_d->ptr_DfsEntryPath = q_d->ptr_ServerName = q_d->ptr_ShareName = 1; - init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1); - init_unistr2(&q_d->ServerName, servername, strlen(servername)+1); - init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1); - if(comment != NULL) { - init_unistr2(&q_d->Comment, comment, strlen(comment)+1); - q_d->ptr_Comment = 1; - } else { - q_d->ptr_Comment = 0; - } - - q_d->Flags = flags; - return True; -} - -/************************************************************ - Read/write a DFS_Q_DFS_ADD structure - ************************************************************/ - -BOOL dfs_io_q_dfs_add(const char *desc, DFS_Q_DFS_ADD *q_d, prs_struct *ps, int depth) -{ - if(q_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_q_dfs_add"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("DfsEntryPath",&q_d->DfsEntryPath, 1, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("ServerName",&q_d->ServerName, 1, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_ShareName", ps, depth, &q_d->ptr_ShareName)) - return False; - if(!smb_io_unistr2("ShareName",&q_d->ShareName, 1, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_Comment", ps, depth, &q_d->ptr_Comment)) - return False; - if(!smb_io_unistr2("",&q_d->Comment, q_d->ptr_Comment , ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("Flags", ps, depth, &q_d->Flags)) - return True; - - return True; -} - -/************************************************************ - Read/write a DFS_R_DFS_ADD structure - ************************************************************/ - -BOOL dfs_io_r_dfs_add(const char *desc, DFS_R_DFS_ADD *r_d, prs_struct *ps, int depth) -{ - if(r_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_r_dfs_add"); - depth++; - - if(!prs_werror("status", ps, depth, &r_d->status)) - return False; - - return True; -} - -BOOL init_dfs_q_dfs_get_info(DFS_Q_DFS_GET_INFO *q_d, const char *entrypath, - const char *servername, const char *sharename, - uint32 info_level) -{ - DEBUG(5,("init_dfs_q2_get_info\n")); - init_unistr2(&q_d->uni_path, entrypath, strlen(entrypath)+1); - init_unistr2(&q_d->uni_server, servername, strlen(servername)+1); - init_unistr2(&q_d->uni_share, sharename, strlen(sharename)+1); - q_d->level = info_level; - q_d->ptr_server = q_d->ptr_share = 1; - return True; -} - -/************************************************************ - Read/write a DFS_Q_GET_INFO structure - ************************************************************/ - -BOOL dfs_io_q_dfs_get_info(const char *desc, DFS_Q_DFS_GET_INFO* q_i, prs_struct* ps, int depth) -{ - if(q_i == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_q_dfs_get_info"); - depth++; - - if(!smb_io_unistr2("",&q_i->uni_path, 1, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_server", ps, depth, &q_i->ptr_server)) - return False; - - if(q_i->ptr_server) - if (!smb_io_unistr2("",&q_i->uni_server, q_i->ptr_server, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_share", ps, depth, &q_i->ptr_share)) - return False; - if(q_i->ptr_share) - if(!smb_io_unistr2("", &q_i->uni_share, q_i->ptr_share, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_i->level)) - return False; - return True; -} - -/************************************************************ - Read/write a DFS_R_GET_INFO structure - ************************************************************/ - -BOOL dfs_io_r_dfs_get_info(const char *desc, DFS_R_DFS_GET_INFO* r_i, prs_struct* ps, int depth) -{ - if(r_i == NULL) - return False; - - if(!prs_uint32("level", ps, depth, &r_i->level)) - return False; - if(!prs_uint32("ptr_ctr", ps, depth, &r_i->ptr_ctr)) - return False; - - if(!dfs_io_dfs_info_ctr("", &r_i->ctr, 1, r_i->level, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_i->status)) - return False; - return True; -} - -/************************************************************ - Make a DFS_Q_DFS_ENUM structure - ************************************************************/ -BOOL init_dfs_q_dfs_enum(DFS_Q_DFS_ENUM *q_d, uint32 level, DFS_INFO_CTR *ctr) -{ - q_d->level = level; - q_d->maxpreflen = -1; - q_d->ptr_buffer = 1; - q_d->level2 = level; - - q_d->ptr_num_entries = 1; - q_d->num_entries = 0; - q_d->num_entries2 = 0; - q_d->reshnd.ptr_hnd = 1; - q_d->reshnd.handle = 0; - return True; -} - -/************************************************************ - Read or write the DFS_Q_DFS_ENUM structure - ************************************************************/ - -BOOL dfs_io_q_dfs_enum(const char *desc, DFS_Q_DFS_ENUM *q_d, prs_struct *ps, int depth) -{ - if(q_d == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_q_dfs_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_d->level)) - return False; - if(!prs_uint32("maxpreflen", ps, depth, &q_d->maxpreflen)) - return False; - if(!prs_uint32("ptr_buffer", ps, depth, &q_d->ptr_buffer)) - return False; - if(!prs_uint32("level2", ps, depth, &q_d->level2)) - return False; - if(!prs_uint32("level3", ps, depth, &q_d->level2)) - return False; - - if(!prs_uint32("ptr_num_entries", ps, depth, &q_d->ptr_num_entries)) - return False; - if(!prs_uint32("num_entries", ps, depth, &q_d->num_entries)) - return False; - if(!prs_uint32("num_entries2", ps, depth, &q_d->num_entries2)) - return False; - if(!smb_io_enum_hnd("resume_hnd",&q_d->reshnd, ps, depth)) - return False; - return True; -} - -/************************************************************ - Read/write a DFS_INFO_CTR structure - ************************************************************/ - -BOOL dfs_io_dfs_info_ctr(const char *desc, DFS_INFO_CTR* ctr, uint32 num_entries, uint32 level, prs_struct* ps, int depth) -{ - int i=0; - - switch(level) { - case 1: - depth++; - /* should depend on whether marshalling or unmarshalling! */ - if(UNMARSHALLING(ps)) { - ctr->dfs.info1 = (DFS_INFO_1 *)prs_alloc_mem(ps, sizeof(DFS_INFO_1)*num_entries); - if (!ctr->dfs.info1) - return False; - } - - for(i=0;i<num_entries;i++) { - if(!prs_uint32("ptr_entrypath",ps, depth, &ctr->dfs.info1[i].ptr_entrypath)) - return False; - } - for(i=0;i<num_entries;i++) { - if(!smb_io_unistr2("", &ctr->dfs.info1[i].entrypath, ctr->dfs.info1[i].ptr_entrypath, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - depth--; - break; - case 2: - depth++; - if(UNMARSHALLING(ps)) { - ctr->dfs.info2 = (DFS_INFO_2 *)prs_alloc_mem(ps, num_entries*sizeof(DFS_INFO_2)); - if (!ctr->dfs.info2) - return False; - } - - for(i=0;i<num_entries;i++) { - if(!prs_uint32("ptr_entrypath", ps, depth, &ctr->dfs.info2[i].ptr_entrypath)) - return False; - if(!prs_uint32("ptr_comment", ps, depth, &ctr->dfs.info2[i].ptr_comment)) - return False; - if(!prs_uint32("state", ps, depth, &ctr->dfs.info2[i].state)) - return False; - if(!prs_uint32("num_storages", ps, depth, &ctr->dfs.info2[i].num_storages)) - return False; - } - for(i=0;i<num_entries;i++) { - if(!smb_io_unistr2("", &ctr->dfs.info2[i].entrypath, ctr->dfs.info2[i].ptr_entrypath, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("",&ctr->dfs.info2[i].comment, ctr->dfs.info2[i].ptr_comment, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - depth--; - break; - case 3: - depth++; - if(UNMARSHALLING(ps)) { - ctr->dfs.info3 = (DFS_INFO_3 *)prs_alloc_mem(ps, num_entries*sizeof(DFS_INFO_3)); - if (!ctr->dfs.info3) - return False; - } - - for(i=0;i<num_entries;i++) { - if(!prs_uint32("ptr_entrypath", ps, depth, &ctr->dfs.info3[i].ptr_entrypath)) - return False; - if(!prs_uint32("ptr_comment", ps, depth, &ctr->dfs.info3[i].ptr_comment)) - return False; - if(!prs_uint32("state", ps, depth, &ctr->dfs.info3[i].state)) - return False; - if(!prs_uint32("num_storages", ps, depth, &ctr->dfs.info3[i].num_storages)) - return False; - if(!prs_uint32("ptr_storages", ps, depth, &ctr->dfs.info3[i].ptr_storages)) - return False; - } - for(i=0;i<num_entries;i++) { - if(!smb_io_unistr2("", &ctr->dfs.info3[i].entrypath, ctr->dfs.info3[i].ptr_entrypath, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("", &ctr->dfs.info3[i].comment, ctr->dfs.info3[i].ptr_comment, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_storage_infos", ps, depth, &ctr->dfs.info3[i].num_storage_infos)) - return False; - - if(!dfs_io_dfs_storage_info("storage_info", &ctr->dfs.info3[i], ps, depth)) - return False; - } - } - - return True; -} - -/************************************************************ - Read/write a DFS_R_DFS_ENUM structure - ************************************************************/ - -BOOL dfs_io_r_dfs_enum(const char *desc, DFS_R_DFS_ENUM *q_d, prs_struct *ps, int depth) -{ - DFS_INFO_CTR *ctr; - if(q_d == NULL) - return False; - ctr = q_d->ctr; - if(ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "dfs_io_r_dfs_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_buffer", ps, depth, &q_d->ptr_buffer)) - return False; - if(!prs_uint32("level", ps, depth, &q_d->level)) - return False; - if(!prs_uint32("level2", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_num_entries", ps, depth, &q_d->ptr_num_entries)) - return False; - if(q_d->ptr_num_entries) - if(!prs_uint32("num_entries", ps, depth, &q_d->num_entries)) - return False; - if(!prs_uint32("ptr_num_entries2", ps, depth, &q_d->ptr_num_entries2)) - return False; - if(q_d->ptr_num_entries2) - if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries)) - return False; - - if(!dfs_io_dfs_info_ctr("", ctr, q_d->num_entries, q_d->level, ps, depth)) - return False; - - if(!smb_io_enum_hnd("resume_hnd", &q_d->reshnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &q_d->status)) - return False; - return True; -} - -BOOL dfs_io_dfs_storage_info(const char *desc, DFS_INFO_3* info3, prs_struct *ps, int depth) -{ - int i=0; - if(info3 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dfs_storage_info"); - depth++; - - if(UNMARSHALLING(ps)) { - info3->storages = (DFS_STORAGE_INFO *)prs_alloc_mem(ps, info3->num_storage_infos*sizeof(DFS_STORAGE_INFO)); - if (!info3->storages) - return False; - } - - for(i=0;i<info3->num_storage_infos;i++) { - if(!prs_uint32("storage_state", ps, depth, &info3->storages[i].state)) - return False; - if(!prs_uint32("ptr_servername", ps, depth, &info3->storages[i].ptr_servername)) - return False; - if(!prs_uint32("ptr_sharename", ps, depth, &info3->storages[i].ptr_sharename)) - return False; - } - - for(i=0;i<info3->num_storage_infos;i++) { - if(!smb_io_unistr2("servername", &info3->storages[i].servername, info3->storages[i].ptr_servername, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("sharename", &info3->storages[i].sharename, info3->storages[i].ptr_sharename, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - - return True; -} diff --git a/source4/rpc_parse/parse_ds.c b/source4/rpc_parse/parse_ds.c deleted file mode 100644 index ab07631831..0000000000 --- a/source4/rpc_parse/parse_ds.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Unix SMB/CIFS implementation. - * RPC Pipe client / server routines - * Copyright (C) Gerald Carter 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" - -static BOOL ds_io_dominfobasic( const char *desc, prs_struct *ps, int depth, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic) -{ - DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic; - - if ( UNMARSHALLING(ps) ) - p = *basic = (DSROLE_PRIMARY_DOMAIN_INFO_BASIC *)prs_alloc_mem(ps, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC)); - - if ( !p ) - return False; - - if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) ) - return False; - if ( !prs_uint16("unknown", ps, depth, &p->unknown) ) - return False; - - if ( !prs_uint32("flags", ps, depth, &p->flags) ) - return False; - - if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) ) - return False; - if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) ) - return False; - if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) ) - return False; - - if ( !prs_uint8s(False, "domain_guid", ps, depth, p->domain_guid.info, GUID_SIZE) ) - return False; - - if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) ) - return False; - if ( !prs_align(ps) ) - return False; - - if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) ) - return False; - if ( !prs_align(ps) ) - return False; - - if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) ) - return False; - if ( !prs_align(ps) ) - return False; - - - return True; - -} - -BOOL ds_io_q_getprimdominfo( const char *desc, DS_Q_GETPRIMDOMINFO *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "ds_io_q_getprimdominfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_uint16( "level", ps, depth, &q_u->level ) ) - return False; - - return True; -} - -BOOL ds_io_r_getprimdominfo( const char *desc, DS_R_GETPRIMDOMINFO *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "ds_io_r_getprimdominfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if ( !prs_uint32( "ptr", ps, depth, &r_u->ptr ) ) - return False; - - if ( r_u->ptr ) - { - if ( !prs_uint16( "level", ps, depth, &r_u->level ) ) - return False; - - if ( !prs_uint16( "unknown0", ps, depth, &r_u->unknown0 ) ) - return False; - - switch ( r_u->level ) - { - case DsRolePrimaryDomainInfoBasic: - if ( !ds_io_dominfobasic( "dominfobasic", ps, depth, &r_u->info.basic ) ) - return False; - break; - default: - return False; - } - } - - if ( !prs_align(ps) ) - return False; - - if ( !prs_ntstatus("status", ps, depth, &r_u->status ) ) - return False; - - return True; -} diff --git a/source4/rpc_parse/parse_lsa.c b/source4/rpc_parse/parse_lsa.c deleted file mode 100644 index 53a0fc958d..0000000000 --- a/source4/rpc_parse/parse_lsa.c +++ /dev/null @@ -1,2525 +0,0 @@ -/* - * 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 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 - -static 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) -{ - int len_name = strlen(name); - - if(len_name == 0) - len_name = 1; - - trn->sid_name_use = sid_name_use; - init_uni_hdr(&trn->hdr_name, len_name); - init_unistr2(uni_name, name, len_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 *r_r, prs_struct *ps, - int depth) -{ - 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, &r_r->num_ref_doms_1)) /* num referenced domains? */ - return False; - if(!prs_uint32("ptr_ref_dom ", ps, depth, &r_r->ptr_ref_dom)) /* undocumented buffer pointer. */ - return False; - if(!prs_uint32("max_entries ", ps, depth, &r_r->max_entries)) /* 32 - max number of entries */ - return False; - - SMB_ASSERT_ARRAY(r_r->hdr_ref_dom, r_r->num_ref_doms_1); - - if (r_r->ptr_ref_dom != 0) { - - if(!prs_uint32("num_ref_doms_2", ps, depth, &r_r->num_ref_doms_2)) /* 4 - num referenced domains? */ - return False; - - SMB_ASSERT_ARRAY(r_r->ref_dom, r_r->num_ref_doms_2); - - for (i = 0; i < r_r->num_ref_doms_1; i++) { - fstring t; - - slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); - if(!smb_io_unihdr(t, &r_r->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, &r_r->hdr_ref_dom[i].ptr_dom_sid)) - return False; - } - - for (i = 0; i < r_r->num_ref_doms_2; i++) { - fstring t; - - if (r_r->hdr_ref_dom[i].hdr_dom_name.buffer != 0) { - slprintf(t, sizeof(t) - 1, "dom_ref[%d] ", i); - if(!smb_io_unistr2(t, &r_r->ref_dom[i].uni_dom_name, True, ps, depth)) /* domain name unicode string */ - return False; - if(!prs_align(ps)) - return False; - } - - if (r_r->hdr_ref_dom[i].ptr_dom_sid != 0) { - slprintf(t, sizeof(t) - 1, "sid_ptr[%d] ", i); - if(!smb_io_dom_sid2(t, &r_r->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) -{ - uint32 start; - - prs_debug(ps, depth, desc, "lsa_io_obj_attr"); - 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, &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; - - /* code commented out as it's not necessary true (tested with hyena). JFM, 11/22/2001 */ -#if 0 - if (attr->len != prs_offset(ps) - start) { - DEBUG(3,("lsa_io_obj_attr: length %x does not match size %x\n", - attr->len, prs_offset(ps) - start)); - return False; - } -#endif - - if (attr->ptr_sec_qos != 0) { - if (UNMARSHALLING(ps)) - if (!(attr->sec_qos = (LSA_SEC_QOS *)prs_alloc_mem(ps,sizeof(LSA_SEC_QOS)))) - 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 *r_q, 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)); - - r_q->ptr = 1; /* undocumented pointer */ - - r_q->des_access = desired_access; - - r_q->system_name = system_name; - init_lsa_obj_attr(&r_q->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 *r_q, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_open_pol"); - depth++; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - if(!prs_uint16("system_name", ps, depth, &r_q->system_name)) - return False; - if(!prs_align( ps )) - return False; - - if(!lsa_io_obj_attr("", &r_q->attr, ps, depth)) - return False; - - if(!prs_uint32("des_access", ps, depth, &r_q->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 *r_p, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_open_pol"); - depth++; - - if(!smb_io_pol_hnd("", &r_p->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_p->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_Q_OPEN_POL2 structure. -********************************************************************/ - -void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, 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)); - - r_q->ptr = 1; /* undocumented pointer */ - - r_q->des_access = desired_access; - - init_unistr2(&r_q->uni_server_name, server_name, - strlen(server_name) + 1); - - init_lsa_obj_attr(&r_q->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 *r_q, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_open_pol2"); - depth++; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - - if(!smb_io_unistr2 ("", &r_q->uni_server_name, r_q->ptr, ps, depth)) - return False; - if(!lsa_io_obj_attr("", &r_q->attr, ps, depth)) - return False; - - if(!prs_uint32("des_access", ps, depth, &r_q->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 *r_p, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_open_pol2"); - depth++; - - if(!smb_io_pol_hnd("", &r_p->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_p->status)) - return False; - - return True; -} - -/******************************************************************* -makes an LSA_Q_QUERY_SEC_OBJ structure. -********************************************************************/ - -void init_q_query_sec_obj(LSA_Q_QUERY_SEC_OBJ *q_q, const POLICY_HND *hnd, - uint32 sec_info) -{ - DEBUG(5, ("init_q_query_sec_obj\n")); - - q_q->pol = *hnd; - q_q->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 *q_q, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_query_sec_obj"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if (!prs_uint32("sec_info", ps, depth, &q_q->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 *r_u, - 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, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - if (!sec_io_desc_buf("sec", &r_u->buf, ps, depth)) - return False; - } - - if (!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_Q_QUERY_INFO structure. -********************************************************************/ - -void init_q_query(LSA_Q_QUERY_INFO *q_q, POLICY_HND *hnd, uint16 info_class) -{ - DEBUG(5, ("init_q_query\n")); - - memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); - - q_q->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 *q_q, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_query"); - depth++; - - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!prs_uint16("info_class", ps, depth, &q_q->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; -} - -/******************************************************************* - Reads or writes an LSA_Q_ENUM_TRUST_DOM structure. -********************************************************************/ - -BOOL lsa_io_q_enum_trust_dom(const char *desc, LSA_Q_ENUM_TRUST_DOM *q_e, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_enum_trust_dom"); - depth++; - - if(!smb_io_pol_hnd("", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("enum_context ", ps, depth, &q_e->enum_context)) - return False; - if(!prs_uint32("preferred_len", ps, depth, &q_e->preferred_len)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_TRUST_DOM structure. -********************************************************************/ - -void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 enum_context, - uint32 req_num_domains, uint32 num_domains, TRUSTDOM **td) -{ - int i; - - DEBUG(5, ("init_r_enum_trust_dom\n")); - - r_e->enum_context = enum_context; - r_e->num_domains = num_domains; - r_e->ptr_enum_domains = 0; - r_e->num_domains2 = num_domains; - - if (num_domains != 0) { - - /* - * allocating empty arrays of unicode headers, strings - * and sids of enumerated trusted domains - */ - if (!(r_e->hdr_domain_name = (UNIHDR2 *)talloc(ctx,sizeof(UNIHDR2) * num_domains))) { - r_e->status = NT_STATUS_NO_MEMORY; - return; - } - - if (!(r_e->uni_domain_name = (UNISTR2 *)talloc(ctx,sizeof(UNISTR2) * num_domains))) { - r_e->status = NT_STATUS_NO_MEMORY; - return; - } - - if (!(r_e->domain_sid = (DOM_SID2 *)talloc(ctx,sizeof(DOM_SID2) * num_domains))) { - r_e->status = NT_STATUS_NO_MEMORY; - return; - } - - for (i = 0; i < num_domains; i++) { - - /* don't know what actually is this for */ - r_e->ptr_enum_domains = 1; - - init_uni_hdr2(&r_e->hdr_domain_name[i], strlen_w((td[i])->name)); - init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid); - - init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name); - - }; - } - -} - -/******************************************************************* - Reads or writes an LSA_R_ENUM_TRUST_DOM structure. -********************************************************************/ - -BOOL lsa_io_r_enum_trust_dom(const char *desc, LSA_R_ENUM_TRUST_DOM *r_e, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_trust_dom"); - depth++; - - if(!prs_uint32("enum_context ", ps, depth, &r_e->enum_context)) - return False; - if(!prs_uint32("num_domains ", ps, depth, &r_e->num_domains)) - return False; - if(!prs_uint32("ptr_enum_domains", ps, depth, &r_e->ptr_enum_domains)) - return False; - - if (r_e->ptr_enum_domains) { - int i, num_domains; - - if(!prs_uint32("num_domains2", ps, depth, &r_e->num_domains2)) - return False; - - num_domains = r_e->num_domains2; - - if (UNMARSHALLING(ps)) { - if (!(r_e->hdr_domain_name = (UNIHDR2 *)prs_alloc_mem(ps,sizeof(UNIHDR2) * num_domains))) - return False; - - if (!(r_e->uni_domain_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2) * num_domains))) - return False; - - if (!(r_e->domain_sid = (DOM_SID2 *)prs_alloc_mem(ps,sizeof(DOM_SID2) * num_domains))) - return False; - } - - for (i = 0; i < num_domains; i++) { - if(!smb_io_unihdr2 ("", &r_e->hdr_domain_name[i], ps, - depth)) - return False; - } - - for (i = 0; i < num_domains; i++) { - if(!smb_io_unistr2 ("", &r_e->uni_domain_name[i], - r_e->hdr_domain_name[i].buffer, - ps, depth)) - return False; - if(!smb_io_dom_sid2("", &r_e->domain_sid[i], ps, - depth)) - return False; - } - } - - if(!prs_ntstatus("status", ps, depth, &r_e->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a dom query structure. -********************************************************************/ - -static BOOL lsa_io_dom_query(const char *desc, DOM_QUERY *d_q, prs_struct *ps, int depth) -{ - if (d_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_dom_query"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("uni_dom_max_len", ps, depth, &d_q->uni_dom_max_len)) /* domain name string length * 2 */ - return False; - if(!prs_uint16("uni_dom_str_len", ps, depth, &d_q->uni_dom_str_len)) /* domain name string length * 2 */ - return False; - - if(!prs_uint32("buffer_dom_name", ps, depth, &d_q->buffer_dom_name)) /* undocumented domain name string buffer pointer */ - return False; - if(!prs_uint32("buffer_dom_sid ", ps, depth, &d_q->buffer_dom_sid)) /* undocumented domain SID string buffer pointer */ - return False; - - if(!smb_io_unistr2("unistr2", &d_q->uni_domain_name, d_q->buffer_dom_name, ps, depth)) /* domain name (unicode string) */ - return False; - - if(!prs_align(ps)) - return False; - - if (d_q->buffer_dom_sid != 0) { - if(!smb_io_dom_sid2("", &d_q->dom_sid, ps, depth)) /* domain SID */ - return False; - } else { - memset((char *)&d_q->dom_sid, '\0', sizeof(d_q->dom_sid)); - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL lsa_io_dom_query_2(const char *desc, DOM_QUERY_2 *d_q, prs_struct *ps, int depth) -{ - uint32 ptr = 1; - - if (d_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_dom_query_2"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("auditing_enabled", ps, depth, &d_q->auditing_enabled)) - return False; - if (!prs_uint32("ptr ", ps, depth, &ptr)) - return False; - if (!prs_uint32("count1", ps, depth, &d_q->count1)) - return False; - if (!prs_uint32("count2", ps, depth, &d_q->count2)) - return False; - - if (UNMARSHALLING(ps)) { - d_q->auditsettings = (uint32 *)talloc_zero(ps->mem_ctx, d_q->count2 * sizeof(uint32)); - } - - if (d_q->auditsettings == NULL) { - DEBUG(1, ("lsa_io_dom_query_2: NULL auditsettings!\n")); - return False; - } - - if (!prs_uint32s(False, "auditsettings", ps, depth, d_q->auditsettings, d_q->count2)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a dom query structure. -********************************************************************/ - -static BOOL lsa_io_dom_query_3(const char *desc, DOM_QUERY_3 *d_q, prs_struct *ps, int depth) -{ - return lsa_io_dom_query("", d_q, ps, depth); -} - -/******************************************************************* - Reads or writes a dom query structure. -********************************************************************/ - -static BOOL lsa_io_dom_query_5(const char *desc, DOM_QUERY_5 *d_q, prs_struct *ps, int depth) -{ - return lsa_io_dom_query("", d_q, ps, depth); -} - -/******************************************************************* - Reads or writes a dom query structure. -********************************************************************/ - -static BOOL lsa_io_dom_query_6(const char *desc, DOM_QUERY_6 *d_q, prs_struct *ps, int depth) -{ - if (d_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_dom_query_6"); - depth++; - - if (!prs_uint16("server_role", ps, depth, &d_q->server_role)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_QUERY_INFO structure. -********************************************************************/ - -BOOL lsa_io_r_query(const char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_query"); - depth++; - - if(!prs_uint32("undoc_buffer", ps, depth, &r_q->undoc_buffer)) - return False; - - if (r_q->undoc_buffer != 0) { - if(!prs_uint16("info_class", ps, depth, &r_q->info_class)) - return False; - - if(!prs_align(ps)) - return False; - - switch (r_q->info_class) { - case 2: - if(!lsa_io_dom_query_2("", &r_q->dom.id2, ps, depth)) - return False; - break; - case 3: - if(!lsa_io_dom_query_3("", &r_q->dom.id3, ps, depth)) - return False; - break; - case 5: - if(!lsa_io_dom_query_5("", &r_q->dom.id5, ps, depth)) - return False; - break; - case 6: - if(!lsa_io_dom_query_6("", &r_q->dom.id6, ps, depth)) - return False; - break; - default: - /* PANIC! */ - break; - } - } - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a LSA_SID_ENUM structure. -********************************************************************/ - -static void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen, - int num_entries, DOM_SID *sids) -{ - int i; - - DEBUG(5, ("init_lsa_sid_enum\n")); - - sen->num_entries = num_entries; - sen->ptr_sid_enum = (num_entries != 0); - sen->num_entries2 = num_entries; - - /* Allocate memory for sids and sid pointers */ - - if (num_entries == 0) return; - - if ((sen->ptr_sid = (uint32 *)talloc_zero(mem_ctx, num_entries * - sizeof(uint32))) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n")); - return; - } - - if ((sen->sid = (DOM_SID2 *)talloc_zero(mem_ctx, num_entries * - sizeof(DOM_SID2))) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n")); - return; - } - - /* Copy across SIDs and SID pointers */ - - for (i = 0; i < num_entries; i++) { - sen->ptr_sid[i] = 1; - init_dom_sid2(&sen->sid[i], &sids[i]); - } -} - -/******************************************************************* - Reads or writes a LSA_SID_ENUM structure. -********************************************************************/ - -static BOOL lsa_io_sid_enum(const char *desc, LSA_SID_ENUM *sen, prs_struct *ps, - int depth) -{ - int i; - - prs_debug(ps, depth, desc, "lsa_io_sid_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &sen->num_entries)) - return False; - if(!prs_uint32("ptr_sid_enum", ps, depth, &sen->ptr_sid_enum)) - return False; - - /* - if the ptr is NULL, leave here. checked from a real w2k trace. - JFM, 11/23/2001 - */ - - if (sen->ptr_sid_enum==0) - return True; - - if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2)) - return False; - - /* Mallocate memory if we're unpacking from the wire */ - - if (UNMARSHALLING(ps)) { - if ((sen->ptr_sid = (uint32 *)prs_alloc_mem( ps, - sen->num_entries * sizeof(uint32))) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for " - "ptr_sid\n")); - return False; - } - - if ((sen->sid = (DOM_SID2 *)prs_alloc_mem( ps, - sen->num_entries * sizeof(DOM_SID2))) == NULL) { - DEBUG(3, ("init_lsa_sid_enum(): out of memory for " - "sids\n")); - return False; - } - } - - for (i = 0; i < sen->num_entries; i++) { - fstring temp; - - slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i); - if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) { - return False; - } - } - - for (i = 0; i < sen->num_entries; i++) { - fstring temp; - - slprintf(temp, sizeof(temp) - 1, "sid[%d]", i); - if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) { - return False; - } - } - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_TRUST_DOM structure. -********************************************************************/ - -void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l, - POLICY_HND *hnd, int num_sids, DOM_SID *sids, - uint16 level) -{ - DEBUG(5, ("init_r_enum_trust_dom\n")); - - ZERO_STRUCTP(q_l); - - memcpy(&q_l->pol, hnd, sizeof(q_l->pol)); - init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids); - - q_l->level.value = level; -} - -/******************************************************************* - Reads or writes a LSA_Q_LOOKUP_SIDS structure. -********************************************************************/ - -BOOL lsa_io_q_lookup_sids(const char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookup_sids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol_hnd", &q_s->pol, ps, depth)) /* policy handle */ - return False; - if(!lsa_io_sid_enum("sids ", &q_s->sids, ps, depth)) /* sids to be looked up */ - return False; - if(!lsa_io_trans_names("names ", &q_s->names, ps, depth)) /* translated names */ - return False; - if(!smb_io_lookup_level("switch ", &q_s->level, ps, depth)) /* lookup level */ - return False; - - if(!prs_uint32("mapped_count", ps, depth, &q_s->mapped_count)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "lsa_io_trans_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &trn->num_entries)) - return False; - if(!prs_uint32("ptr_trans_names", ps, depth, &trn->ptr_trans_names)) - return False; - - if (trn->ptr_trans_names != 0) { - if(!prs_uint32("num_entries2 ", ps, depth, - &trn->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if ((trn->name = (LSA_TRANS_NAME *) - prs_alloc_mem(ps, trn->num_entries * - sizeof(LSA_TRANS_NAME))) == NULL) { - return False; - } - - if ((trn->uni_name = (UNISTR2 *) - prs_alloc_mem(ps, trn->num_entries * - sizeof(UNISTR2))) == NULL) { - return False; - } - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */ - return False; - } - - for (i = 0; i < trn->num_entries2; i++) { - fstring t; - slprintf(t, sizeof(t) - 1, "name[%d] ", i); - - if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref)) - return False; - - if (r_s->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */ - return False; - - if(!lsa_io_trans_names("names ", r_s->names, ps, depth)) /* translated names */ - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_s->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l, - POLICY_HND *hnd, int num_names, const char **names) -{ - int i; - - DEBUG(5, ("init_q_lookup_names\n")); - - ZERO_STRUCTP(q_l); - - q_l->pol = *hnd; - q_l->num_entries = num_names; - q_l->num_entries2 = num_names; - q_l->lookup_level = 1; - - if ((q_l->uni_name = (UNISTR2 *)talloc_zero( - mem_ctx, num_names * sizeof(UNISTR2))) == NULL) { - DEBUG(3, ("init_q_lookup_names(): out of memory\n")); - return; - } - - if ((q_l->hdr_name = (UNIHDR *)talloc_zero( - mem_ctx, num_names * sizeof(UNIHDR))) == NULL) { - DEBUG(3, ("init_q_lookup_names(): out of memory\n")); - return; - } - - for (i = 0; i < num_names; i++) { - int len; - len = strlen(names[i]); - - init_uni_hdr(&q_l->hdr_name[i], len); - init_unistr2(&q_l->uni_name[i], names[i], len); - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "lsa_io_q_lookup_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */ - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries ", ps, depth, &q_r->num_entries)) - return False; - if(!prs_uint32("num_entries2 ", ps, depth, &q_r->num_entries2)) - return False; - - if (UNMARSHALLING(ps)) { - if (q_r->num_entries) { - if ((q_r->hdr_name = (UNIHDR *)prs_alloc_mem(ps, - q_r->num_entries * sizeof(UNIHDR))) == NULL) - return False; - if ((q_r->uni_name = (UNISTR2 *)prs_alloc_mem(ps, - q_r->num_entries * sizeof(UNISTR2))) == NULL) - return False; - } - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */ - return False; - } - - for (i = 0; i < q_r->num_entries; i++) { - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */ - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries)) - return False; - if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids)) - return False; - if(!prs_uint32("lookup_level ", ps, depth, &q_r->lookup_level)) - return False; - if(!prs_uint32("mapped_count ", ps, depth, &q_r->mapped_count)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *r_r, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "lsa_io_r_lookup_names"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_dom_ref", ps, depth, &r_r->ptr_dom_ref)) - return False; - - if (r_r->ptr_dom_ref != 0) - if(!lsa_io_dom_r_ref("", r_r->dom_ref, ps, depth)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &r_r->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &r_r->ptr_entries)) - return False; - - if (r_r->ptr_entries != 0) { - if(!prs_uint32("num_entries2", ps, depth, &r_r->num_entries2)) - return False; - - if (r_r->num_entries2 != r_r->num_entries) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) { - if ((r_r->dom_rid = (DOM_RID2 *)prs_alloc_mem(ps, r_r->num_entries2 * sizeof(DOM_RID2))) - == NULL) { - DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n")); - return False; - } - } - - for (i = 0; i < r_r->num_entries2; i++) - if(!smb_io_dom_rid2("", &r_r->dom_rid[i], ps, depth)) /* domain RIDs being looked up */ - return False; - } - - if(!prs_uint32("mapped_count", ps, depth, &r_r->mapped_count)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_r->status)) - return False; - - return True; -} - - -/******************************************************************* - Inits an LSA_Q_CLOSE structure. -********************************************************************/ - -void init_lsa_q_close(LSA_Q_CLOSE *q_c, POLICY_HND *hnd) -{ - DEBUG(5, ("init_lsa_q_close\n")); - - memcpy(&q_c->pol, hnd, sizeof(q_c->pol)); -} - -/******************************************************************* - Reads or writes an LSA_Q_CLOSE structure. -********************************************************************/ - -BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *q_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_close"); - depth++; - - if(!smb_io_pol_hnd("", &q_c->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_CLOSE structure. -********************************************************************/ - -BOOL lsa_io_r_close(const char *desc, LSA_R_CLOSE *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_close"); - depth++; - - if(!smb_io_pol_hnd("", &r_c->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_Q_OPEN_SECRET structure. -********************************************************************/ - -BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *q_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_open_secret"); - depth++; - - /* Don't bother to read or write at present... */ - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_OPEN_SECRET structure. -********************************************************************/ - -BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_open_secret"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("dummy1", ps, depth, &r_c->dummy1)) - return False; - if(!prs_uint32("dummy2", ps, depth, &r_c->dummy2)) - return False; - if(!prs_uint32("dummy3", ps, depth, &r_c->dummy3)) - return False; - if(!prs_uint32("dummy4", ps, depth, &r_c->dummy4)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_Q_ENUM_PRIVS structure. -********************************************************************/ - -void init_q_enum_privs(LSA_Q_ENUM_PRIVS *q_q, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length) -{ - DEBUG(5, ("init_q_enum_privs\n")); - - memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); - - q_q->enum_context = enum_context; - q_q->pref_max_length = pref_max_length; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_enum_privs"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context)) - return False; - if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth) -{ - uint32 i; - - if (entries == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_priv_entries"); - depth++; - - if(!prs_align(ps)) - return False; - - for (i = 0; i < count; i++) { - if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth)) - return False; - if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low)) - return False; - if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high)) - return False; - } - - for (i = 0; i < count; i++) - if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_PRIVS structure. -********************************************************************/ - -void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *r_u, uint32 enum_context, - uint32 count, LSA_PRIV_ENTRY *entries) -{ - DEBUG(5, ("init_lsa_r_enum_privs\n")); - - r_u->enum_context=enum_context; - r_u->count=count; - - if (entries!=NULL) { - r_u->ptr=1; - r_u->count1=count; - r_u->privs=entries; - } else { - r_u->ptr=0; - r_u->count1=0; - r_u->privs=NULL; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_r_enum_privs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context)) - return False; - if(!prs_uint32("count", ps, depth, &r_q->count)) - return False; - if(!prs_uint32("ptr", ps, depth, &r_q->ptr)) - return False; - - if (r_q->ptr) { - if(!prs_uint32("count1", ps, depth, &r_q->count1)) - return False; - - if (UNMARSHALLING(ps)) - if (!(r_q->privs = (LSA_PRIV_ENTRY *)prs_alloc_mem(ps, sizeof(LSA_PRIV_ENTRY) * r_q->count1))) - return False; - - if (!lsa_io_priv_entries("", r_q->privs, r_q->count1, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys) -{ - int len_name = strlen(name); - - if(len_name == 0) - len_name = 1; - - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - init_uni_hdr(&trn->hdr_name, len_name); - init_unistr2(&trn->name, name, len_name); - trn->lang_id = lang_id; - trn->lang_id_sys = lang_id_sys; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if (!smb_io_unihdr("hdr_name", &q_q->hdr_name, ps, depth)) - return False; - - if (!smb_io_unistr2("name", &q_q->name, q_q->hdr_name.buffer, ps, depth)) - return False; - - if(!prs_uint16("lang_id ", ps, depth, &q_q->lang_id)) - return False; - if(!prs_uint16("lang_id_sys", ps, depth, &q_q->lang_id_sys)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_info", ps, depth, &r_q->ptr_info)) - return False; - - if (r_q->ptr_info){ - if (!smb_io_unihdr("hdr_name", &r_q->hdr_desc, ps, depth)) - return False; - - if (!smb_io_unistr2("desc", &r_q->desc, r_q->hdr_desc.buffer, ps, depth)) - return False; - } -/* - if(!prs_align(ps)) - return False; -*/ - if(!prs_uint16("lang_id", ps, depth, &r_q->lang_id)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/* - initialise a LSA_Q_ENUM_ACCOUNTS structure -*/ -void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length) -{ - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - trn->enum_context = enum_context; - trn->pref_max_length = pref_max_length; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!prs_uint32("enum_context ", ps, depth, &q_q->enum_context)) - return False; - if(!prs_uint32("pref_max_length", ps, depth, &q_q->pref_max_length)) - return False; - - return True; -} - - -/******************************************************************* - Inits an LSA_R_ENUM_PRIVS structure. -********************************************************************/ - -void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *r_u, uint32 enum_context) -{ - DEBUG(5, ("init_lsa_r_enum_accounts\n")); - - r_u->enum_context=enum_context; - if (r_u->enum_context!=0) { - r_u->sids.num_entries=enum_context; - r_u->sids.ptr_sid_enum=1; - r_u->sids.num_entries2=enum_context; - } else { - r_u->sids.num_entries=0; - r_u->sids.ptr_sid_enum=0; - r_u->sids.num_entries2=0; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("enum_context", ps, depth, &r_q->enum_context)) - return False; - - if (!lsa_io_sid_enum("sids", &r_q->sids, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes an LSA_Q_UNK_GET_CONNUSER structure. -********************************************************************/ - -BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname)) - return False; - - if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */ - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("unk1", ps, depth, &q_c->unk1)) - return False; - if(!prs_uint32("unk2", ps, depth, &q_c->unk2)) - return False; - if(!prs_uint32("unk3", ps, depth, &q_c->unk3)) - return False; - - /* Don't bother to read or write at present... */ - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_UNK_GET_CONNUSER structure. -********************************************************************/ - -BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name)) - return False; - if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("unk1", ps, depth, &r_c->unk1)) - return False; - - if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name)) - return False; - if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access) -{ - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - init_dom_sid2(&trn->sid, sid); - trn->access = desired_access; -} - -/******************************************************************* - Reads or writes an LSA_Q_OPENACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_open_account"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &r_c->sid, ps, depth)) /* domain SID */ - return False; - - if(!prs_uint32("access", ps, depth, &r_c->access)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_OPENACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_open_account"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - -void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd) -{ - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - -} - -/******************************************************************* - Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LUID structure. -********************************************************************/ - -static BOOL lsa_io_luid(const char *desc, LUID *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_luid"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("low", ps, depth, &r_c->low)) - return False; - - if(!prs_uint32("high", ps, depth, &r_c->high)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LUID_ATTR structure. -********************************************************************/ - -static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_luid_attr"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!lsa_io_luid(desc, &r_c->luid, ps, depth)) - return False; - - if(!prs_uint32("attr", ps, depth, &r_c->attr)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an PRIVILEGE_SET structure. -********************************************************************/ - -static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *r_c, prs_struct *ps, int depth) -{ - uint32 i; - - prs_debug(ps, depth, desc, "lsa_io_privilege_set"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count", ps, depth, &r_c->count)) - return False; - if(!prs_uint32("control", ps, depth, &r_c->control)) - return False; - - for (i=0; i<r_c->count; i++) { - if (!lsa_io_luid_attr(desc, &r_c->set[i], ps, depth)) - return False; - } - - return True; -} - -void init_lsa_r_enum_privsaccount(LSA_R_ENUMPRIVSACCOUNT *r_u, LUID_ATTR *set, uint32 count, uint32 control) -{ - r_u->ptr=1; - r_u->count=count; - r_u->set.set=set; - r_u->set.count=count; - r_u->set.control=control; - DEBUG(10,("init_lsa_r_enum_privsaccount: %d %d privileges\n", r_u->count, r_u->set.count)); -} - -/******************************************************************* - Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_c->ptr)) - return False; - - if (r_c->ptr!=0) { - if(!prs_uint32("count", ps, depth, &r_c->count)) - return False; - - /* malloc memory if unmarshalling here */ - - if (UNMARSHALLING(ps) && r_c->count!=0) { - if (!(r_c->set.set = (LUID_ATTR *)prs_alloc_mem(ps,sizeof(LUID_ATTR) * r_c->count))) - return False; - - } - - if(!lsa_io_privilege_set(desc, &r_c->set, ps, depth)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - - -/******************************************************************* - Reads or writes an LSA_Q_GETSYSTEMACCOUNTstructure. -********************************************************************/ - -BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_GETSYSTEMACCOUNTstructure. -********************************************************************/ - -BOOL lsa_io_r_getsystemaccount(const char *desc, LSA_R_GETSYSTEMACCOUNT *r_c, 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, &r_c->access)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes an LSA_Q_SETSYSTEMACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_q_setsystemaccount(const char *desc, LSA_Q_SETSYSTEMACCOUNT *r_c, 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", &r_c->pol, ps, depth)) - return False; - - if(!prs_uint32("access", ps, depth, &r_c->access)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_SETSYSTEMACCOUNT structure. -********************************************************************/ - -BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, 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, &r_c->status)) - return False; - - return True; -} - - -void init_lsa_q_lookupprivvalue(LSA_Q_LOOKUPPRIVVALUE *trn, POLICY_HND *hnd, const char *name) -{ - int len_name = strlen(name); - memcpy(&trn->pol, hnd, sizeof(trn->pol)); - - if(len_name == 0) - len_name = 1; - - init_uni_hdr(&trn->hdr_right, len_name); - init_unistr2(&trn->uni2_right, name, len_name); -} - -/******************************************************************* - Reads or writes an LSA_Q_LOOKUPPRIVVALUE structure. -********************************************************************/ - -BOOL lsa_io_q_lookupprivvalue(const char *desc, LSA_Q_LOOKUPPRIVVALUE *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_lookupprivvalue"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_c->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("hdr_name", &r_c->hdr_right, ps, depth)) - return False; - if(!smb_io_unistr2("uni2_right", &r_c->uni2_right, r_c->hdr_right.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_R_LOOKUPPRIVVALUE structure. -********************************************************************/ - -BOOL lsa_io_r_lookupprivvalue(const char *desc, LSA_R_LOOKUPPRIVVALUE *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_lookupprivvalue"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!lsa_io_luid("luid", &r_c->luid, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes an LSA_Q_ADDPRIVS structure. -********************************************************************/ - -BOOL lsa_io_q_addprivs(const char *desc, LSA_Q_ADDPRIVS *r_c, 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", &r_c->pol, ps, depth)) - return False; - - if(!prs_uint32("count", ps, depth, &r_c->count)) - return False; - - if (UNMARSHALLING(ps) && r_c->count!=0) { - if (!(r_c->set.set = (LUID_ATTR *)prs_alloc_mem(ps,sizeof(LUID_ATTR) * r_c->count))) - return False; - } - - if(!lsa_io_privilege_set(desc, &r_c->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 *r_c, 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, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an LSA_Q_REMOVEPRIVS structure. -********************************************************************/ - -BOOL lsa_io_q_removeprivs(const char *desc, LSA_Q_REMOVEPRIVS *r_c, 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", &r_c->pol, ps, depth)) - return False; - - if(!prs_uint32("allrights", ps, depth, &r_c->allrights)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_c->ptr)) - return False; - - /* - * JFM: I'm not sure at all if the count is inside the ptr - * never seen one with ptr=0 - */ - - if (r_c->ptr!=0) { - if(!prs_uint32("count", ps, depth, &r_c->count)) - return False; - - if (UNMARSHALLING(ps) && r_c->count!=0) { - if (!(r_c->set.set = (LUID_ATTR *)prs_alloc_mem(ps,sizeof(LUID_ATTR) * r_c->count))) - return False; - } - - if(!lsa_io_privilege_set(desc, &r_c->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 *r_c, 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, &r_c->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 (!prs_uint8s(False, "dom_guid", ps, depth, info->dom_guid.info, GUID_SIZE)) - 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 *q_q, POLICY_HND *hnd, uint16 info_class) -{ - DEBUG(5, ("init_q_query2\n")); - - memcpy(&q_q->pol, hnd, sizeof(q_q->pol)); - - q_q->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 *q_c, - 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", &q_c->pol, ps, depth)) - return False; - - if(!prs_uint16("info_class", ps, depth, &q_c->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 *r_c, - 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, &r_c->ptr)) - return False; - if(!prs_uint16("info_class", ps, depth, &r_c->info_class)) - return False; - switch(r_c->info_class) { - case 0x000c: - if (!lsa_io_dns_dom_info("info12", &r_c->info.dns_dom_info, - ps, depth)) - return False; - break; - default: - DEBUG(0,("lsa_io_r_query_info2: unknown info class %d\n", - r_c->info_class)); - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - -/******************************************************************* - Inits an LSA_Q_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -void init_q_enum_acct_rights(LSA_Q_ENUM_ACCT_RIGHTS *q_q, - POLICY_HND *hnd, - uint32 count, - DOM_SID *sid) -{ - DEBUG(5, ("init_q_enum_acct_rights\n")); - - q_q->pol = *hnd; - init_dom_sid2(&q_q->sid, sid); -} - -/******************************************************************* -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 *q_q, prs_struct *ps, int depth) -{ - - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &q_q->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 *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_rights"); - depth++; - - if(!prs_uint32("count ", ps, depth, &r_c->count)) - return False; - - if(!smb_io_unistr2_array("rights", &r_c->rights, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -void init_r_enum_acct_rights(LSA_R_ENUM_ACCT_RIGHTS *q_r, - uint32 count, - const char **rights) -{ - DEBUG(5, ("init_r_enum_acct_rights\n")); - - q_r->count = count; - init_unistr2_array(&q_r->rights, count, rights); -} - - -/******************************************************************* - Inits an LSA_Q_ADD_ACCT_RIGHTS structure. -********************************************************************/ -void init_q_add_acct_rights(LSA_Q_ADD_ACCT_RIGHTS *q_q, - POLICY_HND *hnd, - DOM_SID *sid, - uint32 count, - const char **rights) -{ - DEBUG(5, ("init_q_add_acct_rights\n")); - - q_q->pol = *hnd; - init_dom_sid2(&q_q->sid, sid); - init_unistr2_array(&q_q->rights, count, rights); -} - - -/******************************************************************* -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 *q_q, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_add_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth)) - return False; - - if(!prs_uint32("count", ps, depth, &q_q->rights.count)) - return False; - - if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a LSA_R_ENUM_ACCT_RIGHTS structure. -********************************************************************/ -BOOL lsa_io_r_add_acct_rights(const char *desc, LSA_R_ADD_ACCT_RIGHTS *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_add_acct_rights"); - depth++; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_ADD_ACCT_RIGHTS structure. -********************************************************************/ -void init_r_add_acct_rights(LSA_R_ADD_ACCT_RIGHTS *q_r) -{ - DEBUG(5, ("init_r_add_acct_rights\n")); - /* oh what a silly function! */ -} - - -/******************************************************************* - Inits an LSA_Q_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ -void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *q_q, - POLICY_HND *hnd, - DOM_SID *sid, - uint32 removeall, - uint32 count, - const char **rights) -{ - DEBUG(5, ("init_q_remove_acct_rights\n")); - - q_q->pol = *hnd; - init_dom_sid2(&q_q->sid, sid); - q_q->removeall = removeall; - init_unistr2_array(&q_q->rights, count, rights); -} - - -/******************************************************************* -reads or writes a LSA_Q_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ -BOOL lsa_io_q_remove_acct_rights(const char *desc, LSA_Q_REMOVE_ACCT_RIGHTS *q_q, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_remove_acct_rights"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &q_q->sid, ps, depth)) - return False; - - if(!prs_uint32("removeall", ps, depth, &q_q->removeall)) - return False; - - if(!prs_uint32("count", ps, depth, &q_q->rights.count)) - return False; - - if(!smb_io_unistr2_array("rights", &q_q->rights, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a LSA_R_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ -BOOL lsa_io_r_remove_acct_rights(const char *desc, LSA_R_REMOVE_ACCT_RIGHTS *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_remove_acct_rights"); - depth++; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_REMOVE_ACCT_RIGHTS structure. -********************************************************************/ -void init_r_remove_acct_rights(LSA_R_REMOVE_ACCT_RIGHTS *q_r) -{ - DEBUG(5, ("init_r_remove_acct_rights\n")); -} - -/******************************************************************* - Inits an LSA_Q_ENUM_ACCT_WITH_RIGHT structure. -********************************************************************/ -void init_q_enum_acct_with_right(LSA_Q_ENUM_ACCT_WITH_RIGHT *q_q, - POLICY_HND *hnd, - const char *right) -{ - DEBUG(5, ("init_q_enum_acct_with_right\n")); - - q_q->pol = *hnd; - init_unistr2(&q_q->right, right, strlen(right)); - init_str_hdr(&q_q->right_hdr, - q_q->right.uni_max_len*2, - q_q->right.uni_max_len*2, right?1:0); -} - - -/******************************************************************* -reads or writes a LSA_Q_ENUM_ACCT_WITH_RIGHT structure. -********************************************************************/ -BOOL lsa_io_q_enum_acct_with_right(const char *desc, LSA_Q_ENUM_ACCT_WITH_RIGHT *q_q, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_q_enum_acct_with_right"); - depth++; - - if (!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if (!prs_uint32("ref_id ", ps, depth, &q_q->right_hdr.buffer)) - return False; - - if (UNMARSHALLING(ps) && q_q->right_hdr.buffer == 0) { - return True; - } - - if (!smb_io_strhdr("", &q_q->right_hdr, ps, depth)) - return False; - - if (!smb_io_unistr2("", &q_q->right, q_q->right_hdr.buffer, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a LSA_R_ENUM_ACCT_WITH_RIGHT structure. -********************************************************************/ -BOOL lsa_io_r_enum_acct_with_right(const char *desc, LSA_R_ENUM_ACCT_WITH_RIGHT *r_c, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "lsa_io_r_enum_acct_with_right"); - depth++; - - if (!prs_uint32("count ", ps, depth, &r_c->count)) - return False; - - if (!smb_io_sid_array("sids ", &r_c->sids, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an LSA_R_ENUM_ACCT_WITH_RIGHT structure. -********************************************************************/ -void init_r_enum_acct_with_right(LSA_R_ENUM_ACCT_WITH_RIGHT *r_c, - uint32 count, - DOM_SID *sids) -{ - DEBUG(5, ("init_r_enum_acct_with_right\n")); - - r_c->count = count; - init_sid_array(&r_c->sids, count, sids); -} diff --git a/source4/rpc_parse/parse_misc.c b/source4/rpc_parse/parse_misc.c deleted file mode 100644 index ad50c4c6d1..0000000000 --- a/source4/rpc_parse/parse_misc.c +++ /dev/null @@ -1,1784 +0,0 @@ -/* - * 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. - * - * 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 - -/**************************************************************************** - A temporary TALLOC context for things like unistrs, that is valid for - the life of a complete RPC call. -****************************************************************************/ - -static TALLOC_CTX *current_rpc_talloc = NULL; - -TALLOC_CTX *get_current_rpc_talloc(void) -{ - return current_rpc_talloc; -} - -void set_current_rpc_talloc( TALLOC_CTX *ctx) -{ - current_rpc_talloc = ctx; -} - -static TALLOC_CTX *main_loop_talloc = NULL; - -/******************************************************************* -free up temporary memory - called from the main loop -********************************************************************/ - -void main_loop_talloc_freeREWRITE(void) -{ - if (!main_loop_talloc) - return; - talloc_destroy(main_loop_talloc); - main_loop_talloc = NULL; -} - -/******************************************************************* - Get a talloc context that is freed in the main loop... -********************************************************************/ - -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; -} - -/******************************************************************* - Try and get a talloc context. Get the rpc one if possible, else - get the main loop one. The main loop one is more dangerous as it - goes away between packets, the rpc one will stay around for as long - as a current RPC lasts. -********************************************************************/ - -TALLOC_CTX *get_talloc_ctx(void) -{ - TALLOC_CTX *tc = get_current_rpc_talloc(); - - if (tc) - return tc; - return main_loop_talloc_get(); -} - -/******************************************************************* - Reads or writes a UTIME type. -********************************************************************/ - -static BOOL smb_io_utime(const char *desc, UTIME *t, prs_struct *ps, int depth) -{ - if (t == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_utime"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32 ("time", ps, depth, &t->time)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an NTTIME structure. -********************************************************************/ - -BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth) -{ - if (nttime == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_time"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("low ", ps, depth, &nttime->low)) /* low part */ - return False; - if(!prs_uint32("high", ps, depth, &nttime->high)) /* high part */ - return False; - - return True; -} - -/******************************************************************* - Reads or writes a LOOKUP_LEVEL structure. -********************************************************************/ - -BOOL smb_io_lookup_level(const char *desc, LOOKUP_LEVEL *level, prs_struct *ps, int depth) -{ - if (level == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_lookup_level"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint16("value", ps, depth, &level->value)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - Gets an enumeration handle from an ENUM_HND structure. -********************************************************************/ - -uint32 get_enum_hnd(ENUM_HND *enh) -{ - return (enh && enh->ptr_hnd != 0) ? enh->handle : 0; -} - -/******************************************************************* - Inits an ENUM_HND structure. -********************************************************************/ - -void init_enum_hnd(ENUM_HND *enh, uint32 hnd) -{ - DEBUG(5,("smb_io_enum_hnd\n")); - - enh->ptr_hnd = (hnd != 0) ? 1 : 0; - enh->handle = hnd; -} - -/******************************************************************* - Reads or writes an ENUM_HND structure. -********************************************************************/ - -BOOL smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth) -{ - if (hnd == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_enum_hnd"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_hnd", ps, depth, &hnd->ptr_hnd)) /* pointer */ - return False; - - if (hnd->ptr_hnd != 0) { - if(!prs_uint32("handle ", ps, depth, &hnd->handle )) /* enum handle */ - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a DOM_SID structure. -********************************************************************/ - -BOOL smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth) -{ - int i; - - if (sid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_sid"); - depth++; - - if(!prs_uint8 ("sid_rev_num", ps, depth, &sid->sid_rev_num)) - return False; - - if(!prs_uint8 ("num_auths ", ps, depth, &sid->num_auths)) - return False; - - for (i = 0; i < 6; i++) - { - fstring tmp; - slprintf(tmp, sizeof(tmp) - 1, "id_auth[%d] ", i); - if(!prs_uint8 (tmp, ps, depth, &sid->id_auth[i])) - return False; - } - - /* oops! XXXX should really issue a warning here... */ - if (sid->num_auths > MAXSUBAUTHS) - sid->num_auths = MAXSUBAUTHS; - - if(!prs_uint32s(False, "sub_auths ", ps, depth, sid->sub_auths, sid->num_auths)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_SID structure. - - BIG NOTE: this function only does SIDS where the identauth is not >= 2^32 - identauth >= 2^32 can be detected because it will be specified in hex -********************************************************************/ - -void init_dom_sid(DOM_SID *sid, const char *str_sid) -{ - pstring domsid; - int identauth; - char *p; - - if (str_sid == NULL) { - DEBUG(4,("netlogon domain SID: none\n")); - sid->sid_rev_num = 0; - sid->num_auths = 0; - return; - } - - pstrcpy(domsid, str_sid); - - DEBUG(4,("init_dom_sid %d SID: %s\n", __LINE__, domsid)); - - /* assume, but should check, that domsid starts "S-" */ - p = strtok(domsid+2,"-"); - sid->sid_rev_num = atoi(p); - - /* identauth in decimal should be < 2^32 */ - /* identauth in hex should be >= 2^32 */ - identauth = atoi(strtok(0,"-")); - - DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num)); - DEBUG(4,("netlogon %s ia %d\n", p, identauth)); - - sid->id_auth[0] = 0; - sid->id_auth[1] = 0; - sid->id_auth[2] = (identauth & 0xff000000) >> 24; - sid->id_auth[3] = (identauth & 0x00ff0000) >> 16; - sid->id_auth[4] = (identauth & 0x0000ff00) >> 8; - sid->id_auth[5] = (identauth & 0x000000ff); - - sid->num_auths = 0; - - while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS) - sid->sub_auths[sid->num_auths++] = atoi(p); - - DEBUG(4,("init_dom_sid: %d SID: %s\n", __LINE__, domsid)); -} - -/******************************************************************* - Inits a DOM_SID2 structure. -********************************************************************/ - -void init_dom_sid2(DOM_SID2 *sid2, const DOM_SID *sid) -{ - sid2->sid = *sid; - sid2->num_auths = sid2->sid.num_auths; -} - -/******************************************************************* - Reads or writes a DOM_SID2 structure. -********************************************************************/ - -BOOL smb_io_dom_sid2(const char *desc, DOM_SID2 *sid, prs_struct *ps, int depth) -{ - if (sid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_sid2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_auths", ps, depth, &sid->num_auths)) - return False; - - if(!smb_io_dom_sid("sid", &sid->sid, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -creates a STRHDR structure. -********************************************************************/ - -void init_str_hdr(STRHDR *hdr, int max_len, int len, uint32 buffer) -{ - hdr->str_max_len = max_len; - hdr->str_str_len = len; - hdr->buffer = buffer; -} - -/******************************************************************* - Reads or writes a STRHDR structure. -********************************************************************/ - -BOOL smb_io_strhdr(const char *desc, STRHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_strhdr"); - depth++; - - prs_align(ps); - - if(!prs_uint16("str_str_len", ps, depth, &hdr->str_str_len)) - return False; - if(!prs_uint16("str_max_len", ps, depth, &hdr->str_max_len)) - return False; - if(!prs_uint32("buffer ", ps, depth, &hdr->buffer)) - return False; - - return True; -} - -/******************************************************************* - Inits a UNIHDR structure. -********************************************************************/ - -void init_uni_hdr(UNIHDR *hdr, int len) -{ - hdr->uni_str_len = 2 * len; - hdr->uni_max_len = 2 * len; - hdr->buffer = len != 0 ? 1 : 0; -} - -/******************************************************************* - Reads or writes a UNIHDR structure. -********************************************************************/ - -BOOL smb_io_unihdr(const char *desc, UNIHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unihdr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("uni_str_len", ps, depth, &hdr->uni_str_len)) - return False; - if(!prs_uint16("uni_max_len", ps, depth, &hdr->uni_max_len)) - return False; - if(!prs_uint32("buffer ", ps, depth, &hdr->buffer)) - return False; - - return True; -} - -/******************************************************************* - Inits a BUFHDR structure. -********************************************************************/ - -void init_buf_hdr(BUFHDR *hdr, int max_len, int len) -{ - hdr->buf_max_len = max_len; - hdr->buf_len = len; -} - -/******************************************************************* - prs_uint16 wrapper. Call this and it sets up a pointer to where the - uint16 should be stored, or gets the size if reading. - ********************************************************************/ - -BOOL smb_io_hdrbuf_pre(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset) -{ - (*offset) = prs_offset(ps); - if (ps->io) { - - /* reading. */ - - if(!smb_io_hdrbuf(desc, hdr, ps, depth)) - return False; - - } else { - - /* writing. */ - - if(!prs_set_offset(ps, prs_offset(ps) + (sizeof(uint32) * 2))) - return False; - } - - return True; -} - -/******************************************************************* - smb_io_hdrbuf wrapper. Call this and it retrospectively stores the size. - Does nothing on reading, as that is already handled by ...._pre() - ********************************************************************/ - -BOOL smb_io_hdrbuf_post(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth, - uint32 ptr_hdrbuf, uint32 max_len, uint32 len) -{ - if (!ps->io) { - /* writing: go back and do a retrospective job. i hate this */ - - uint32 old_offset = prs_offset(ps); - - init_buf_hdr(hdr, max_len, len); - if(!prs_set_offset(ps, ptr_hdrbuf)) - return False; - if(!smb_io_hdrbuf(desc, hdr, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a BUFHDR structure. -********************************************************************/ - -BOOL smb_io_hdrbuf(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth) -{ - if (hdr == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_hdrbuf"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_max_len", ps, depth, &hdr->buf_max_len)) - return False; - if(!prs_uint32("buf_len ", ps, depth, &hdr->buf_len)) - return False; - - return True; -} - -/******************************************************************* -creates a UNIHDR2 structure. -********************************************************************/ - -void init_uni_hdr2(UNIHDR2 *hdr, int len) -{ - init_uni_hdr(&hdr->unihdr, len); - hdr->buffer = (len > 0) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a UNIHDR2 structure. -********************************************************************/ - -BOOL smb_io_unihdr2(const char *desc, UNIHDR2 *hdr2, prs_struct *ps, int depth) -{ - if (hdr2 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unihdr2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr", &hdr2->unihdr, ps, depth)) - return False; - if(!prs_uint32("buffer", ps, depth, &hdr2->buffer)) - return False; - - return True; -} - -/******************************************************************* - Inits a UNISTR structure. -********************************************************************/ - -void init_unistr(UNISTR *str, const char *buf) -{ - size_t len; - - if (buf == NULL) { - str->buffer = NULL; - return; - } - - - len = strlen(buf) + 1; - - if (len < MAX_UNISTRLEN) - len = MAX_UNISTRLEN; - len *= sizeof(uint16); - - str->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len); - if (str->buffer == NULL) - smb_panic("init_unistr: malloc fail\n"); - - rpcstr_push(str->buffer, buf, len, STR_TERMINATE); -} - -/******************************************************************* -reads or writes a UNISTR structure. -XXXX NOTE: UNISTR structures NEED to be null-terminated. -********************************************************************/ - -BOOL smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth) -{ - if (uni == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unistr"); - depth++; - - if(!prs_unistr("unistr", ps, depth, uni)) - return False; - - return True; -} - -/******************************************************************* - Allocate the BUFFER3 memory. -********************************************************************/ - -static void create_buffer3(BUFFER3 *str, size_t len) -{ - if (len < MAX_BUFFERLEN) - len = MAX_BUFFERLEN; - - str->buffer = talloc_zero(get_talloc_ctx(), len); - if (str->buffer == NULL) - smb_panic("create_buffer3: talloc fail\n"); - -} - -/******************************************************************* - Inits a BUFFER3 structure from a uint32 -********************************************************************/ - -void init_buffer3_uint32(BUFFER3 *str, uint32 val) -{ - ZERO_STRUCTP(str); - - /* set up string lengths. */ - str->buf_max_len = sizeof(uint32); - str->buf_len = sizeof(uint32); - - create_buffer3(str, sizeof(uint32)); - SIVAL(str->buffer, 0, val); -} - -/******************************************************************* - Inits a BUFFER3 structure. -********************************************************************/ - -void init_buffer3_str(BUFFER3 *str, const char *buf, int len) -{ - ZERO_STRUCTP(str); - - /* set up string lengths. */ - str->buf_max_len = len * 2; - str->buf_len = len * 2; - - create_buffer3(str, str->buf_max_len); - - rpcstr_push(str->buffer, buf, str->buf_max_len, STR_TERMINATE); - -} - -/******************************************************************* - Inits a BUFFER3 structure from a hex string. -********************************************************************/ - -void init_buffer3_hex(BUFFER3 *str, const char *buf) -{ - ZERO_STRUCTP(str); - create_buffer3(str, strlen(buf)); - str->buf_max_len = str->buf_len = strhex_to_str((char *)str->buffer, sizeof(str->buffer), buf); -} - -/******************************************************************* - Inits a BUFFER3 structure. -********************************************************************/ - -void init_buffer3_bytes(BUFFER3 *str, uint8 *buf, int len) -{ - ZERO_STRUCTP(str); - - /* max buffer size (allocated size) */ - str->buf_max_len = len; - if (buf != NULL) { - create_buffer3(str, len); - memcpy(str->buffer, buf, len); - } - str->buf_len = buf != NULL ? len : 0; -} - -/******************************************************************* - Reads or writes a BUFFER3 structure. - the uni_max_len member tells you how large the buffer is. - the uni_str_len member tells you how much of the buffer is really used. -********************************************************************/ - -BOOL smb_io_buffer3(const char *desc, BUFFER3 *buf3, prs_struct *ps, int depth) -{ - if (buf3 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_buffer3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("uni_max_len", ps, depth, &buf3->buf_max_len)) - return False; - - if (UNMARSHALLING(ps)) { - buf3->buffer = (unsigned char *)prs_alloc_mem(ps, buf3->buf_max_len); - if (buf3->buffer == NULL) - return False; - } - - if(!prs_uint8s(True, "buffer ", ps, depth, buf3->buffer, buf3->buf_max_len)) - return False; - - if(!prs_uint32("buf_len ", ps, depth, &buf3->buf_len)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a BUFFER5 structure. -the buf_len member tells you how large the buffer is. -********************************************************************/ -BOOL smb_io_buffer5(const char *desc, BUFFER5 *buf5, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_buffer5"); - depth++; - - if (buf5 == NULL) return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("buf_len", ps, depth, &buf5->buf_len)) - return False; - - if(buf5->buf_len) { - if(!prs_buffer5(True, "buffer" , ps, depth, buf5)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a BUFFER2 structure. -********************************************************************/ - -void init_buffer2(BUFFER2 *str, const uint8 *buf, int len) -{ - ZERO_STRUCTP(str); - - /* max buffer size (allocated size) */ - str->buf_max_len = len; - str->undoc = 0; - str->buf_len = buf != NULL ? len : 0; - - if (buf != NULL) { - if (len < MAX_BUFFERLEN) - len = MAX_BUFFERLEN; - str->buffer = talloc_zero(get_talloc_ctx(), len); - if (str->buffer == NULL) - smb_panic("init_buffer2: talloc fail\n"); - memcpy(str->buffer, buf, MIN(str->buf_len, len)); - } -} - -/******************************************************************* - Reads or writes a BUFFER2 structure. - the uni_max_len member tells you how large the buffer is. - the uni_str_len member tells you how much of the buffer is really used. -********************************************************************/ - -BOOL smb_io_buffer2(const char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *ps, int depth) -{ - if (buf2 == NULL) - return False; - - if (buffer) { - - prs_debug(ps, depth, desc, "smb_io_buffer2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("uni_max_len", ps, depth, &buf2->buf_max_len)) - return False; - if(!prs_uint32("undoc ", ps, depth, &buf2->undoc)) - return False; - if(!prs_uint32("buf_len ", ps, depth, &buf2->buf_len)) - return False; - - /* buffer advanced by indicated length of string - NOT by searching for null-termination */ - - if(!prs_buffer2(True, "buffer ", ps, depth, buf2)) - return False; - - } else { - - prs_debug(ps, depth, desc, "smb_io_buffer2 - NULL"); - depth++; - memset((char *)buf2, '\0', sizeof(*buf2)); - - } - return True; -} - -/******************************************************************* -creates a UNISTR2 structure: sets up the buffer, too -********************************************************************/ - -void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf) -{ - if (buf != NULL) { - - *ptr = 1; - init_unistr2(str, buf, strlen(buf)+1); - - } else { - - *ptr = 0; - init_unistr2(str, "", 0); - - } -} - -/******************************************************************* - Copies a UNISTR2 structure. -********************************************************************/ - -void copy_unistr2(UNISTR2 *str, const UNISTR2 *from) -{ - - /* set up string lengths. add one if string is not null-terminated */ - str->uni_max_len = from->uni_max_len; - str->undoc = from->undoc; - str->uni_str_len = from->uni_str_len; - - if (from->buffer == NULL) - return; - - /* the string buffer is allocated to the maximum size - (the the length of the source string) to prevent - reallocation of memory. */ - if (str->buffer == NULL) { - size_t len = from->uni_max_len * sizeof(uint16); - - if (len < MAX_UNISTRLEN) - len = MAX_UNISTRLEN; - len *= sizeof(uint16); - - str->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len); - if ((str->buffer == NULL) && (len > 0 )) - { - smb_panic("copy_unistr2: talloc fail\n"); - return; - } - } - - /* copy the string */ - memcpy(str->buffer, from->buffer, from->uni_max_len*sizeof(uint16)); -} - -/******************************************************************* - Creates a STRING2 structure. -********************************************************************/ - -void init_string2(STRING2 *str, const char *buf, int max_len, int str_len) -{ - int alloc_len = 0; - - /* set up string lengths. */ - str->str_max_len = max_len; - str->undoc = 0; - str->str_str_len = str_len; - - /* store the string */ - if(str_len != 0) { - if (str_len < MAX_STRINGLEN) - alloc_len = MAX_STRINGLEN; - str->buffer = talloc_zero(get_talloc_ctx(), alloc_len); - if (str->buffer == NULL) - smb_panic("init_string2: malloc fail\n"); - memcpy(str->buffer, buf, str_len); - } -} - -/******************************************************************* - Reads or writes a STRING2 structure. - XXXX NOTE: STRING2 structures need NOT be null-terminated. - the str_str_len member tells you how long the string is; - the str_max_len member tells you how large the buffer is. -********************************************************************/ - -BOOL smb_io_string2(const char *desc, STRING2 *str2, uint32 buffer, prs_struct *ps, int depth) -{ - if (str2 == NULL) - return False; - - if (buffer) { - - prs_debug(ps, depth, desc, "smb_io_string2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("str_max_len", ps, depth, &str2->str_max_len)) - return False; - if(!prs_uint32("undoc ", ps, depth, &str2->undoc)) - return False; - if(!prs_uint32("str_str_len", ps, depth, &str2->str_str_len)) - return False; - - /* buffer advanced by indicated length of string - NOT by searching for null-termination */ - if(!prs_string2(True, "buffer ", ps, depth, str2)) - return False; - - } else { - - prs_debug(ps, depth, desc, "smb_io_string2 - NULL"); - depth++; - memset((char *)str2, '\0', sizeof(*str2)); - - } - - return True; -} - -/******************************************************************* - Inits a UNISTR2 structure. -********************************************************************/ - -void init_unistr2(UNISTR2 *str, const char *buf, size_t len) -{ - ZERO_STRUCTP(str); - - /* set up string lengths. */ - str->uni_max_len = (uint32)len; - str->undoc = 0; - str->uni_str_len = (uint32)len; - - if (len < MAX_UNISTRLEN) - len = MAX_UNISTRLEN; - len *= sizeof(uint16); - - str->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len); - if ((str->buffer == NULL) && (len > 0)) - { - smb_panic("init_unistr2: malloc fail\n"); - return; - } - - /* - * don't move this test above ! The UNISTR2 must be initialized !!! - * jfm, 7/7/2001. - */ - if (buf==NULL) - return; - - rpcstr_push((char *)str->buffer, buf, len, STR_TERMINATE); -} - -/** - * Inits a UNISTR2 structure. - * @param ctx talloc context to allocate string on - * @param str pointer to string to create - * @param buf UCS2 null-terminated buffer to init from -*/ - -void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf) -{ - uint32 len = strlen_w(buf); - uint32 max_len = len; - uint32 alloc_len; - - ZERO_STRUCTP(str); - - /* set up string lengths. */ - str->uni_max_len = len; - str->undoc = 0; - str->uni_str_len = len; - - if (max_len < MAX_UNISTRLEN) - max_len = MAX_UNISTRLEN; - - alloc_len = (max_len + 1) * sizeof(uint16); - - str->buffer = (uint16 *)talloc_zero(ctx, alloc_len); - if ((str->buffer == NULL) && (alloc_len > 0)) - { - smb_panic("init_unistr2_w: malloc fail\n"); - return; - } - - /* - * don't move this test above ! The UNISTR2 must be initialized !!! - * jfm, 7/7/2001. - */ - if (buf==NULL) - return; - - /* Yes, this is a strncpy( foo, bar, strlen(bar)) - but as - long as the buffer above is talloc()ed correctly then this - is the correct thing to do */ - strncpy_w(str->buffer, buf, len + 1); -} - -/******************************************************************* - Inits a UNISTR2 structure from a UNISTR -********************************************************************/ -void init_unistr2_from_unistr (UNISTR2 *to, const UNISTR *from) -{ - - uint32 i; - - /* the destination UNISTR2 should never be NULL. - if it is it is a programming error */ - - /* if the source UNISTR is NULL, then zero out - the destination string and return */ - ZERO_STRUCTP (to); - if ((from == NULL) || (from->buffer == NULL)) - return; - - /* get the length; UNISTR must be NULL terminated */ - i = 0; - while ((from->buffer)[i]!='\0') - i++; - i++; /* one more to catch the terminating NULL */ - /* is this necessary -- jerry? I need to think */ - - /* set up string lengths; uni_max_len is set to i+1 - because we need to account for the final NULL termination */ - to->uni_max_len = i; - to->undoc = 0; - to->uni_str_len = i; - - /* allocate the space and copy the string buffer */ - to->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), sizeof(uint16)*(to->uni_str_len)); - if (to->buffer == NULL) - smb_panic("init_unistr2_from_unistr: malloc fail\n"); - memcpy(to->buffer, from->buffer, to->uni_max_len*sizeof(uint16)); - - return; -} - - -/******************************************************************* - Reads or writes a UNISTR2 structure. - XXXX NOTE: UNISTR2 structures need NOT be null-terminated. - the uni_str_len member tells you how long the string is; - the uni_max_len member tells you how large the buffer is. -********************************************************************/ - -BOOL smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *ps, int depth) -{ - if (uni2 == NULL) - return False; - - if (buffer) { - - prs_debug(ps, depth, desc, "smb_io_unistr2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("uni_max_len", ps, depth, &uni2->uni_max_len)) - return False; - if(!prs_uint32("undoc ", ps, depth, &uni2->undoc)) - return False; - if(!prs_uint32("uni_str_len", ps, depth, &uni2->uni_str_len)) - return False; - - /* buffer advanced by indicated length of string - NOT by searching for null-termination */ - if(!prs_unistr2(True, "buffer ", ps, depth, uni2)) - return False; - - } else { - - prs_debug(ps, depth, desc, "smb_io_unistr2 - NULL"); - depth++; - memset((char *)uni2, '\0', sizeof(*uni2)); - - } - - return True; -} - - -/* - initialise a UNISTR_ARRAY from a char** -*/ -BOOL init_unistr2_array(UNISTR2_ARRAY *array, - uint32 count, const char **strings) -{ - int i; - - array->count = count; - array->ref_id = count?1:0; - if (array->count == 0) { - return True; - } - - array->strings = (UNISTR2_ARRAY_EL *)talloc_zero(get_talloc_ctx(), count * sizeof(UNISTR2_ARRAY_EL)); - if (!array->strings) { - return False; - } - - for (i=0;i<count;i++) { - init_unistr2(&array->strings[i].string, strings[i], strlen(strings[i])); - array->strings[i].size = array->strings[i].string.uni_max_len*2; - array->strings[i].length = array->strings[i].size; - array->strings[i].ref_id = 1; - } - - return True; -} - -/******************************************************************* - Reads or writes a UNISTR2_ARRAY structure. -********************************************************************/ -BOOL smb_io_unistr2_array(const char *desc, UNISTR2_ARRAY *array, prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "smb_io_unistr2_array"); - depth++; - - if(!prs_uint32("ref_id", ps, depth, &array->ref_id)) - return False; - - if (! array->ref_id) { - return True; - } - - if(!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (array->count == 0) { - return True; - } - - if (UNMARSHALLING(ps)) { - array->strings = talloc_zero(get_talloc_ctx(), array->count * sizeof(array->strings[0])); - } - if (! array->strings) { - return False; - } - - for (i=0;i<array->count;i++) { - if(!prs_uint16("length", ps, depth, &array->strings[i].length)) - return False; - if(!prs_uint16("size", ps, depth, &array->strings[i].size)) - return False; - if(!prs_uint32("ref_id", ps, depth, &array->strings[i].ref_id)) - return False; - } - - for (i=0;i<array->count;i++) { - if (! smb_io_unistr2("string", &array->strings[i].string, array->strings[i].ref_id, ps, depth)) - return False; - } - - return True; -} - - -/* - initialise a SID_ARRAY from a list of sids -*/ -BOOL init_sid_array(SID_ARRAY *array, - uint32 count, DOM_SID *sids) -{ - int i; - - array->count = count; - array->ref_id = count?1:0; - if (array->count == 0) { - return True; - } - - array->sids = (SID_ARRAY_EL *)talloc_zero(get_talloc_ctx(), count * sizeof(SID_ARRAY_EL)); - if (!array->sids) { - return False; - } - - for (i=0;i<count;i++) { - array->sids[i].ref_id = 1; - init_dom_sid2(&array->sids[i].sid, &sids[i]); - } - - return True; -} - - -/******************************************************************* - Reads or writes a SID_ARRAY structure. -********************************************************************/ -BOOL smb_io_sid_array(const char *desc, SID_ARRAY *array, prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "smb_io_sid_array"); - depth++; - - if(!prs_uint32("ref_id", ps, depth, &array->ref_id)) - return False; - - if (! array->ref_id) { - return True; - } - - if(!prs_uint32("count", ps, depth, &array->count)) - return False; - - if (array->count == 0) { - return True; - } - - if (UNMARSHALLING(ps)) { - array->sids = talloc_zero(get_talloc_ctx(), array->count * sizeof(array->sids[0])); - } - if (! array->sids) { - return False; - } - - for (i=0;i<array->count;i++) { - if(!prs_uint32("ref_id", ps, depth, &array->sids[i].ref_id)) - return False; - } - - for (i=0;i<array->count;i++) { - if (!smb_io_dom_sid2("sid", &array->sids[i].sid, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a DOM_RID2 structure. -********************************************************************/ - -void init_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx) -{ - rid2->type = type; - rid2->rid = rid; - rid2->rid_idx = idx; -} - -/******************************************************************* - Reads or writes a DOM_RID2 structure. -********************************************************************/ - -BOOL smb_io_dom_rid2(const char *desc, DOM_RID2 *rid2, prs_struct *ps, int depth) -{ - if (rid2 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_rid2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8("type ", ps, depth, &rid2->type)) - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("rid ", ps, depth, &rid2->rid)) - return False; - if(!prs_uint32("rid_idx", ps, depth, &rid2->rid_idx)) - return False; - - return True; -} - -/******************************************************************* -creates a DOM_RID3 structure. -********************************************************************/ - -void init_dom_rid3(DOM_RID3 *rid3, uint32 rid, uint8 type) -{ - rid3->rid = rid; - rid3->type1 = type; - rid3->ptr_type = 0x1; /* non-zero, basically. */ - rid3->type2 = 0x1; - rid3->unk = type; -} - -/******************************************************************* -reads or writes a DOM_RID3 structure. -********************************************************************/ - -BOOL smb_io_dom_rid3(const char *desc, DOM_RID3 *rid3, prs_struct *ps, int depth) -{ - if (rid3 == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_dom_rid3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("rid ", ps, depth, &rid3->rid)) - return False; - if(!prs_uint32("type1 ", ps, depth, &rid3->type1)) - return False; - if(!prs_uint32("ptr_type", ps, depth, &rid3->ptr_type)) - return False; - if(!prs_uint32("type2 ", ps, depth, &rid3->type2)) - return False; - if(!prs_uint32("unk ", ps, depth, &rid3->unk)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_RID4 structure. -********************************************************************/ - -void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid) -{ - rid4->unknown = unknown; - rid4->attr = attr; - rid4->rid = rid; -} - -/******************************************************************* - Inits a DOM_CLNT_SRV structure. -********************************************************************/ - -static void init_clnt_srv(DOM_CLNT_SRV *logp, const char *logon_srv, const char *comp_name) -{ - DEBUG(5,("init_clnt_srv: %d\n", __LINE__)); - - if (logon_srv != NULL) { - logp->undoc_buffer = 1; - init_unistr2(&logp->uni_logon_srv, logon_srv, strlen(logon_srv)+1); - } else { - logp->undoc_buffer = 0; - } - - if (comp_name != NULL) { - logp->undoc_buffer2 = 1; - init_unistr2(&logp->uni_comp_name, comp_name, strlen(comp_name)+1); - } else { - logp->undoc_buffer2 = 0; - } -} - -/******************************************************************* - Inits or writes a DOM_CLNT_SRV structure. -********************************************************************/ - -static BOOL smb_io_clnt_srv(const char *desc, DOM_CLNT_SRV *logp, prs_struct *ps, int depth) -{ - if (logp == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_srv"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer ", ps, depth, &logp->undoc_buffer)) - return False; - - if (logp->undoc_buffer != 0) { - if(!smb_io_unistr2("unistr2", &logp->uni_logon_srv, logp->undoc_buffer, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer2", ps, depth, &logp->undoc_buffer2)) - return False; - - if (logp->undoc_buffer2 != 0) { - if(!smb_io_unistr2("unistr2", &logp->uni_comp_name, logp->undoc_buffer2, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a DOM_LOG_INFO structure. -********************************************************************/ - -void init_log_info(DOM_LOG_INFO *logp, const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name) -{ - DEBUG(5,("make_log_info %d\n", __LINE__)); - - logp->undoc_buffer = 1; - - init_unistr2(&logp->uni_logon_srv, logon_srv, strlen(logon_srv)+1); - init_unistr2(&logp->uni_acct_name, acct_name, strlen(acct_name)+1); - - logp->sec_chan = sec_chan; - - init_unistr2(&logp->uni_comp_name, comp_name, strlen(comp_name)+1); -} - -/******************************************************************* - Reads or writes a DOM_LOG_INFO structure. -********************************************************************/ - -BOOL smb_io_log_info(const char *desc, DOM_LOG_INFO *logp, prs_struct *ps, int depth) -{ - if (logp == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_log_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer", ps, depth, &logp->undoc_buffer)) - return False; - - if(!smb_io_unistr2("unistr2", &logp->uni_logon_srv, True, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &logp->uni_acct_name, True, ps, depth)) - return False; - - if(!prs_uint16("sec_chan", ps, depth, &logp->sec_chan)) - return False; - - if(!smb_io_unistr2("unistr2", &logp->uni_comp_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_CHAL structure. -********************************************************************/ - -BOOL smb_io_chal(const char *desc, DOM_CHAL *chal, prs_struct *ps, int depth) -{ - if (chal == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_chal"); - depth++; - - if(!prs_uint8s (False, "data", ps, depth, chal->data, 8)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_CRED structure. -********************************************************************/ - -BOOL smb_io_cred(const char *desc, DOM_CRED *cred, prs_struct *ps, int depth) -{ - if (cred == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_cred"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal ("", &cred->challenge, ps, depth)) - return False; - - if(!smb_io_utime("", &cred->timestamp, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_CLNT_INFO2 structure. -********************************************************************/ - -void init_clnt_info2(DOM_CLNT_INFO2 *clnt, - const char *logon_srv, const char *comp_name, - const DOM_CRED *clnt_cred) -{ - DEBUG(5,("make_clnt_info: %d\n", __LINE__)); - - init_clnt_srv(&clnt->login, logon_srv, comp_name); - - if (clnt_cred != NULL) { - clnt->ptr_cred = 1; - memcpy(&clnt->cred, clnt_cred, sizeof(clnt->cred)); - } else { - clnt->ptr_cred = 0; - } -} - -/******************************************************************* - Reads or writes a DOM_CLNT_INFO2 structure. -********************************************************************/ - -BOOL smb_io_clnt_info2(const char *desc, DOM_CLNT_INFO2 *clnt, prs_struct *ps, int depth) -{ - if (clnt == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_srv("", &clnt->login, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_cred", ps, depth, &clnt->ptr_cred)) - return False; - if(!smb_io_cred("", &clnt->cred, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_CLNT_INFO structure. -********************************************************************/ - -void init_clnt_info(DOM_CLNT_INFO *clnt, - const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name, - const DOM_CRED *cred) -{ - DEBUG(5,("make_clnt_info\n")); - - init_log_info(&clnt->login, logon_srv, acct_name, sec_chan, comp_name); - memcpy(&clnt->cred, cred, sizeof(clnt->cred)); -} - -/******************************************************************* - Reads or writes a DOM_CLNT_INFO structure. -********************************************************************/ - -BOOL smb_io_clnt_info(const char *desc, DOM_CLNT_INFO *clnt, prs_struct *ps, int depth) -{ - if (clnt == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_clnt_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info("", &clnt->login, ps, depth)) - return False; - if(!smb_io_cred("", &clnt->cred, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a DOM_LOGON_ID structure. -********************************************************************/ - -void init_logon_id(DOM_LOGON_ID *logp, uint32 log_id_low, uint32 log_id_high) -{ - DEBUG(5,("make_logon_id: %d\n", __LINE__)); - - logp->low = log_id_low; - logp->high = log_id_high; -} - -/******************************************************************* - Reads or writes a DOM_LOGON_ID structure. -********************************************************************/ - -BOOL smb_io_logon_id(const char *desc, DOM_LOGON_ID *logp, prs_struct *ps, int depth) -{ - if (logp == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_logon_id"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("low ", ps, depth, &logp->low )) - return False; - if(!prs_uint32("high", ps, depth, &logp->high)) - return False; - - return True; -} - -/******************************************************************* - Inits an OWF_INFO structure. -********************************************************************/ - -void init_owf_info(OWF_INFO *hash, const uint8 data[16]) -{ - DEBUG(5,("init_owf_info: %d\n", __LINE__)); - - if (data != NULL) - memcpy(hash->data, data, sizeof(hash->data)); - else - memset((char *)hash->data, '\0', sizeof(hash->data)); -} - -/******************************************************************* - Reads or writes an OWF_INFO structure. -********************************************************************/ - -BOOL smb_io_owf_info(const char *desc, OWF_INFO *hash, prs_struct *ps, int depth) -{ - if (hash == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_owf_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s (False, "data", ps, depth, hash->data, 16)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a DOM_GID structure. -********************************************************************/ - -BOOL smb_io_gid(const char *desc, DOM_GID *gid, prs_struct *ps, int depth) -{ - if (gid == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_gid"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("g_rid", ps, depth, &gid->g_rid)) - return False; - if(!prs_uint32("attr ", ps, depth, &gid->attr)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an POLICY_HND structure. -********************************************************************/ - -BOOL smb_io_pol_hnd(const char *desc, POLICY_HND *pol, prs_struct *ps, int depth) -{ - if (pol == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_pol_hnd"); - depth++; - - if(!prs_align(ps)) - return False; - - if(UNMARSHALLING(ps)) - ZERO_STRUCTP(pol); - - if (!prs_uint32("data1", ps, depth, &pol->data1)) - return False; - if (!prs_uint32("data2", ps, depth, &pol->data2)) - return False; - if (!prs_uint16("data3", ps, depth, &pol->data3)) - return False; - if (!prs_uint16("data4", ps, depth, &pol->data4)) - return False; - if(!prs_uint8s (False, "data5", ps, depth, pol->data5, sizeof(pol->data5))) - return False; - - return True; -} - -/******************************************************************* - Create a UNISTR3. -********************************************************************/ - -void init_unistr3(UNISTR3 *str, const char *buf) -{ - size_t len; - - if (buf == NULL) { - str->uni_str_len=0; - str->str.buffer = NULL; - return; - } - - len = strlen(buf) + 1; - - str->uni_str_len=len; - - if (len < MAX_UNISTRLEN) - len = MAX_UNISTRLEN; - - len *= sizeof(uint16); - - str->str.buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len); - if (str->str.buffer == NULL) - smb_panic("init_unistr3: malloc fail\n"); - - rpcstr_push((char *)str->str.buffer, buf, len, STR_TERMINATE); -} - -/******************************************************************* - Reads or writes a UNISTR3 structure. -********************************************************************/ - -BOOL smb_io_unistr3(const char *desc, UNISTR3 *name, prs_struct *ps, int depth) -{ - if (name == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_unistr3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("uni_str_len", ps, depth, &name->uni_str_len)) - return False; - - /* don't know if len is specified by uni_str_len member... */ - /* assume unicode string is unicode-null-terminated, instead */ - - if(!prs_unistr3(True, "unistr", name, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* - Stream a uint64_struct - ********************************************************************/ -BOOL prs_uint64(const char *name, prs_struct *ps, int depth, UINT64_S *data64) -{ - return prs_uint32(name, ps, depth+1, &data64->low) && - prs_uint32(name, ps, depth+1, &data64->high); -} - -/******************************************************************* -reads or writes a BUFHDR2 structure. -********************************************************************/ -BOOL smb_io_bufhdr2(const char *desc, BUFHDR2 *hdr, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_bufhdr2"); - depth++; - - prs_align(ps); - prs_uint32("info_level", ps, depth, &(hdr->info_level)); - prs_uint32("length ", ps, depth, &(hdr->length )); - prs_uint32("buffer ", ps, depth, &(hdr->buffer )); - - return True; -} - -/******************************************************************* -reads or writes a BUFFER4 structure. -********************************************************************/ -BOOL smb_io_buffer4(const char *desc, BUFFER4 *buf4, uint32 buffer, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_buffer4"); - depth++; - - prs_align(ps); - prs_uint32("buf_len", ps, depth, &(buf4->buf_len)); - - if (buf4->buf_len > MAX_BUFFERLEN) - { - buf4->buf_len = MAX_BUFFERLEN; - } - - prs_uint8s(True, "buffer", ps, depth, buf4->buffer, buf4->buf_len); - - return True; -} - -/******************************************************************* -creates a UNIHDR structure. -********************************************************************/ - -BOOL make_uni_hdr(UNIHDR *hdr, int len) -{ - if (hdr == NULL) - { - return False; - } - hdr->uni_str_len = 2 * len; - hdr->uni_max_len = 2 * len; - hdr->buffer = len != 0 ? 1 : 0; - - return True; -} - -/******************************************************************* -creates a BUFHDR2 structure. -********************************************************************/ -BOOL make_bufhdr2(BUFHDR2 *hdr, uint32 info_level, uint32 length, uint32 buffer) -{ - hdr->info_level = info_level; - hdr->length = length; - hdr->buffer = buffer; - - return True; -} diff --git a/source4/rpc_parse/parse_net.c b/source4/rpc_parse/parse_net.c deleted file mode 100644 index 53f660fcc3..0000000000 --- a/source4/rpc_parse/parse_net.c +++ /dev/null @@ -1,2971 +0,0 @@ -/* - * 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) Jean François Micouleau 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 - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL net_io_neg_flags(const char *desc, NEG_FLAGS *neg, prs_struct *ps, int depth) -{ - if (neg == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_neg_flags"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("neg_flags", ps, depth, &neg->neg_flags)) - return False; - - return True; -} - -/******************************************************************* - Inits a NETLOGON_INFO_3 structure. -********************************************************************/ - -static void init_netinfo_3(NETLOGON_INFO_3 *info, uint32 flags, uint32 logon_attempts) -{ - info->flags = flags; - info->logon_attempts = logon_attempts; - info->reserved_1 = 0x0; - info->reserved_2 = 0x0; - info->reserved_3 = 0x0; - info->reserved_4 = 0x0; - info->reserved_5 = 0x0; -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_3 structure. -********************************************************************/ - -static BOOL net_io_netinfo_3(const char *desc, NETLOGON_INFO_3 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("logon_attempts", ps, depth, &info->logon_attempts)) - return False; - if(!prs_uint32("reserved_1 ", ps, depth, &info->reserved_1)) - return False; - if(!prs_uint32("reserved_2 ", ps, depth, &info->reserved_2)) - return False; - if(!prs_uint32("reserved_3 ", ps, depth, &info->reserved_3)) - return False; - if(!prs_uint32("reserved_4 ", ps, depth, &info->reserved_4)) - return False; - if(!prs_uint32("reserved_5 ", ps, depth, &info->reserved_5)) - return False; - - return True; -} - - -/******************************************************************* - Inits a NETLOGON_INFO_1 structure. -********************************************************************/ - -static void init_netinfo_1(NETLOGON_INFO_1 *info, uint32 flags, uint32 pdc_status) -{ - info->flags = flags; - info->pdc_status = pdc_status; -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_1 structure. -********************************************************************/ - -static BOOL net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("pdc_status", ps, depth, &info->pdc_status)) - return False; - - return True; -} - -/******************************************************************* - Inits a NETLOGON_INFO_2 structure. -********************************************************************/ - -static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status, - uint32 tc_status, const char *trusted_dc_name) -{ - int len_dc_name = strlen(trusted_dc_name); - info->flags = flags; - info->pdc_status = pdc_status; - info->ptr_trusted_dc_name = 1; - info->tc_status = tc_status; - - if (trusted_dc_name != NULL) - init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, len_dc_name+1); - else - init_unistr2(&info->uni_trusted_dc_name, "", 1); -} - -/******************************************************************* - Reads or writes a NETLOGON_INFO_2 structure. -********************************************************************/ - -static BOOL net_io_netinfo_2(const char *desc, NETLOGON_INFO_2 *info, prs_struct *ps, int depth) -{ - if (info == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_netinfo_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &info->flags)) - return False; - if(!prs_uint32("pdc_status ", ps, depth, &info->pdc_status)) - return False; - if(!prs_uint32("ptr_trusted_dc_name", ps, depth, &info->ptr_trusted_dc_name)) - return False; - if(!prs_uint32("tc_status ", ps, depth, &info->tc_status)) - return False; - - if (info->ptr_trusted_dc_name != 0) { - if(!smb_io_unistr2("unistr2", &info->uni_trusted_dc_name, info->ptr_trusted_dc_name, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an NET_Q_LOGON_CTRL2 structure. -********************************************************************/ - -BOOL net_io_q_logon_ctrl2(const char *desc, NET_Q_LOGON_CTRL2 *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_logon_ctrl2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) - return False; - - if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) - return False; - if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) - return False; - if(!prs_uint32("switch_value ", ps, depth, &q_l->switch_value)) - return False; - - return True; -} - -/******************************************************************* - Inits an NET_Q_LOGON_CTRL2 structure. -********************************************************************/ - -void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name, - uint32 query_level) -{ - DEBUG(5,("init_q_logon_ctrl2\n")); - - q_l->function_code = 0x01; - q_l->query_level = query_level; - q_l->switch_value = 0x01; - - init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1); -} - -/******************************************************************* - Inits an NET_R_LOGON_CTRL2 structure. -********************************************************************/ - -void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status, - uint32 logon_attempts, uint32 tc_status, - const char *trusted_domain_name) -{ - DEBUG(5,("init_r_logon_ctrl2\n")); - - r_l->switch_value = query_level; /* should only be 0x1 */ - - switch (query_level) { - case 1: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_1(&r_l->logon.info1, flags, pdc_status); - r_l->status = NT_STATUS_OK; - break; - case 2: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_2(&r_l->logon.info2, flags, pdc_status, - tc_status, trusted_domain_name); - r_l->status = NT_STATUS_OK; - break; - case 3: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_3(&r_l->logon.info3, flags, logon_attempts); - r_l->status = NT_STATUS_OK; - break; - default: - DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n", - r_l->switch_value)); - r_l->ptr = 0; /* undocumented pointer */ - - /* take a guess at an error code... */ - r_l->status = NT_STATUS_INVALID_INFO_CLASS; - break; - } -} - -/******************************************************************* - Reads or writes an NET_R_LOGON_CTRL2 structure. -********************************************************************/ - -BOOL net_io_r_logon_ctrl2(const char *desc, NET_R_LOGON_CTRL2 *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_logon_ctrl2"); - depth++; - - if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) - return False; - - if (r_l->ptr != 0) { - switch (r_l->switch_value) { - case 1: - if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) - return False; - break; - case 2: - if(!net_io_netinfo_2("", &r_l->logon.info2, ps, depth)) - return False; - break; - case 3: - if(!net_io_netinfo_3("", &r_l->logon.info3, ps, depth)) - return False; - break; - default: - DEBUG(2,("net_io_r_logon_ctrl2: unsupported switch value %d\n", - r_l->switch_value)); - break; - } - } - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes an NET_Q_LOGON_CTRL structure. -********************************************************************/ - -BOOL net_io_q_logon_ctrl(const char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_logon_ctrl"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) - return False; - - if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("function_code", ps, depth, &q_l->function_code)) - return False; - if(!prs_uint32("query_level ", ps, depth, &q_l->query_level)) - return False; - - return True; -} - -/******************************************************************* - Inits an NET_Q_LOGON_CTRL structure. -********************************************************************/ - -void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name, - uint32 query_level) -{ - DEBUG(5,("init_q_logon_ctrl\n")); - - q_l->function_code = 0x01; /* ??? */ - q_l->query_level = query_level; - - init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1); -} - -/******************************************************************* - Inits an NET_R_LOGON_CTRL structure. -********************************************************************/ - -void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level, - uint32 flags, uint32 pdc_status) -{ - DEBUG(5,("init_r_logon_ctrl\n")); - - r_l->switch_value = query_level; /* should only be 0x1 */ - - switch (query_level) { - case 1: - r_l->ptr = 1; /* undocumented pointer */ - init_netinfo_1(&r_l->logon.info1, flags, pdc_status); - r_l->status = NT_STATUS_OK; - break; - default: - DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n", - r_l->switch_value)); - r_l->ptr = 0; /* undocumented pointer */ - - /* take a guess at an error code... */ - r_l->status = NT_STATUS_INVALID_INFO_CLASS; - break; - } -} - -/******************************************************************* - Reads or writes an NET_R_LOGON_CTRL structure. -********************************************************************/ - -BOOL net_io_r_logon_ctrl(const char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_r_logon_ctrl"); - depth++; - - if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_l->ptr)) - return False; - - if (r_l->ptr != 0) { - switch (r_l->switch_value) { - case 1: - if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth)) - return False; - break; - default: - DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n", - r_l->switch_value)); - break; - } - } - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an NET_R_TRUST_DOM_LIST structure. -********************************************************************/ - -void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t, - uint32 num_doms, const char *dom_name) -{ - int i = 0; - - DEBUG(5,("init_r_trust_dom\n")); - - for (i = 0; i < MAX_TRUST_DOMS; i++) { - r_t->uni_trust_dom_name[i].uni_str_len = 0; - r_t->uni_trust_dom_name[i].uni_max_len = 0; - } - if (num_doms > MAX_TRUST_DOMS) - num_doms = MAX_TRUST_DOMS; - - for (i = 0; i < num_doms; i++) { - fstring domain_name; - fstrcpy(domain_name, dom_name); - strupper(domain_name); - init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, strlen(domain_name)+1); - /* the use of UNISTR2 here is non-standard. */ - r_t->uni_trust_dom_name[i].undoc = 0x1; - } - - r_t->status = NT_STATUS_OK; -} - -/******************************************************************* - Reads or writes an NET_R_TRUST_DOM_LIST structure. -********************************************************************/ - -BOOL net_io_r_trust_dom(const char *desc, NET_R_TRUST_DOM_LIST *r_t, prs_struct *ps, int depth) -{ - uint32 value; - - if (r_t == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_trust_dom"); - depth++; - - /* temporary code to give a valid response */ - value=2; - if(!prs_uint32("status", ps, depth, &value)) - return False; - - value=1; - if(!prs_uint32("status", ps, depth, &value)) - return False; - value=2; - if(!prs_uint32("status", ps, depth, &value)) - return False; - - value=0; - if(!prs_uint32("status", ps, depth, &value)) - return False; - - value=0; - if(!prs_uint32("status", ps, depth, &value)) - return False; - -/* old non working code */ -#if 0 - int i; - - for (i = 0; i < MAX_TRUST_DOMS; i++) { - if (r_t->uni_trust_dom_name[i].uni_str_len == 0) - break; - if(!smb_io_unistr2("", &r_t->uni_trust_dom_name[i], True, ps, depth)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_t->status)) - return False; -#endif - return True; -} - - -/******************************************************************* - Reads or writes an NET_Q_TRUST_DOM_LIST structure. -********************************************************************/ - -BOOL net_io_q_trust_dom(const char *desc, NET_Q_TRUST_DOM_LIST *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_trust_dom"); - depth++; - - if(!prs_uint32("ptr ", ps, depth, &q_l->ptr)) - return False; - if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits an NET_Q_REQ_CHAL structure. -********************************************************************/ - -void init_q_req_chal(NET_Q_REQ_CHAL *q_c, - const char *logon_srv, const char *logon_clnt, - DOM_CHAL *clnt_chal) -{ - DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); - - q_c->undoc_buffer = 1; /* don't know what this buffer is */ - - init_unistr2(&q_c->uni_logon_srv, logon_srv , strlen(logon_srv )+1); - init_unistr2(&q_c->uni_logon_clnt, logon_clnt, strlen(logon_clnt)+1); - - memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - - DEBUG(5,("init_q_req_chal: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes an NET_Q_REQ_CHAL structure. -********************************************************************/ - -BOOL net_io_q_req_chal(const char *desc, NET_Q_REQ_CHAL *q_c, prs_struct *ps, int depth) -{ - if (q_c == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_req_chal"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("undoc_buffer", ps, depth, &q_c->undoc_buffer)) - return False; - - if(!smb_io_unistr2("", &q_c->uni_logon_srv, True, ps, depth)) /* logon server unicode string */ - return False; - if(!smb_io_unistr2("", &q_c->uni_logon_clnt, True, ps, depth)) /* logon client unicode string */ - return False; - - if(!smb_io_chal("", &q_c->clnt_chal, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_req_chal(const char *desc, NET_R_REQ_CHAL *r_c, prs_struct *ps, int depth) -{ - if (r_c == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_req_chal"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_c->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_auth(const char *desc, NET_Q_AUTH *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_auth(const char *desc, NET_R_AUTH *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a NET_Q_AUTH_2 struct. -********************************************************************/ - -void init_q_auth_2(NET_Q_AUTH_2 *q_a, - const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name, - DOM_CHAL *clnt_chal, uint32 clnt_flgs) -{ - DEBUG(5,("init_q_auth_2: %d\n", __LINE__)); - - init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name); - memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - q_a->clnt_flgs.neg_flags = clnt_flgs; - - DEBUG(5,("init_q_auth_2: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_auth_2(const char *desc, NET_Q_AUTH_2 *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_auth_2(const char *desc, NET_R_AUTH_2 *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a NET_Q_AUTH_3 struct. -********************************************************************/ - -void init_q_auth_3(NET_Q_AUTH_3 *q_a, - const char *logon_srv, const char *acct_name, uint16 sec_chan, const char *comp_name, - DOM_CHAL *clnt_chal, uint32 clnt_flgs) -{ - DEBUG(5,("init_q_auth_3: %d\n", __LINE__)); - - init_log_info(&q_a->clnt_id, logon_srv, acct_name, sec_chan, comp_name); - memcpy(q_a->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); - q_a->clnt_flgs.neg_flags = clnt_flgs; - - DEBUG(5,("init_q_auth_3: %d\n", __LINE__)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_auth_3(const char *desc, NET_Q_AUTH_3 *q_a, prs_struct *ps, int depth) -{ - if (q_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_auth_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_log_info ("", &q_a->clnt_id, ps, depth)) /* client identification info */ - return False; - if(!smb_io_chal("", &q_a->clnt_chal, ps, depth)) - return False; - if(!net_io_neg_flags("", &q_a->clnt_flgs, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_auth_3(const char *desc, NET_R_AUTH_3 *r_a, prs_struct *ps, int depth) -{ - if (r_a == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_auth_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_chal("srv_chal", &r_a->srv_chal, ps, depth)) /* server challenge */ - return False; - if(!net_io_neg_flags("srv_flgs", &r_a->srv_flgs, ps, depth)) - return False; - if (!prs_uint32("unknown", ps, depth, &r_a->unknown)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_a->status)) - return False; - - return True; -} - - -/******************************************************************* - Inits a NET_Q_SRV_PWSET. -********************************************************************/ - -void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, - const char *logon_srv, const char *sess_key, const char *acct_name, - uint16 sec_chan, const char *comp_name, - DOM_CRED *cred, uchar hashed_mach_pwd[16]) -{ - unsigned char nt_cypher[16]; - - DEBUG(5,("init_q_srv_pwset\n")); - - /* Process the new password. */ - cred_hash3( nt_cypher, hashed_mach_pwd, sess_key, 1); - - init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred); - - memcpy(q_s->pwd, nt_cypher, sizeof(q_s->pwd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_srv_pwset(const char *desc, NET_Q_SRV_PWSET *q_s, prs_struct *ps, int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_srv_pwset"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_info("", &q_s->clnt_id, ps, depth)) /* client identification/authentication info */ - return False; - if(!prs_uint8s (False, "pwd", ps, depth, q_s->pwd, 16)) /* new password - undocumented */ - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_srv_pwset(const char *desc, NET_R_SRV_PWSET *r_s, prs_struct *ps, int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_srv_pwset"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */ - return False; - - if(!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} - -/************************************************************************* - Init DOM_SID2 array from a string containing multiple sids - *************************************************************************/ - -static int init_dom_sid2s(TALLOC_CTX *ctx, const char *sids_str, DOM_SID2 **ppsids) -{ - const char *ptr; - pstring s2; - int count = 0; - - DEBUG(4,("init_dom_sid2s: %s\n", sids_str ? sids_str:"")); - - *ppsids = NULL; - - if(sids_str) { - int number; - DOM_SID2 *sids; - - /* Count the number of valid SIDs. */ - for (count = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) { - DOM_SID tmpsid; - if (string_to_sid(&tmpsid, s2)) - count++; - } - - /* Now allocate space for them. */ - *ppsids = (DOM_SID2 *)talloc_zero(ctx, count * sizeof(DOM_SID2)); - if (*ppsids == NULL) - return 0; - - sids = *ppsids; - - for (number = 0, ptr = sids_str; next_token(&ptr, s2, NULL, sizeof(s2)); ) { - DOM_SID tmpsid; - if (string_to_sid(&tmpsid, s2)) { - /* count only valid sids */ - init_dom_sid2(&sids[number], &tmpsid); - number++; - } - } - } - - return count; -} - -/******************************************************************* - Inits a NET_ID_INFO_1 structure. -********************************************************************/ - -void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name, - uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high, - const char *user_name, const char *wksta_name, - const char *sess_key, - unsigned char lm_cypher[16], unsigned char nt_cypher[16]) -{ - int len_domain_name = strlen(domain_name); - int len_user_name = strlen(user_name ); - int len_wksta_name = strlen(wksta_name ); - - unsigned char lm_owf[16]; - unsigned char nt_owf[16]; - - DEBUG(5,("init_id_info1: %d\n", __LINE__)); - - id->ptr_id_info1 = 1; - - init_uni_hdr(&id->hdr_domain_name, len_domain_name); - - id->param_ctrl = param_ctrl; - init_logon_id(&id->logon_id, log_id_low, log_id_high); - - init_uni_hdr(&id->hdr_user_name, len_user_name); - init_uni_hdr(&id->hdr_wksta_name, len_wksta_name); - - if (lm_cypher && nt_cypher) { - unsigned char key[16]; -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm cypher:")); - dump_data(100, (char *)lm_cypher, 16); - - DEBUG(100,("nt cypher:")); - dump_data(100, (char *)nt_cypher, 16); -#endif - - memset(key, 0, 16); - memcpy(key, sess_key, 8); - - memcpy(lm_owf, lm_cypher, 16); - SamOEMhash(lm_owf, key, 16); - memcpy(nt_owf, nt_cypher, 16); - SamOEMhash(nt_owf, key, 16); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("encrypt of lm owf password:")); - dump_data(100, (char *)lm_owf, 16); - - DEBUG(100,("encrypt of nt owf password:")); - dump_data(100, (char *)nt_owf, 16); -#endif - /* set up pointers to cypher blocks */ - lm_cypher = lm_owf; - nt_cypher = nt_owf; - } - - init_owf_info(&id->lm_owf, lm_cypher); - init_owf_info(&id->nt_owf, nt_cypher); - - init_unistr2(&id->uni_domain_name, domain_name, len_domain_name); - init_unistr2(&id->uni_user_name, user_name, len_user_name); - init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name); -} - -/******************************************************************* - Reads or writes an NET_ID_INFO_1 structure. -********************************************************************/ - -static BOOL net_io_id_info1(const char *desc, NET_ID_INFO_1 *id, prs_struct *ps, int depth) -{ - if (id == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_id_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_id_info1", ps, depth, &id->ptr_id_info1)) - return False; - - if (id->ptr_id_info1 != 0) { - if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth)) - return False; - - if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl)) - return False; - if(!smb_io_logon_id("", &id->logon_id, ps, depth)) - return False; - - if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth)) - return False; - - if(!smb_io_owf_info("", &id->lm_owf, ps, depth)) - return False; - if(!smb_io_owf_info("", &id->nt_owf, ps, depth)) - return False; - - if(!smb_io_unistr2("unistr2", &id->uni_domain_name, - id->hdr_domain_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &id->uni_user_name, - id->hdr_user_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("unistr2", &id->uni_wksta_name, - id->hdr_wksta_name.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -Inits a NET_ID_INFO_2 structure. - -This is a network logon packet. The log_id parameters -are what an NT server would generate for LUID once the -user is logged on. I don't think we care about them. - -Note that this has no access to the NT and LM hashed passwords, -so it forwards the challenge, and the NT and LM responses (24 -bytes each) over the secure channel to the Domain controller -for it to say yea or nay. This is the preferred method of -checking for a logon as it doesn't export the password -hashes to anyone who has compromised the secure channel. JRA. -********************************************************************/ - -void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name, - uint32 param_ctrl, - uint32 log_id_low, uint32 log_id_high, - const char *user_name, const char *wksta_name, - const uchar lm_challenge[8], - const uchar * lm_chal_resp, int lm_chal_resp_len, - const uchar * nt_chal_resp, int nt_chal_resp_len) -{ - int len_domain_name = strlen(domain_name); - int len_user_name = strlen(user_name ); - int len_wksta_name = strlen(wksta_name ); - unsigned char lm_owf[24]; - unsigned char nt_owf[128]; - - DEBUG(5,("init_id_info2: %d\n", __LINE__)); - - id->ptr_id_info2 = 1; - - init_uni_hdr(&id->hdr_domain_name, len_domain_name); - - id->param_ctrl = param_ctrl; - init_logon_id(&id->logon_id, log_id_low, log_id_high); - - init_uni_hdr(&id->hdr_user_name, len_user_name); - init_uni_hdr(&id->hdr_wksta_name, len_wksta_name); - - if (nt_chal_resp) { - /* oops. can only send what-ever-it-is direct */ - memcpy(nt_owf, nt_chal_resp, MIN(sizeof(nt_owf), nt_chal_resp_len)); - nt_chal_resp = nt_owf; - } - if (lm_chal_resp) { - /* oops. can only send what-ever-it-is direct */ - memcpy(lm_owf, lm_chal_resp, MIN(sizeof(lm_owf), lm_chal_resp_len)); - lm_chal_resp = lm_owf; - } - - memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal)); - init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0); - init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0); - - init_unistr2(&id->uni_domain_name, domain_name, len_domain_name); - init_unistr2(&id->uni_user_name, user_name, len_user_name); - init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name); - - init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len); - init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len); - -} - -/******************************************************************* - Reads or writes an NET_ID_INFO_2 structure. -********************************************************************/ - -static BOOL net_io_id_info2(const char *desc, NET_ID_INFO_2 *id, prs_struct *ps, int depth) -{ - if (id == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_id_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_id_info2", ps, depth, &id->ptr_id_info2)) - return False; - - if (id->ptr_id_info2 != 0) { - if(!smb_io_unihdr("unihdr", &id->hdr_domain_name, ps, depth)) - return False; - - if(!prs_uint32("param_ctrl", ps, depth, &id->param_ctrl)) - return False; - if(!smb_io_logon_id("", &id->logon_id, ps, depth)) - return False; - - if(!smb_io_unihdr("unihdr", &id->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unihdr("unihdr", &id->hdr_wksta_name, ps, depth)) - return False; - - if(!prs_uint8s (False, "lm_chal", ps, depth, id->lm_chal, 8)) /* lm 8 byte challenge */ - return False; - - if(!smb_io_strhdr("hdr_nt_chal_resp", &id->hdr_nt_chal_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_lm_chal_resp", &id->hdr_lm_chal_resp, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_domain_name", &id->uni_domain_name, - id->hdr_domain_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_user_name ", &id->uni_user_name, - id->hdr_user_name.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_wksta_name ", &id->uni_wksta_name, - id->hdr_wksta_name.buffer, ps, depth)) - return False; - if(!smb_io_string2("nt_chal_resp", &id->nt_chal_resp, - id->hdr_nt_chal_resp.buffer, ps, depth)) - return False; - if(!smb_io_string2("lm_chal_resp", &id->lm_chal_resp, - id->hdr_lm_chal_resp.buffer, ps, depth)) - return False; - } - - return True; -} - - -/******************************************************************* - Inits a DOM_SAM_INFO structure. -********************************************************************/ - -void init_sam_info(DOM_SAM_INFO *sam, - const char *logon_srv, const char *comp_name, - DOM_CRED *clnt_cred, - DOM_CRED *rtn_cred, uint16 logon_level, - NET_ID_INFO_CTR *ctr) -{ - DEBUG(5,("init_sam_info: %d\n", __LINE__)); - - init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred); - - if (rtn_cred != NULL) { - sam->ptr_rtn_cred = 1; - memcpy(&sam->rtn_cred, rtn_cred, sizeof(sam->rtn_cred)); - } else { - sam->ptr_rtn_cred = 0; - } - - sam->logon_level = logon_level; - sam->ctr = ctr; -} - -/******************************************************************* - Reads or writes a DOM_SAM_INFO structure. -********************************************************************/ - -static BOOL net_io_id_info_ctr(const char *desc, NET_ID_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - NET_ID_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "smb_io_sam_info"); - depth++; - - if (UNMARSHALLING(ps)) { - ctr = *pp_ctr = (NET_ID_INFO_CTR *)prs_alloc_mem(ps, sizeof(NET_ID_INFO_CTR)); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - /* don't 4-byte align here! */ - - if(!prs_uint16("switch_value ", ps, depth, &ctr->switch_value)) - return False; - - switch (ctr->switch_value) { - case 1: - if(!net_io_id_info1("", &ctr->auth.id1, ps, depth)) - return False; - break; - case 2: - if(!net_io_id_info2("", &ctr->auth.id2, ps, depth)) - return False; - break; - default: - /* PANIC! */ - DEBUG(4,("smb_io_sam_info: unknown switch_value!\n")); - break; - } - - return True; -} - -/******************************************************************* - Reads or writes a DOM_SAM_INFO structure. - ********************************************************************/ - -static BOOL smb_io_sam_info(const char *desc, DOM_SAM_INFO *sam, prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_sam_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_clnt_info2("", &sam->client, ps, depth)) - return False; - - if(!prs_uint32("ptr_rtn_cred ", ps, depth, &sam->ptr_rtn_cred)) - return False; - if(!smb_io_cred("", &sam->rtn_cred, ps, depth)) - return False; - - if(!prs_uint16("logon_level ", ps, depth, &sam->logon_level)) - return False; - - if (sam->logon_level != 0) { - if(!net_io_id_info_ctr("logon_info", &sam->ctr, ps, depth)) - return False; - } - - return True; -} - -/************************************************************************* - Inits a NET_USER_INFO_3 structure. - - This is a network logon reply packet, and contains much information about - the user. This information is passed as a (very long) paramater list - to avoid having to link in the PASSDB code to every program that deals - with this file. - *************************************************************************/ - -void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, - uint32 user_rid, - uint32 group_rid, - - const char* user_name, - const char* full_name, - const char* home_dir, - const char* dir_drive, - const char* logon_script, - const char* profile_path, - - time_t unix_logon_time, - time_t unix_logoff_time, - time_t unix_kickoff_time, - time_t unix_pass_last_set_time, - time_t unix_pass_can_change_time, - time_t unix_pass_must_change_time, - - uint16 logon_count, uint16 bad_pw_count, - uint32 num_groups, const DOM_GID *gids, - uint32 user_flgs, uchar sess_key[16], - const char *logon_srv, const char *logon_dom, - const DOM_SID *dom_sid, const char *other_sids) -{ - /* only cope with one "other" sid, right now. */ - /* need to count the number of space-delimited sids */ - int i; - int num_other_sids = 0; - - NTTIME logon_time, logoff_time, kickoff_time, - pass_last_set_time, pass_can_change_time, - pass_must_change_time; - - int len_user_name, len_full_name, len_home_dir, - len_dir_drive, len_logon_script, len_profile_path; - - int len_logon_srv = strlen(logon_srv); - int len_logon_dom = strlen(logon_dom); - - len_user_name = strlen(user_name ); - len_full_name = strlen(full_name ); - len_home_dir = strlen(home_dir ); - len_dir_drive = strlen(dir_drive ); - len_logon_script = strlen(logon_script); - len_profile_path = strlen(profile_path); - - - ZERO_STRUCTP(usr); - - usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */ - - - /* Create NTTIME structs */ - unix_to_nt_time (&logon_time, unix_logon_time); - unix_to_nt_time (&logoff_time, unix_logoff_time); - unix_to_nt_time (&kickoff_time, unix_kickoff_time); - unix_to_nt_time (&pass_last_set_time, unix_pass_last_set_time); - unix_to_nt_time (&pass_can_change_time, unix_pass_can_change_time); - unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time); - - usr->logon_time = logon_time; - usr->logoff_time = logoff_time; - usr->kickoff_time = kickoff_time; - usr->pass_last_set_time = pass_last_set_time; - usr->pass_can_change_time = pass_can_change_time; - usr->pass_must_change_time = pass_must_change_time; - - init_uni_hdr(&usr->hdr_user_name, len_user_name); - init_uni_hdr(&usr->hdr_full_name, len_full_name); - init_uni_hdr(&usr->hdr_logon_script, len_logon_script); - init_uni_hdr(&usr->hdr_profile_path, len_profile_path); - init_uni_hdr(&usr->hdr_home_dir, len_home_dir); - init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive); - - usr->logon_count = logon_count; - usr->bad_pw_count = bad_pw_count; - - usr->user_rid = user_rid; - usr->group_rid = group_rid; - usr->num_groups = num_groups; - - usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */ - usr->user_flgs = user_flgs; - - if (sess_key != NULL) - memcpy(usr->user_sess_key, sess_key, sizeof(usr->user_sess_key)); - else - memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key)); - - init_uni_hdr(&usr->hdr_logon_srv, len_logon_srv); - init_uni_hdr(&usr->hdr_logon_dom, len_logon_dom); - - usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */ - - memset((char *)usr->padding, '\0', sizeof(usr->padding)); - - num_other_sids = init_dom_sid2s(ctx, other_sids, &usr->other_sids); - - usr->num_other_sids = num_other_sids; - usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0; - - init_unistr2(&usr->uni_user_name, user_name, len_user_name); - init_unistr2(&usr->uni_full_name, full_name, len_full_name); - init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script); - init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path); - init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir); - init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive); - - usr->num_groups2 = num_groups; - - usr->gids = (DOM_GID *)talloc_zero(ctx,sizeof(DOM_GID) * (num_groups)); - if (usr->gids == NULL && num_groups>0) - return; - - for (i = 0; i < num_groups; i++) - usr->gids[i] = gids[i]; - - init_unistr2(&usr->uni_logon_srv, logon_srv, len_logon_srv); - init_unistr2(&usr->uni_logon_dom, logon_dom, len_logon_dom); - - init_dom_sid2(&usr->dom_sid, dom_sid); - /* "other" sids are set up above */ -} - -/******************************************************************* - This code has been modified to cope with a NET_USER_INFO_2 - which is - exactly the same as a NET_USER_INFO_3, minus the other sids parameters. - We use validation level to determine if we're marshalling a info 2 or - INFO_3 - be we always return an INFO_3. Based on code donated by Marc - Jacobsen at HP. JRA. -********************************************************************/ - -BOOL net_io_user_info3(const char *desc, NET_USER_INFO_3 *usr, prs_struct *ps, - int depth, uint16 validation_level) -{ - int i; - - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_user_info3"); - depth++; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(usr); - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_user_info ", ps, depth, &usr->ptr_user_info)) - return False; - - if (usr->ptr_user_info == 0) - return True; - - if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */ - return False; - if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */ - return False; - if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */ - return False; - if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */ - return False; - if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */ - return False; - if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */ - return False; - - if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ - return False; - if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ - return False; - if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ - return False; - if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ - return False; - if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ - return False; - if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */ - return False; - - if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) /* logon count */ - return False; - if(!prs_uint16("bad_pw_count ", ps, depth, &usr->bad_pw_count)) /* bad password count */ - return False; - - if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User RID */ - return False; - if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group RID */ - return False; - if(!prs_uint32("num_groups ", ps, depth, &usr->num_groups)) /* num groups */ - return False; - if(!prs_uint32("buffer_groups ", ps, depth, &usr->buffer_groups)) /* undocumented buffer pointer to groups. */ - return False; - if(!prs_uint32("user_flgs ", ps, depth, &usr->user_flgs)) /* user flags */ - return False; - - if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* user session key */ - return False; - - if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */ - return False; - if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */ - return False; - - if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */ - return False; - if(!prs_uint8s (False, "padding ", ps, depth, usr->padding, 40)) /* unused padding bytes? */ - return False; - - if (validation_level == 3) { - if(!prs_uint32("num_other_sids", ps, depth, &usr->num_other_sids)) /* 0 - num_sids */ - return False; - if(!prs_uint32("buffer_other_sids", ps, depth, &usr->buffer_other_sids)) /* NULL - undocumented pointer to SIDs. */ - return False; - } else { - if (UNMARSHALLING(ps)) { - usr->num_other_sids = 0; - usr->buffer_other_sids = 0; - } - } - - if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ - return False; - if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ - return False; - if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ - return False; - if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ - return False; - if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ - return False; - if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_groups2 ", ps, depth, &usr->num_groups2)) /* num groups */ - return False; - - if (UNMARSHALLING(ps) && usr->num_groups2 > 0) { - usr->gids = (DOM_GID *)prs_alloc_mem(ps, sizeof(DOM_GID)*usr->num_groups2); - if (usr->gids == NULL) - return False; - } - - for (i = 0; i < usr->num_groups2; i++) { - if(!smb_io_gid("", &usr->gids[i], ps, depth)) /* group info */ - return False; - } - - if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */ - return False; - if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_srv.buffer, ps, depth)) /* logon domain unicode string */ - return False; - - if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth)) /* domain SID */ - return False; - - if (usr->num_other_sids) { - - if (UNMARSHALLING(ps)) { - usr->other_sids = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(DOM_SID2)*usr->num_other_sids); - if (usr->other_sids == NULL) - return False; - } - - if(!prs_uint32("num_other_groups", ps, depth, &usr->num_other_groups)) - return False; - - if (UNMARSHALLING(ps) && usr->num_other_groups > 0) { - usr->other_gids = (DOM_GID *)prs_alloc_mem(ps, sizeof(DOM_GID)*usr->num_other_groups); - if (usr->other_gids == NULL) - return False; - } - - for (i = 0; i < usr->num_other_groups; i++) { - if(!smb_io_gid("", &usr->other_gids[i], ps, depth)) /* other GIDs */ - return False; - } - for (i = 0; i < usr->num_other_sids; i++) { - if(!smb_io_dom_sid2("", &usr->other_sids[i], ps, depth)) /* other domain SIDs */ - return False; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_sam_logon(const char *desc, NET_Q_SAM_LOGON *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_sam_logon"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) - return False; - - if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_sam_logon"); - depth++; - - if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */ - return False; - if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */ - return False; - - if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value)) - return False; - if(!prs_align(ps)) - return False; - -#if 1 /* W2k always needs this - even for bad passwd. JRA */ - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value)) - return False; -#else - if (r_l->switch_value != 0) { - if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value)) - return False; - } -#endif - - if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */ - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_q_sam_logoff(const char *desc, NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth) -{ - if (q_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_q_sam_logoff"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) /* domain SID */ - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth) -{ - if (r_l == NULL) - return False; - - prs_debug(ps, depth, desc, "net_io_r_sam_logoff"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */ - return False; - if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */ - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_l->status)) - return False; - - return True; -} - -/******************************************************************* -makes a NET_Q_SAM_SYNC structure. -********************************************************************/ -BOOL init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name, - const char *cli_name, DOM_CRED *cli_creds, - DOM_CRED *ret_creds, uint32 database_id, - uint32 next_rid) -{ - DEBUG(5, ("init_q_sam_sync\n")); - - init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1); - init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1); - - if (cli_creds) - memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); - - if (cli_creds) - memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds)); - else - memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds)); - - q_s->database_id = database_id; - q_s->restart_state = 0; - q_s->sync_context = next_rid; - q_s->max_size = 0xffff; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_sam_sync"); - depth++; - - if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth)) - return False; - if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth)) - return False; - - if (!smb_io_cred("", &q_s->cli_creds, ps, depth)) - return False; - if (!smb_io_cred("", &q_s->ret_creds, ps, depth)) - return False; - - if (!prs_uint32("database_id ", ps, depth, &q_s->database_id)) - return False; - if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state)) - return False; - if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context)) - return False; - - if (!prs_uint32("max_size", ps, depth, &q_s->max_size)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_hdr"); - depth++; - - if (!prs_uint16("type", ps, depth, &delta->type)) - return False; - if (!prs_uint16("type2", ps, depth, &delta->type2)) - return False; - if (!prs_uint32("target_rid", ps, depth, &delta->target_rid)) - return False; - - if (!prs_uint32("type3", ps, depth, &delta->type3)) - return False; - - /* Not sure why we need this but it seems to be necessary to get - sam deltas working. */ - - if (delta->type != 0x16) { - if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_stamp"); - depth++; - - if (!prs_uint32("seqnum", ps, depth, &info->seqnum)) - return False; - if (!prs_uint32("dom_mod_count_ptr", ps, depth, - &info->dom_mod_count_ptr)) - return False; - - if (info->dom_mod_count_ptr) { - if (!prs_uint64("dom_mod_count", ps, depth, - &info->dom_mod_count)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_domain_info"); - depth++; - - if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth)) - return False; - - if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff)) - return False; - if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len)) - return False; - if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len)) - return False; - if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age)) - return False; - if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count)) - return False; - if (!smb_io_time("creation_time", &info->creation_time, ps, depth)) - return False; - - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_unknown", &info->hdr_unknown, ps, depth)) - return False; - - if (prs_offset(ps) + 40 > prs_data_size(ps)) - return False; - prs_set_offset(ps, prs_offset(ps) + 40); - - if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name, - info->hdr_dom_name.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info, - info->hdr_oem_info.buffer, ps, depth)) - return False; - - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("buf_unknown", &info->buf_unknown, - info->hdr_unknown.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_group_info"); - depth++; - - if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth)) - return False; - if (!smb_io_gid("gid", &info->gid, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - if (prs_offset(ps) + 48 > prs_data_size(ps)) - return False; - prs_set_offset(ps, prs_offset(ps) + 48); - - if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name, - info->hdr_grp_name.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc, - info->hdr_grp_desc.buffer, ps, depth)) - return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_passwd_info"); - depth++; - - if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0)) - return False; - - if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth)) - return False; - if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16)) - return False; - - if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth)) - return False; - if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16)) - return False; - - if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth)) - return False; - if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -makes a SAM_ACCOUNT_INFO structure. -********************************************************************/ -BOOL make_sam_account_info(SAM_ACCOUNT_INFO * info, - const UNISTR2 *user_name, - const UNISTR2 *full_name, - uint32 user_rid, uint32 group_rid, - const UNISTR2 *home_dir, - const UNISTR2 *dir_drive, - const UNISTR2 *log_scr, - const UNISTR2 *desc, - uint32 acb_info, - const UNISTR2 *prof_path, - const UNISTR2 *wkstas, - const UNISTR2 *unk_str, const UNISTR2 *mung_dial) -{ - int len_user_name = user_name != NULL ? user_name->uni_str_len : 0; - int len_full_name = full_name != NULL ? full_name->uni_str_len : 0; - int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0; - int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0; - int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0; - int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0; - int len_description = desc != NULL ? desc->uni_str_len : 0; - int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0; - int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0; - int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0; - - DEBUG(5, ("make_sam_account_info\n")); - - make_uni_hdr(&info->hdr_acct_name, len_user_name); - make_uni_hdr(&info->hdr_full_name, len_full_name); - make_uni_hdr(&info->hdr_home_dir, len_home_dir); - make_uni_hdr(&info->hdr_dir_drive, len_dir_drive); - make_uni_hdr(&info->hdr_logon_script, len_logon_script); - make_uni_hdr(&info->hdr_profile, len_profile_path); - make_uni_hdr(&info->hdr_acct_desc, len_description); - make_uni_hdr(&info->hdr_workstations, len_workstations); - make_uni_hdr(&info->hdr_comment, len_unknown_str); - make_uni_hdr(&info->hdr_parameters, len_munged_dial); - - /* not present */ - make_bufhdr2(&info->hdr_sec_desc, 0, 0, 0); - - info->user_rid = user_rid; - info->group_rid = group_rid; - - init_nt_time(&info->logon_time); - init_nt_time(&info->logoff_time); - init_nt_time(&info->pwd_last_set_time); - init_nt_time(&info->acct_expiry_time); - - info->logon_divs = 0xA8; - info->ptr_logon_hrs = 0; /* Don't care right now */ - - info->bad_pwd_count = 0; - info->logon_count = 0; - info->acb_info = acb_info; - info->nt_pwd_present = 0; - info->lm_pwd_present = 0; - info->pwd_expired = 0; - info->country = 0; - info->codepage = 0; - - info->unknown1 = 0x4EC; - info->unknown2 = 0; - - copy_unistr2(&info->uni_acct_name, user_name); - copy_unistr2(&info->uni_full_name, full_name); - copy_unistr2(&info->uni_home_dir, home_dir); - copy_unistr2(&info->uni_dir_drive, dir_drive); - copy_unistr2(&info->uni_logon_script, log_scr); - copy_unistr2(&info->uni_profile, prof_path); - copy_unistr2(&info->uni_acct_desc, desc); - copy_unistr2(&info->uni_workstations, wkstas); - copy_unistr2(&info->uni_comment, unk_str); - copy_unistr2(&info->uni_parameters, mung_dial); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_account_info(const char *desc, uint8 sess_key[16], - SAM_ACCOUNT_INFO * info, prs_struct *ps, - int depth) -{ - BUFHDR2 hdr_priv_data; - uint32 i; - - prs_debug(ps, depth, desc, "net_io_sam_account_info"); - depth++; - - if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth)) - return False; - - if (!prs_uint32("user_rid ", ps, depth, &info->user_rid)) - return False; - if (!prs_uint32("group_rid", ps, depth, &info->group_rid)) - return False; - - if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps, - depth)) - return False; - - if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps, - depth)) - return False; - - if (!smb_io_time("logon_time", &info->logon_time, ps, depth)) - return False; - if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth)) - return False; - - if (!prs_uint32("logon_divs ", ps, depth, &info->logon_divs)) - return False; - if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs)) - return False; - - if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count)) - return False; - if (!prs_uint16("logon_count", ps, depth, &info->logon_count)) - return False; - if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps, - depth)) - return False; - if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps, - depth)) - return False; - - if (!prs_uint32("acb_info", ps, depth, &info->acb_info)) - return False; - if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16)) - return False; - if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16)) - return False; - if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present)) - return False; - if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present)) - return False; - if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired)) - return False; - - if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps, - depth)) - return False; - if (!prs_uint16("country", ps, depth, &info->country)) - return False; - if (!prs_uint16("codepage", ps, depth, &info->codepage)) - return False; - - if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth)) - return False; - - for (i = 0; i < 3; i++) - { - if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i], - ps, depth)) - return False; - } - - for (i = 0; i < 4; i++) - { - if (!prs_uint32("dw_reserved", ps, depth, - &info->dw_reserved[i])) - return False; - } - - if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name, - info->hdr_acct_name.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_full_name", &info->uni_full_name, - info->hdr_full_name.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir, - info->hdr_home_dir.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive, - info->hdr_dir_drive.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script, - info->hdr_logon_script.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc, - info->hdr_acct_desc.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_workstations", &info->uni_workstations, - info->hdr_workstations.buffer, ps, depth)) - return False; - prs_align(ps); - - if (!prs_uint32("unknown1", ps, depth, &info->unknown1)) - return False; - if (!prs_uint32("unknown2", ps, depth, &info->unknown2)) - return False; - - if (!smb_io_buffer4("buf_logon_hrs", &info->buf_logon_hrs, - info->ptr_logon_hrs, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_comment", &info->uni_comment, - info->hdr_comment.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_parameters", &info->uni_parameters, - info->hdr_parameters.buffer, ps, depth)) - return False; - prs_align(ps); - if (hdr_priv_data.buffer != 0) - { - int old_offset = 0; - uint32 len = 0x44; - if (!prs_uint32("pwd_len", ps, depth, &len)) - return False; - old_offset = prs_offset(ps); - if (len == 0x44) - { - if (ps->io) - { - /* reading */ - if (!prs_hash1(ps, prs_offset(ps), sess_key)) - return False; - } - if (!net_io_sam_passwd_info("pass", &info->pass, - ps, depth)) - return False; - - if (!ps->io) - { - /* writing */ - if (!prs_hash1(ps, old_offset, sess_key)) - return False; - } - } - if (old_offset + len > prs_data_size(ps)) - return False; - prs_set_offset(ps, old_offset + len); - } - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - return False; - prs_align(ps); - if (!smb_io_unistr2("uni_profile", &info->uni_profile, - info->hdr_profile.buffer, ps, depth)) - return False; - - prs_align(ps); - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * info, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - prs_debug(ps, depth, desc, "net_io_sam_group_mem_info"); - depth++; - - prs_align(ps); - if (!prs_uint32("ptr_rids ", ps, depth, &info->ptr_rids)) - return False; - if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs)) - return False; - if (!prs_uint32("num_members", ps, depth, &info->num_members)) - return False; - - if (prs_offset(ps) + 16 > prs_data_size(ps)) - return False; - prs_set_offset(ps, prs_offset(ps) + 16); - - if (info->ptr_rids != 0) - { - if (!prs_uint32("num_members2", ps, depth, - &info->num_members2)) - return False; - - if (info->num_members2 != info->num_members) - { - /* RPC fault */ - return False; - } - - info->rids = talloc(ps->mem_ctx, sizeof(uint32) * - info->num_members2); - - if (info->rids == NULL) { - DEBUG(0, ("out of memory allocating %d rids\n", - info->num_members2)); - return False; - } - - for (i = 0; i < info->num_members2; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->rids[i])) - return False; - } - } - - if (info->ptr_attribs != 0) - { - if (!prs_uint32("num_members3", ps, depth, - &info->num_members3)) - return False; - if (info->num_members3 != info->num_members) - { - /* RPC fault */ - return False; - } - - info->attribs = talloc(ps->mem_ctx, sizeof(uint32) * - info->num_members3); - - if (info->attribs == NULL) { - DEBUG(0, ("out of memory allocating %d attribs\n", - info->num_members3)); - return False; - } - - for (i = 0; i < info->num_members3; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->attribs[i])) - return False; - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_alias_info(const char *desc, SAM_ALIAS_INFO * info, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_alias_info"); - depth++; - - if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth)) - return False; - if (!prs_uint32("als_rid", ps, depth, &info->als_rid)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth)) - return False; - - if (prs_offset(ps) + 40 > prs_data_size(ps)) - return False; - prs_set_offset(ps, prs_offset(ps) + 40); - - if (!smb_io_unistr2("uni_als_name", &info->uni_als_name, - info->hdr_als_name.buffer, ps, depth)) - return False; - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - return False; - if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc, - info->hdr_als_name.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * info, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info"); - depth++; - - prs_align(ps); - if (!prs_uint32("num_members", ps, depth, &info->num_members)) - return False; - if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members)) - return False; - - if (info->ptr_members != 0) - { - if (prs_offset(ps) + 16 > prs_data_size(ps)) - return False; - prs_set_offset(ps, prs_offset(ps) + 16); - - if (!prs_uint32("num_sids", ps, depth, &info->num_sids)) - return False; - if (info->num_sids != info->num_members) - { - /* RPC fault */ - return False; - } - - info->ptr_sids = talloc(ps->mem_ctx, sizeof(uint32) * - info->num_sids); - - if (info->ptr_sids == NULL) { - DEBUG(0, ("out of memory allocating %d ptr_sids\n", - info->num_sids)); - return False; - } - - for (i = 0; i < info->num_sids; i++) - { - slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i); - if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i])) - return False; - } - - info->sids = talloc(ps->mem_ctx, sizeof(DOM_SID2) * - info->num_sids); - - if (info->sids == NULL) { - DEBUG(0, ("error allocating %d sids\n", - info->num_sids)); - return False; - } - - for (i = 0; i < info->num_sids; i++) - { - if (info->ptr_sids[i] != 0) - { - slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]", - i); - if (!smb_io_dom_sid2(tmp, &info->sids[i], - ps, depth)) - return False; - } - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_policy_info(const char *desc, SAM_DELTA_POLICY *info, - prs_struct *ps, int depth) -{ - int i; - prs_debug(ps, depth, desc, "net_io_sam_policy_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("max_log_size", ps, depth, &info->max_log_size)) - return False; - if (!prs_uint64("audit_retention_period", ps, depth, - &info->audit_retention_period)) - return False; - if (!prs_uint32("auditing_mode", ps, depth, &info->auditing_mode)) - return False; - if (!prs_uint32("num_events", ps, depth, &info->num_events)) - return False; - if (!prs_uint32("ptr_events", ps, depth, &info->ptr_events)) - return False; - - if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth)) - return False; - - if (!prs_uint32("sid_ptr", ps, depth, &info->sid_ptr)) - return False; - - if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit)) - return False; - if (!prs_uint32("non_paged_pool_limit", ps, depth, - &info->non_paged_pool_limit)) - return False; - if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size)) - return False; - if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size)) - return False; - if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit)) - return False; - if (!prs_uint64("time_limit", ps, depth, &info->time_limit)) - return False; - if (!smb_io_time("modify_time", &info->modify_time, ps, depth)) - return False; - if (!smb_io_time("create_time", &info->create_time, ps, depth)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - for (i=0; i<4; i++) { - UNIHDR dummy; - if (!smb_io_unihdr("dummy", &dummy, ps, depth)) - return False; - } - - for (i=0; i<4; i++) { - uint32 reserved; - if (!prs_uint32("reserved", ps, depth, &reserved)) - return False; - } - - if (!prs_uint32("num_event_audit_options", ps, depth, - &info->num_event_audit_options)) - return False; - - for (i=0; i<info->num_event_audit_options; i++) - if (!prs_uint32("event_audit_option", ps, depth, - &info->event_audit_option)) - return False; - - if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth)) - return False; - - if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth)) - return False; - - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_trustdoms_info(const char *desc, SAM_DELTA_TRUSTDOMS *info, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_sam_trustdoms_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_size", ps, depth, &info->buf_size)) - return False; - - if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth)) - return False; - - if(!smb_io_dom_sid2("sid", &info->sid, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth)) - return False; - - if(!prs_uint32("unknown0", ps, depth, &info->unknown0)) - return False; - if(!prs_uint32("unknown1", ps, depth, &info->unknown1)) - return False; - if(!prs_uint32("unknown2", ps, depth, &info->unknown2)) - return False; - - if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2)) - return False; - if(!prs_uint32("ptr", ps, depth, &info->ptr)) - return False; - - for (i=0; i<12; i++) - if(!prs_uint32("unknown3", ps, depth, &info->unknown3)) - return False; - - if (!smb_io_unistr2("domain", &info->domain, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_secret_info(const char *desc, SAM_DELTA_SECRET *info, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_sam_secret_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("buf_size", ps, depth, &info->buf_size)) - return False; - - if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth)) - return False; - - if (!smb_io_unistr2("secret", &info->secret, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count1", ps, depth, &info->count1)) - return False; - if(!prs_uint32("count2", ps, depth, &info->count2)) - return False; - if(!prs_uint32("ptr", ps, depth, &info->ptr)) - return False; - - - if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */ - return False; - if(!prs_uint32("count3", ps, depth, &info->count3)) - return False; - if(!prs_uint32("count4", ps, depth, &info->count4)) - return False; - if(!prs_uint32("ptr2", ps, depth, &info->ptr2)) - return False; - if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */ - return False; - if(!prs_uint32("unknow1", ps, depth, &info->unknow1)) - return False; - - - if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2)) - return False; - if(!prs_uint32("ptr3", ps, depth, &info->ptr3)) - return False; - for(i=0; i<12; i++) - if(!prs_uint32("unknow2", ps, depth, &info->unknow2)) - return False; - - if(!prs_uint32("chal_len", ps, depth, &info->chal_len)) - return False; - if(!prs_uint32("reserved1", ps, depth, &info->reserved1)) - return False; - if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2)) - return False; - - if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2)) - return False; - - if(!prs_uint32("key_len", ps, depth, &info->key_len)) - return False; - if(!prs_uint32("reserved2", ps, depth, &info->reserved2)) - return False; - if(!prs_uint32("key_len2", ps, depth, &info->key_len2)) - return False; - - if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2)) - return False; - - - if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3)) - return False; - - if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth)) - return False; - - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_privs_info(const char *desc, SAM_DELTA_PRIVS *info, - prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_sam_privs_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_dom_sid2("sid", &info->sid, ps, depth)) - return False; - - if(!prs_uint32("priv_count", ps, depth, &info->priv_count)) - return False; - if(!prs_uint32("priv_control", ps, depth, &info->priv_control)) - return False; - - if(!prs_uint32("priv_attr_ptr", ps, depth, &info->priv_attr_ptr)) - return False; - if(!prs_uint32("priv_name_ptr", ps, depth, &info->priv_name_ptr)) - return False; - - if (!prs_uint32("paged_pool_limit", ps, depth, &info->paged_pool_limit)) - return False; - if (!prs_uint32("non_paged_pool_limit", ps, depth, - &info->non_paged_pool_limit)) - return False; - if (!prs_uint32("min_workset_size", ps, depth, &info->min_workset_size)) - return False; - if (!prs_uint32("max_workset_size", ps, depth, &info->max_workset_size)) - return False; - if (!prs_uint32("page_file_limit", ps, depth, &info->page_file_limit)) - return False; - if (!prs_uint64("time_limit", ps, depth, &info->time_limit)) - return False; - if (!prs_uint32("system_flags", ps, depth, &info->system_flags)) - return False; - if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth)) - return False; - - for (i=0; i<4; i++) { - UNIHDR dummy; - if (!smb_io_unihdr("dummy", &dummy, ps, depth)) - return False; - } - - for (i=0; i<4; i++) { - uint32 reserved; - if (!prs_uint32("reserved", ps, depth, &reserved)) - return False; - } - - if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count)) - return False; - - info->attributes = talloc(ps->mem_ctx, sizeof(uint32) * info->attribute_count); - - for (i=0; i<info->attribute_count; i++) - if(!prs_uint32("attributes", ps, depth, &info->attributes[i])) - return False; - - if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count)) - return False; - - info->hdr_privslist = talloc(ps->mem_ctx, sizeof(UNIHDR) * info->privlist_count); - info->uni_privslist = talloc(ps->mem_ctx, sizeof(UNISTR2) * info->privlist_count); - - for (i=0; i<info->privlist_count; i++) - if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth)) - return False; - - for (i=0; i<info->privlist_count; i++) - if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth)) - return False; - - if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc, - info->hdr_sec_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -static BOOL net_io_sam_delta_ctr(const char *desc, uint8 sess_key[16], - SAM_DELTA_CTR * delta, uint16 type, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "net_io_sam_delta_ctr"); - depth++; - - switch (type) { - /* Seen in sam deltas */ - case SAM_DELTA_MODIFIED_COUNT: - if (!net_io_sam_delta_mod_count("", &delta->mod_count, ps, depth)) - return False; - break; - - case SAM_DELTA_DOMAIN_INFO: - if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth)) - return False; - break; - - case SAM_DELTA_GROUP_INFO: - if (!net_io_sam_group_info("", &delta->group_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ACCOUNT_INFO: - if (!net_io_sam_account_info("", sess_key, &delta->account_info, ps, depth)) - return False; - break; - - case SAM_DELTA_GROUP_MEM: - if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ALIAS_INFO: - if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth)) - return False; - break; - - case SAM_DELTA_POLICY_INFO: - if (!net_io_sam_policy_info("", &delta->policy_info, ps, depth)) - return False; - break; - - case SAM_DELTA_ALIAS_MEM: - if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth)) - return False; - break; - - case SAM_DELTA_PRIVS_INFO: - if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth)) - return False; - break; - - case SAM_DELTA_TRUST_DOMS: - if (!net_io_sam_trustdoms_info("", &delta->trustdoms_info, ps, depth)) - return False; - break; - - case SAM_DELTA_SECRET_INFO: - if (!net_io_sam_secret_info("", &delta->secret_info, ps, depth)) - return False; - break; - - /* These guys are not implemented yet */ - - case SAM_DELTA_RENAME_GROUP: - case SAM_DELTA_RENAME_USER: - case SAM_DELTA_RENAME_ALIAS: - case SAM_DELTA_DELETE_GROUP: - case SAM_DELTA_DELETE_USER: - default: - DEBUG(0, ("Replication error: Unknown delta type 0x%x\n", type)); - break; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL net_io_r_sam_sync(const char *desc, uint8 sess_key[16], - NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth) -{ - uint32 i; - - prs_debug(ps, depth, desc, "net_io_r_sam_sync"); - depth++; - - if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth)) - return False; - if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context)) - return False; - - if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas)) - return False; - if (r_s->ptr_deltas != 0) - { - if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas)) - return False; - if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2)) - return False; - if (r_s->ptr_deltas2 != 0) - { - if (!prs_uint32("num_deltas2", ps, depth, - &r_s->num_deltas2)) - return False; - - if (r_s->num_deltas2 != r_s->num_deltas) - { - /* RPC fault */ - return False; - } - - if (r_s->num_deltas2 > 0) { - r_s->hdr_deltas = (SAM_DELTA_HDR *) - talloc(ps->mem_ctx, r_s->num_deltas2 * - sizeof(SAM_DELTA_HDR)); - - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas2)); - return False; - } - } - - for (i = 0; i < r_s->num_deltas2; i++) - { - if (!net_io_sam_delta_hdr("", - &r_s->hdr_deltas[i], - ps, depth)) - return False; - } - - if (r_s->num_deltas2 > 0) { - r_s->deltas = (SAM_DELTA_CTR *) - talloc(ps->mem_ctx, r_s->num_deltas2 * - sizeof(SAM_DELTA_CTR)); - - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas2)); - return False; - } - } - - for (i = 0; i < r_s->num_deltas2; i++) - { - if (!net_io_sam_delta_ctr( - "", sess_key, &r_s->deltas[i], - r_s->hdr_deltas[i].type3, - ps, depth)) { - DEBUG(0, ("hmm, failed on i=%d\n", i)); - return False; - } - } - } - } - - prs_align(ps); - if (!prs_ntstatus("status", ps, depth, &(r_s->status))) - return False; - - return True; -} - -/******************************************************************* -makes a NET_Q_SAM_DELTAS structure. -********************************************************************/ -BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name, - const char *cli_name, DOM_CRED *cli_creds, - uint32 database_id, UINT64_S dom_mod_count) -{ - DEBUG(5, ("init_net_q_sam_deltas\n")); - - init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1); - init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1); - - memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); - memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds)); - - q_s->database_id = database_id; - q_s->dom_mod_count.low = dom_mod_count.low; - q_s->dom_mod_count.high = dom_mod_count.high; - q_s->max_size = 0xffff; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL net_io_q_sam_deltas(const char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps, - int depth) -{ - prs_debug(ps, depth, desc, "net_io_q_sam_deltas"); - depth++; - - if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth)) - return False; - if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth)) - return False; - - if (!smb_io_cred("", &q_s->cli_creds, ps, depth)) - return False; - if (!smb_io_cred("", &q_s->ret_creds, ps, depth)) - return False; - - if (!prs_uint32("database_id ", ps, depth, &q_s->database_id)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count)) - return False; - if (!prs_uint32("max_size", ps, depth, &q_s->max_size)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL net_io_r_sam_deltas(const char *desc, uint8 sess_key[16], - NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "net_io_r_sam_deltas"); - depth++; - - if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth)) - return False; - if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count)) - return False; - - if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas)) - return False; - if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas)) - return False; - if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2)) - return False; - - if (r_s->num_deltas2 != 0) - { - if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2)) - return False; - - if (r_s->ptr_deltas != 0) - { - if (r_s->num_deltas > 0) { - r_s->hdr_deltas = (SAM_DELTA_HDR *) - talloc(ps->mem_ctx, r_s->num_deltas * - sizeof(SAM_DELTA_HDR)); - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas)); - return False; - } - } - - for (i = 0; i < r_s->num_deltas; i++) - { - net_io_sam_delta_hdr("", &r_s->hdr_deltas[i], - ps, depth); - } - - if (r_s->num_deltas > 0) { - r_s->deltas = (SAM_DELTA_CTR *) - talloc(ps->mem_ctx, r_s->num_deltas * - sizeof(SAM_DELTA_CTR)); - - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas)); - return False; - } - } - - for (i = 0; i < r_s->num_deltas; i++) - { - if (!net_io_sam_delta_ctr( - "", sess_key, - &r_s->deltas[i], - r_s->hdr_deltas[i].type2, - ps, depth)) - - return False; - } - } - } - - prs_align(ps); - if (!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} diff --git a/source4/rpc_parse/parse_prs.c b/source4/rpc_parse/parse_prs.c deleted file mode 100644 index 46879de681..0000000000 --- a/source4/rpc_parse/parse_prs.c +++ /dev/null @@ -1,1329 +0,0 @@ -/* - Unix SMB/CIFS implementation. - Samba memory buffer functions - Copyright (C) Andrew Tridgell 1992-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - Copyright (C) Jeremy Allison 1999. - - 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 - -/** - * Dump a prs to a file: from the current location through to the end. - **/ -void prs_dump(char *name, int v, prs_struct *ps) -{ - prs_dump_region(name, v, ps, ps->data_offset, ps->buffer_size); -} - - -/** - * Dump from the start of the prs to the current location. - **/ -void prs_dump_before(char *name, int v, prs_struct *ps) -{ - prs_dump_region(name, v, ps, 0, ps->data_offset); -} - - -/** - * Dump everything from the start of the prs up to the current location. - **/ -void prs_dump_region(char *name, int v, prs_struct *ps, - int from_off, int to_off) -{ - int fd, i; - pstring fname; - if (DEBUGLEVEL < 50) return; - for (i=1;i<100;i++) { - if (v != -1) { - slprintf(fname,sizeof(fname)-1, "/tmp/%s_%d.%d.prs", name, v, i); - } else { - slprintf(fname,sizeof(fname)-1, "/tmp/%s.%d.prs", name, i); - } - fd = open(fname, O_WRONLY|O_CREAT|O_EXCL, 0644); - if (fd != -1 || errno != EEXIST) break; - } - if (fd != -1) { - write(fd, ps->data_p + from_off, to_off - from_off); - close(fd); - DEBUG(0,("created %s\n", fname)); - } -} - - - -/******************************************************************* - debug output for parsing info. - - XXXX side-effect of this function is to increase the debug depth XXXX - - ********************************************************************/ -void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name) -{ - DEBUG(5+depth, ("%s%06x %s %s\n", DEBUGTAB(depth), ps->data_offset, fn_name, desc)); -} - - -/** - * Initialise an expandable parse structure. - * - * @param size Initial buffer size. If >0, a new buffer will be - * created with malloc(). - * - * @return False if allocation fails, otherwise True. - **/ -BOOL prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, BOOL io) -{ - ZERO_STRUCTP(ps); - ps->io = io; - ps->bigendian_data = RPC_LITTLE_ENDIAN; - ps->align = RPC_PARSE_ALIGN; - ps->is_dynamic = False; - ps->data_offset = 0; - ps->buffer_size = 0; - ps->data_p = NULL; - ps->mem_ctx = ctx; - - if (size != 0) { - ps->buffer_size = size; - if((ps->data_p = (char *)malloc((size_t)size)) == NULL) { - DEBUG(0,("prs_init: malloc fail for %u bytes.\n", (unsigned int)size)); - return False; - } - memset(ps->data_p, '\0', (size_t)size); - ps->is_dynamic = True; /* We own this memory. */ - } - - return True; -} - -/******************************************************************* - Delete the memory in a parse structure - if we own it. - ********************************************************************/ - -void prs_mem_free(prs_struct *ps) -{ - if(ps->is_dynamic) - SAFE_FREE(ps->data_p); - ps->is_dynamic = False; - ps->buffer_size = 0; - ps->data_offset = 0; -} - -/******************************************************************* - Clear the memory in a parse structure. - ********************************************************************/ - -void prs_mem_clear(prs_struct *ps) -{ - if (ps->buffer_size) - memset(ps->data_p, '\0', (size_t)ps->buffer_size); -} - -/******************************************************************* - Allocate memory when unmarshalling... Always zero clears. - ********************************************************************/ - -char *prs_alloc_mem(prs_struct *ps, size_t size) -{ - char *ret = NULL; - - if (size) { - ret = talloc(ps->mem_ctx, size); - if (ret) - memset(ret, '\0', size); - } - return ret; -} - -/******************************************************************* - Return the current talloc context we're using. - ********************************************************************/ - -TALLOC_CTX *prs_get_mem_context(prs_struct *ps) -{ - return ps->mem_ctx; -} - -/******************************************************************* - Hand some already allocated memory to a prs_struct. - ********************************************************************/ - -void prs_give_memory(prs_struct *ps, char *buf, uint32 size, BOOL is_dynamic) -{ - ps->is_dynamic = is_dynamic; - ps->data_p = buf; - ps->buffer_size = size; -} - -/******************************************************************* - Take some memory back from a prs_struct. - ********************************************************************/ - -char *prs_take_memory(prs_struct *ps, uint32 *psize) -{ - char *ret = ps->data_p; - if(psize) - *psize = ps->buffer_size; - ps->is_dynamic = False; - prs_mem_free(ps); - return ret; -} - -/******************************************************************* - Set a prs_struct to exactly a given size. Will grow or tuncate if neccessary. - ********************************************************************/ - -BOOL prs_set_buffer_size(prs_struct *ps, uint32 newsize) -{ - if (newsize > ps->buffer_size) - return prs_force_grow(ps, newsize - ps->buffer_size); - - if (newsize < ps->buffer_size) { - char *new_data_p = Realloc(ps->data_p, newsize); - /* if newsize is zero, Realloc acts like free() & returns NULL*/ - if (new_data_p == NULL && newsize != 0) { - DEBUG(0,("prs_set_buffer_size: Realloc failure for size %u.\n", - (unsigned int)newsize)); - DEBUG(0,("prs_set_buffer_size: Reason %s\n",strerror(errno))); - return False; - } - ps->data_p = new_data_p; - ps->buffer_size = newsize; - } - - return True; -} - -/******************************************************************* - Attempt, if needed, to grow a data buffer. - Also depends on the data stream mode (io). - ********************************************************************/ - -BOOL prs_grow(prs_struct *ps, uint32 extra_space) -{ - uint32 new_size; - char *new_data; - - ps->grow_size = MAX(ps->grow_size, ps->data_offset + extra_space); - - if(ps->data_offset + extra_space <= ps->buffer_size) - return True; - - /* - * We cannot grow the buffer if we're not reading - * into the prs_struct, or if we don't own the memory. - */ - - if(UNMARSHALLING(ps) || !ps->is_dynamic) { - DEBUG(0,("prs_grow: Buffer overflow - unable to expand buffer by %u bytes.\n", - (unsigned int)extra_space)); - return False; - } - - /* - * Decide how much extra space we really need. - */ - - extra_space -= (ps->buffer_size - ps->data_offset); - if(ps->buffer_size == 0) { - /* - * Ensure we have at least a PDU's length, or extra_space, whichever - * is greater. - */ - - new_size = MAX(MAX_PDU_FRAG_LEN,extra_space); - - if((new_data = malloc(new_size)) == NULL) { - DEBUG(0,("prs_grow: Malloc failure for size %u.\n", (unsigned int)new_size)); - return False; - } - memset(new_data, '\0', (size_t)new_size ); - } else { - /* - * If the current buffer size is bigger than the space needed, just - * double it, else add extra_space. - */ - new_size = MAX(ps->buffer_size*2, ps->buffer_size + extra_space); - - if ((new_data = Realloc(ps->data_p, new_size)) == NULL) { - DEBUG(0,("prs_grow: Realloc failure for size %u.\n", - (unsigned int)new_size)); - return False; - } - - memset(&new_data[ps->buffer_size], '\0', (size_t)(new_size - ps->buffer_size)); - } - ps->buffer_size = new_size; - ps->data_p = new_data; - - return True; -} - -/******************************************************************* - Attempt to force a data buffer to grow by len bytes. - This is only used when appending more data onto a prs_struct - when reading an rpc reply, before unmarshalling it. - ********************************************************************/ - -BOOL prs_force_grow(prs_struct *ps, uint32 extra_space) -{ - uint32 new_size = ps->buffer_size + extra_space; - char *new_data; - - if(!UNMARSHALLING(ps) || !ps->is_dynamic) { - DEBUG(0,("prs_force_grow: Buffer overflow - unable to expand buffer by %u bytes.\n", - (unsigned int)extra_space)); - return False; - } - - if((new_data = Realloc(ps->data_p, new_size)) == NULL) { - DEBUG(0,("prs_force_grow: Realloc failure for size %u.\n", - (unsigned int)new_size)); - return False; - } - - memset(&new_data[ps->buffer_size], '\0', (size_t)(new_size - ps->buffer_size)); - - ps->buffer_size = new_size; - ps->data_p = new_data; - - return True; -} - -/******************************************************************* - Get the data pointer (external interface). -********************************************************************/ - -char *prs_data_p(prs_struct *ps) -{ - return ps->data_p; -} - -/******************************************************************* - Get the current data size (external interface). - ********************************************************************/ - -uint32 prs_data_size(prs_struct *ps) -{ - return ps->buffer_size; -} - -/******************************************************************* - Fetch the current offset (external interface). - ********************************************************************/ - -uint32 prs_offset(prs_struct *ps) -{ - return ps->data_offset; -} - -/******************************************************************* - Set the current offset (external interface). - ********************************************************************/ - -BOOL prs_set_offset(prs_struct *ps, uint32 offset) -{ - if(offset <= ps->data_offset) { - ps->data_offset = offset; - return True; - } - - if(!prs_grow(ps, offset - ps->data_offset)) - return False; - - ps->data_offset = offset; - return True; -} - -/******************************************************************* - Append the data from one parse_struct into another. - ********************************************************************/ - -BOOL prs_append_prs_data(prs_struct *dst, prs_struct *src) -{ - if (prs_offset(src) == 0) - return True; - - if(!prs_grow(dst, prs_offset(src))) - return False; - - memcpy(&dst->data_p[dst->data_offset], src->data_p, (size_t)prs_offset(src)); - dst->data_offset += prs_offset(src); - - return True; -} - -/******************************************************************* - Append some data from one parse_struct into another. - ********************************************************************/ - -BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len) -{ - if (len == 0) - return True; - - if(!prs_grow(dst, len)) - return False; - - memcpy(&dst->data_p[dst->data_offset], src->data_p + start, (size_t)len); - dst->data_offset += len; - - return True; -} - -/******************************************************************* - Append the data from a buffer into a parse_struct. - ********************************************************************/ - -BOOL prs_copy_data_in(prs_struct *dst, char *src, uint32 len) -{ - if (len == 0) - return True; - - if(!prs_grow(dst, len)) - return False; - - memcpy(&dst->data_p[dst->data_offset], src, (size_t)len); - dst->data_offset += len; - - return True; -} - -/******************************************************************* - Copy some data from a parse_struct into a buffer. - ********************************************************************/ - -BOOL prs_copy_data_out(char *dst, prs_struct *src, uint32 len) -{ - if (len == 0) - return True; - - if(!prs_mem_get(src, len)) - return False; - - memcpy(dst, &src->data_p[src->data_offset], (size_t)len); - src->data_offset += len; - - return True; -} - -/******************************************************************* - Copy all the data from a parse_struct into a buffer. - ********************************************************************/ - -BOOL prs_copy_all_data_out(char *dst, prs_struct *src) -{ - uint32 len = prs_offset(src); - - if (!len) - return True; - - prs_set_offset(src, 0); - return prs_copy_data_out(dst, src, len); -} - -/******************************************************************* - Set the data as X-endian (external interface). - ********************************************************************/ - -void prs_set_endian_data(prs_struct *ps, BOOL endian) -{ - ps->bigendian_data = endian; -} - -/******************************************************************* - Align a the data_len to a multiple of align bytes - filling with - zeros. - ********************************************************************/ - -BOOL prs_align(prs_struct *ps) -{ - uint32 mod = ps->data_offset & (ps->align-1); - - if (ps->align != 0 && mod != 0) { - uint32 extra_space = (ps->align - mod); - if(!prs_grow(ps, extra_space)) - return False; - memset(&ps->data_p[ps->data_offset], '\0', (size_t)extra_space); - ps->data_offset += extra_space; - } - - return True; -} - -/****************************************************************** - Align on a 2 byte boundary - *****************************************************************/ - -BOOL prs_align_uint16(prs_struct *ps) -{ - BOOL ret; - uint8 old_align = ps->align; - - ps->align = 2; - ret = prs_align(ps); - ps->align = old_align; - - return ret; -} - -/****************************************************************** - Align on a 8 byte boundary - *****************************************************************/ - -BOOL prs_align_uint64(prs_struct *ps) -{ - BOOL ret; - uint8 old_align = ps->align; - - ps->align = 8; - ret = prs_align(ps); - ps->align = old_align; - - return ret; -} - -/******************************************************************* - Align only if required (for the unistr2 string mainly) - ********************************************************************/ - -BOOL prs_align_needed(prs_struct *ps, uint32 needed) -{ - if (needed==0) - return True; - else - return prs_align(ps); -} - -/******************************************************************* - Ensure we can read/write to a given offset. - ********************************************************************/ - -char *prs_mem_get(prs_struct *ps, uint32 extra_size) -{ - if(UNMARSHALLING(ps)) { - /* - * If reading, ensure that we can read the requested size item. - */ - if (ps->data_offset + extra_size > ps->buffer_size) { - DEBUG(0,("prs_mem_get: reading data of size %u would overrun buffer.\n", - (unsigned int)extra_size )); - return NULL; - } - } else { - /* - * Writing - grow the buffer if needed. - */ - if(!prs_grow(ps, extra_size)) - return NULL; - } - return &ps->data_p[ps->data_offset]; -} - -/******************************************************************* - Change the struct type. - ********************************************************************/ - -void prs_switch_type(prs_struct *ps, BOOL io) -{ - if ((ps->io ^ io) == True) - ps->io=io; -} - -/******************************************************************* - Force a prs_struct to be dynamic even when it's size is 0. - ********************************************************************/ - -void prs_force_dynamic(prs_struct *ps) -{ - ps->is_dynamic=True; -} - -/******************************************************************* - Stream a uint8. - ********************************************************************/ - -BOOL prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8) -{ - char *q = prs_mem_get(ps, 1); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) - *data8 = CVAL(q,0); - else - SCVAL(q,0,*data8); - - DEBUG(5,("%s%04x %s: %02x\n", DEBUGTAB(depth), ps->data_offset, name, *data8)); - - ps->data_offset += 1; - - return True; -} - -/******************************************************************* - Stream a uint16. - ********************************************************************/ - -BOOL prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16) -{ - char *q = prs_mem_get(ps, sizeof(uint16)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) - *data16 = RSVAL(q,0); - else - *data16 = SVAL(q,0); - } else { - if (ps->bigendian_data) - RSSVAL(q,0,*data16); - else - SSVAL(q,0,*data16); - } - - DEBUG(5,("%s%04x %s: %04x\n", DEBUGTAB(depth), ps->data_offset, name, *data16)); - - ps->data_offset += sizeof(uint16); - - return True; -} - -/******************************************************************* - Stream a uint32. - ********************************************************************/ - -BOOL prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32) -{ - char *q = prs_mem_get(ps, sizeof(uint32)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) - *data32 = RIVAL(q,0); - else - *data32 = IVAL(q,0); - } else { - if (ps->bigendian_data) - RSIVAL(q,0,*data32); - else - SIVAL(q,0,*data32); - } - - DEBUG(5,("%s%04x %s: %08x\n", DEBUGTAB(depth), ps->data_offset, name, *data32)); - - ps->data_offset += sizeof(uint32); - - return True; -} - -/******************************************************************* - Stream a NTSTATUS - ********************************************************************/ - -BOOL prs_ntstatus(const char *name, prs_struct *ps, int depth, NTSTATUS *status) -{ - char *q = prs_mem_get(ps, sizeof(uint32)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) - *status = NT_STATUS(RIVAL(q,0)); - else - *status = NT_STATUS(IVAL(q,0)); - } else { - if (ps->bigendian_data) - RSIVAL(q,0,NT_STATUS_V(*status)); - else - SIVAL(q,0,NT_STATUS_V(*status)); - } - - DEBUG(5,("%s%04x %s: %s\n", DEBUGTAB(depth), ps->data_offset, name, - nt_errstr(*status))); - - ps->data_offset += sizeof(uint32); - - return True; -} - -/******************************************************************* - Stream a WERROR - ********************************************************************/ - -BOOL prs_werror(const char *name, prs_struct *ps, int depth, WERROR *status) -{ - char *q = prs_mem_get(ps, sizeof(uint32)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) - *status = W_ERROR(RIVAL(q,0)); - else - *status = W_ERROR(IVAL(q,0)); - } else { - if (ps->bigendian_data) - RSIVAL(q,0,W_ERROR_V(*status)); - else - SIVAL(q,0,W_ERROR_V(*status)); - } - - ps->data_offset += sizeof(uint32); - - return True; -} - - -/****************************************************************** - Stream an array of uint8s. Length is number of uint8s. - ********************************************************************/ - -BOOL prs_uint8s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len) -{ - int i; - char *q = prs_mem_get(ps, len); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - for (i = 0; i < len; i++) - data8s[i] = CVAL(q,i); - } else { - for (i = 0; i < len; i++) - SCVAL(q, i, data8s[i]); - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset ,name)); - if (charmode) - print_asc(5, (unsigned char*)data8s, len); - else { - for (i = 0; i < len; i++) - DEBUG(5,("%02x ", data8s[i])); - } - DEBUG(5,("\n")); - - ps->data_offset += len; - - return True; -} - -/****************************************************************** - Stream an array of uint16s. Length is number of uint16s. - ********************************************************************/ - -BOOL prs_uint16s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len) -{ - int i; - char *q = prs_mem_get(ps, len * sizeof(uint16)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - data16s[i] = RSVAL(q, 2*i); - } else { - for (i = 0; i < len; i++) - data16s[i] = SVAL(q, 2*i); - } - } else { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - RSSVAL(q, 2*i, data16s[i]); - } else { - for (i = 0; i < len; i++) - SSVAL(q, 2*i, data16s[i]); - } - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - if (charmode) - print_asc(5, (unsigned char*)data16s, 2*len); - else { - for (i = 0; i < len; i++) - DEBUG(5,("%04x ", data16s[i])); - } - DEBUG(5,("\n")); - - ps->data_offset += (len * sizeof(uint16)); - - return True; -} - -/****************************************************************** - Start using a function for streaming unicode chars. If unmarshalling, - output must be little-endian, if marshalling, input must be little-endian. - ********************************************************************/ - -static void dbg_rw_punival(BOOL charmode, const char *name, int depth, prs_struct *ps, - char *in_buf, char *out_buf, int len) -{ - int i; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - SSVAL(out_buf,2*i,RSVAL(in_buf, 2*i)); - } else { - for (i = 0; i < len; i++) - SSVAL(out_buf, 2*i, SVAL(in_buf, 2*i)); - } - } else { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - RSSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); - } else { - for (i = 0; i < len; i++) - SSVAL(in_buf, 2*i, SVAL(out_buf,2*i)); - } - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - if (charmode) - print_asc(5, (unsigned char*)out_buf, 2*len); - else { - for (i = 0; i < len; i++) - DEBUG(5,("%04x ", out_buf[i])); - } - DEBUG(5,("\n")); -} - -/****************************************************************** - Stream a unistr. Always little endian. - ********************************************************************/ - -BOOL prs_uint16uni(BOOL charmode, const char *name, prs_struct *ps, int depth, uint16 *data16s, int len) -{ - char *q = prs_mem_get(ps, len * sizeof(uint16)); - if (q == NULL) - return False; - - dbg_rw_punival(charmode, name, depth, ps, q, (char *)data16s, len); - ps->data_offset += (len * sizeof(uint16)); - - return True; -} - -/****************************************************************** - Stream an array of uint32s. Length is number of uint32s. - ********************************************************************/ - -BOOL prs_uint32s(BOOL charmode, const char *name, prs_struct *ps, int depth, uint32 *data32s, int len) -{ - int i; - char *q = prs_mem_get(ps, len * sizeof(uint32)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - data32s[i] = RIVAL(q, 4*i); - } else { - for (i = 0; i < len; i++) - data32s[i] = IVAL(q, 4*i); - } - } else { - if (ps->bigendian_data) { - for (i = 0; i < len; i++) - RSIVAL(q, 4*i, data32s[i]); - } else { - for (i = 0; i < len; i++) - SIVAL(q, 4*i, data32s[i]); - } - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - if (charmode) - print_asc(5, (unsigned char*)data32s, 4*len); - else { - for (i = 0; i < len; i++) - DEBUG(5,("%08x ", data32s[i])); - } - DEBUG(5,("\n")); - - ps->data_offset += (len * sizeof(uint32)); - - return True; -} - -/****************************************************************** - Stream an array of unicode string, length/buffer specified separately, - in uint16 chars. The unicode string is already in little-endian format. - ********************************************************************/ - -BOOL prs_buffer5(BOOL charmode, const char *name, prs_struct *ps, int depth, BUFFER5 *str) -{ - char *p; - char *q = prs_mem_get(ps, str->buf_len * sizeof(uint16)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - str->buffer = (uint16 *)prs_alloc_mem(ps,str->buf_len * sizeof(uint16)); - if (str->buffer == NULL) - return False; - } - - /* If the string is empty, we don't have anything to stream */ - if (str->buf_len==0) - return True; - - p = (char *)str->buffer; - - dbg_rw_punival(charmode, name, depth, ps, q, p, str->buf_len); - - ps->data_offset += (str->buf_len * sizeof(uint16)); - - return True; -} - -/****************************************************************** - Stream a "not" unicode string, length/buffer specified separately, - in byte chars. String is in little-endian format. - ********************************************************************/ - -BOOL prs_buffer2(BOOL charmode, const char *name, prs_struct *ps, int depth, BUFFER2 *str) -{ - char *p; - char *q = prs_mem_get(ps, str->buf_len); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - if ( str->buf_len ) { - str->buffer = (uint16 *)prs_alloc_mem(ps,str->buf_len); - if ( str->buffer == NULL ) - return False; - } - } - - p = (char *)str->buffer; - - dbg_rw_punival(charmode, name, depth, ps, q, p, str->buf_len/2); - ps->data_offset += str->buf_len; - - return True; -} - -/****************************************************************** - Stream a string, length/buffer specified separately, - in uint8 chars. - ********************************************************************/ - -BOOL prs_string2(BOOL charmode, const char *name, prs_struct *ps, int depth, STRING2 *str) -{ - int i; - char *q = prs_mem_get(ps, str->str_max_len); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - str->buffer = (unsigned char *)prs_alloc_mem(ps,str->str_max_len); - if (str->buffer == NULL) - return False; - } - - if (UNMARSHALLING(ps)) { - for (i = 0; i < str->str_str_len; i++) - str->buffer[i] = CVAL(q,i); - } else { - for (i = 0; i < str->str_str_len; i++) - SCVAL(q, i, str->buffer[i]); - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - if (charmode) - print_asc(5, (unsigned char*)str->buffer, str->str_str_len); - else { - for (i = 0; i < str->str_str_len; i++) - DEBUG(5,("%02x ", str->buffer[i])); - } - DEBUG(5,("\n")); - - ps->data_offset += str->str_str_len; - - return True; -} - -/****************************************************************** - Stream a unicode string, length/buffer specified separately, - in uint16 chars. The unicode string is already in little-endian format. - ********************************************************************/ - -BOOL prs_unistr2(BOOL charmode, const char *name, prs_struct *ps, int depth, UNISTR2 *str) -{ - char *p; - char *q = prs_mem_get(ps, str->uni_str_len * sizeof(uint16)); - if (q == NULL) - return False; - - /* If the string is empty, we don't have anything to stream */ - if (str->uni_str_len==0) - return True; - - if (UNMARSHALLING(ps)) { - str->buffer = (uint16 *)prs_alloc_mem(ps,str->uni_max_len * sizeof(uint16)); - if (str->buffer == NULL) - return False; - } - - p = (char *)str->buffer; - - dbg_rw_punival(charmode, name, depth, ps, q, p, str->uni_str_len); - - ps->data_offset += (str->uni_str_len * sizeof(uint16)); - - return True; -} - -/****************************************************************** - Stream a unicode string, length/buffer specified separately, - in uint16 chars. The unicode string is already in little-endian format. - ********************************************************************/ - -BOOL prs_unistr3(BOOL charmode, const char *name, UNISTR3 *str, prs_struct *ps, int depth) -{ - char *p; - char *q = prs_mem_get(ps, str->uni_str_len * sizeof(uint16)); - if (q == NULL) - return False; - - if (UNMARSHALLING(ps)) { - str->str.buffer = (uint16 *)prs_alloc_mem(ps,str->uni_str_len * sizeof(uint16)); - if (str->str.buffer == NULL) - return False; - } - - p = (char *)str->str.buffer; - - dbg_rw_punival(charmode, name, depth, ps, q, p, str->uni_str_len); - ps->data_offset += (str->uni_str_len * sizeof(uint16)); - - return True; -} - -/******************************************************************* - Stream a unicode null-terminated string. As the string is already - in little-endian format then do it as a stream of bytes. - ********************************************************************/ - -BOOL prs_unistr(const char *name, prs_struct *ps, int depth, UNISTR *str) -{ - int len = 0; - unsigned char *p = (unsigned char *)str->buffer; - uint8 *start; - char *q; - uint32 max_len; - uint16* ptr; - - if (MARSHALLING(ps)) { - - for(len = 0; str->buffer[len] != 0; len++) - ; - - q = prs_mem_get(ps, (len+1)*2); - if (q == NULL) - return False; - - start = (uint8*)q; - - for(len = 0; str->buffer[len] != 0; len++) - { - if(ps->bigendian_data) - { - /* swap bytes - p is little endian, q is big endian. */ - q[0] = (char)p[1]; - q[1] = (char)p[0]; - p += 2; - q += 2; - } - else - { - q[0] = (char)p[0]; - q[1] = (char)p[1]; - p += 2; - q += 2; - } - } - - /* - * even if the string is 'empty' (only an \0 char) - * at this point the leading \0 hasn't been parsed. - * so parse it now - */ - - q[0] = 0; - q[1] = 0; - q += 2; - - len++; - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - print_asc(5, (unsigned char*)start, 2*len); - DEBUG(5, ("\n")); - } - else { /* unmarshalling */ - - uint32 alloc_len = 0; - q = ps->data_p + prs_offset(ps); - - /* - * Work out how much space we need and talloc it. - */ - max_len = (ps->buffer_size - ps->data_offset)/sizeof(uint16); - - /* the test of the value of *ptr helps to catch the circumstance - where we have an emtpty (non-existent) string in the buffer */ - for ( ptr = (uint16 *)q; *ptr && (alloc_len <= max_len); alloc_len++) - /* do nothing */ - ; - - /* should we allocate anything at all? */ - str->buffer = (uint16 *)prs_alloc_mem(ps,alloc_len * sizeof(uint16)); - if ((str->buffer == NULL) && (alloc_len > 0)) - return False; - - p = (unsigned char *)str->buffer; - - len = 0; - /* the (len < alloc_len) test is to prevent us from overwriting - memory that is not ours...if we get that far, we have a non-null - terminated string in the buffer and have messed up somewhere */ - while ((len < alloc_len) && (*(uint16 *)q != 0)) - { - if(ps->bigendian_data) - { - /* swap bytes - q is big endian, p is little endian. */ - p[0] = (unsigned char)q[1]; - p[1] = (unsigned char)q[0]; - p += 2; - q += 2; - } else { - - p[0] = (unsigned char)q[0]; - p[1] = (unsigned char)q[1]; - p += 2; - q += 2; - } - - len++; - } - if (len < alloc_len) - { - /* NULL terminate the UNISTR */ - str->buffer[len++] = '\0'; - } - - DEBUG(5,("%s%04x %s: ", DEBUGTAB(depth), ps->data_offset, name)); - print_asc(5, (unsigned char*)str->buffer, 2*len); - DEBUG(5, ("\n")); - } - - /* set the offset in the prs_struct; 'len' points to the - terminiating NULL in the UNISTR so we need to go one more - uint16 */ - ps->data_offset += (len)*2; - - return True; -} - - -/******************************************************************* - Stream a null-terminated string. len is strlen, and therefore does - not include the null-termination character. - ********************************************************************/ - -BOOL prs_string(const char *name, prs_struct *ps, int depth, char *str, int len, int max_buf_size) -{ - char *q; - int i; - - len = MIN(len, (max_buf_size-1)); - - q = prs_mem_get(ps, len+1); - if (q == NULL) - return False; - - for(i = 0; i < len; i++) { - if (UNMARSHALLING(ps)) - str[i] = q[i]; - else - q[i] = str[i]; - } - - /* The terminating null. */ - str[i] = '\0'; - - if (MARSHALLING(ps)) { - q[i] = '\0'; - } - - ps->data_offset += len+1; - - dump_data(5+depth, q, len); - - return True; -} - -/******************************************************************* - prs_uint16 wrapper. Call this and it sets up a pointer to where the - uint16 should be stored, or gets the size if reading. - ********************************************************************/ - -BOOL prs_uint16_pre(const char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *offset) -{ - *offset = ps->data_offset; - if (UNMARSHALLING(ps)) { - /* reading. */ - return prs_uint16(name, ps, depth, data16); - } else { - char *q = prs_mem_get(ps, sizeof(uint16)); - if(q ==NULL) - return False; - ps->data_offset += sizeof(uint16); - } - return True; -} - -/******************************************************************* - prs_uint16 wrapper. call this and it retrospectively stores the size. - does nothing on reading, as that is already handled by ...._pre() - ********************************************************************/ - -BOOL prs_uint16_post(const char *name, prs_struct *ps, int depth, uint16 *data16, - uint32 ptr_uint16, uint32 start_offset) -{ - if (MARSHALLING(ps)) { - /* - * Writing - temporarily move the offset pointer. - */ - uint16 data_size = ps->data_offset - start_offset; - uint32 old_offset = ps->data_offset; - - ps->data_offset = ptr_uint16; - if(!prs_uint16(name, ps, depth, &data_size)) { - ps->data_offset = old_offset; - return False; - } - ps->data_offset = old_offset; - } else { - ps->data_offset = start_offset + (uint32)(*data16); - } - return True; -} - -/******************************************************************* - prs_uint32 wrapper. Call this and it sets up a pointer to where the - uint32 should be stored, or gets the size if reading. - ********************************************************************/ - -BOOL prs_uint32_pre(const char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset) -{ - *offset = ps->data_offset; - if (UNMARSHALLING(ps) && (data32 != NULL)) { - /* reading. */ - return prs_uint32(name, ps, depth, data32); - } else { - ps->data_offset += sizeof(uint32); - } - return True; -} - -/******************************************************************* - prs_uint32 wrapper. call this and it retrospectively stores the size. - does nothing on reading, as that is already handled by ...._pre() - ********************************************************************/ - -BOOL prs_uint32_post(const char *name, prs_struct *ps, int depth, uint32 *data32, - uint32 ptr_uint32, uint32 data_size) -{ - if (MARSHALLING(ps)) { - /* - * Writing - temporarily move the offset pointer. - */ - uint32 old_offset = ps->data_offset; - ps->data_offset = ptr_uint32; - if(!prs_uint32(name, ps, depth, &data_size)) { - ps->data_offset = old_offset; - return False; - } - ps->data_offset = old_offset; - } - return True; -} - -/* useful function to store a structure in rpc wire format */ -int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) -{ - TDB_DATA kbuf, dbuf; - kbuf.dptr = keystr; - kbuf.dsize = strlen(keystr)+1; - dbuf.dptr = ps->data_p; - dbuf.dsize = prs_offset(ps); - return tdb_store(tdb, kbuf, dbuf, TDB_REPLACE); -} - -/* useful function to fetch a structure into rpc wire format */ -int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *mem_ctx) -{ - TDB_DATA kbuf, dbuf; - kbuf.dptr = keystr; - kbuf.dsize = strlen(keystr)+1; - - dbuf = tdb_fetch(tdb, kbuf); - if (!dbuf.dptr) - return -1; - - ZERO_STRUCTP(ps); - prs_init(ps, 0, mem_ctx, UNMARSHALL); - prs_give_memory(ps, dbuf.dptr, dbuf.dsize, True); - - return 0; -} - -/******************************************************************* - hash a stream. - ********************************************************************/ -BOOL prs_hash1(prs_struct *ps, uint32 offset, uint8 sess_key[16]) -{ - char *q; - - q = ps->data_p; - q = &q[offset]; - -#ifdef DEBUG_PASSWORD - DEBUG(100, ("prs_hash1\n")); - dump_data(100, sess_key, 16); - dump_data(100, q, 68); -#endif - SamOEMhash((uchar *) q, sess_key, 68); - -#ifdef DEBUG_PASSWORD - dump_data(100, q, 68); -#endif - - return True; -} diff --git a/source4/rpc_parse/parse_reg.c b/source4/rpc_parse/parse_reg.c deleted file mode 100644 index b4d20bf2ba..0000000000 --- a/source4/rpc_parse/parse_reg.c +++ /dev/null @@ -1,1872 +0,0 @@ -/* - * 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) Marc Jacobsen 1999. - * Copyright (C) Simo Sorce 2000. - * Copyright (C) Gerald Carter 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 - -/******************************************************************* - Fill in a BUFFER2 for the data given a REGISTRY_VALUE - *******************************************************************/ - -static uint32 reg_init_buffer2( BUFFER2 *buf2, REGISTRY_VALUE *val ) -{ - uint32 real_size = 0; - - if ( !buf2 || !val ) - return 0; - - real_size = regval_size(val); - init_buffer2( buf2, (char*)regval_data_p(val), real_size ); - - return real_size; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o, - uint16 unknown_0, uint32 level) -{ - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->level = level; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_open_hkcr(const char *desc, REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_hkcr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - - if (r_q->ptr != 0) { - if(!prs_uint16("unknown_0", ps, depth, &r_q->unknown_0)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) - return False; - if(!prs_uint32("level ", ps, depth, &r_q->level)) - return False; - } - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_open_hkcr(const char *desc, REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_hkcr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_open_hklm(REG_Q_OPEN_HKLM * q_o, - uint16 unknown_0, uint32 access_mask) -{ - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->access_mask = access_mask; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_q_open_hklm(const char *desc, REG_Q_OPEN_HKLM * r_q, prs_struct *ps, - int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_hklm"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr ", ps, depth, &(r_q->ptr))) - return False; - if (r_q->ptr != 0) - { - if (!prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0))) - return False; - if (!prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1))) - return False; - if (!prs_uint32("access_mask", ps, depth, &(r_q->access_mask))) - return False; - } - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_open_hklm(const char *desc, REG_R_OPEN_HKLM * r_r, prs_struct *ps, - int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_hklm"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if (!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - - - - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_flush_key(REG_Q_FLUSH_KEY *q_u, POLICY_HND *pol) -{ - memcpy(&q_u->pol, pol, sizeof(q_u->pol)); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_flush_key(const char *desc, REG_Q_FLUSH_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_flush_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_flush_key(const char *desc, REG_R_FLUSH_KEY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_flush_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes SEC_DESC_BUF and SEC_DATA structures. -********************************************************************/ - -static BOOL reg_io_hdrbuf_sec(uint32 ptr, uint32 *ptr3, BUFHDR *hdr_sec, SEC_DESC_BUF *data, prs_struct *ps, int depth) -{ - if (ptr != 0) { - uint32 hdr_offset; - uint32 old_offset; - if(!smb_io_hdrbuf_pre("hdr_sec", hdr_sec, ps, depth, &hdr_offset)) - return False; - - old_offset = prs_offset(ps); - - if (ptr3 != NULL) { - if(!prs_uint32("ptr3", ps, depth, ptr3)) - return False; - } - - if (ptr3 == NULL || *ptr3 != 0) { - if(!sec_io_desc_buf("data ", &data, ps, depth)) /* JRA - this line is probably wrong... */ - return False; - } - - if(!smb_io_hdrbuf_post("hdr_sec", hdr_sec, ps, depth, hdr_offset, - data->max_len, data->len)) - return False; - if(!prs_set_offset(ps, old_offset + data->len + sizeof(uint32) * ((ptr3 != NULL) ? 5 : 3))) - return False; - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd, - char *name, char *class, SEC_ACCESS *sam_access, - SEC_DESC_BUF *sec_buf) -{ - int len_name = name != NULL ? strlen(name ) + 1: 0; - int len_class = class != NULL ? strlen(class) + 1: 0; - - ZERO_STRUCTP(q_c); - - memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - - init_uni_hdr(&q_c->hdr_name, len_name); - init_unistr2(&q_c->uni_name, name, len_name); - - init_uni_hdr(&q_c->hdr_class, len_class); - init_unistr2(&q_c->uni_class, class, len_class); - - q_c->reserved = 0x00000000; - memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access)); - - q_c->ptr1 = 1; - q_c->sec_info = DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION; - - q_c->data = sec_buf; - q_c->ptr2 = 1; - init_buf_hdr(&q_c->hdr_sec, sec_buf->len, sec_buf->len); - q_c->ptr3 = 1; - q_c->unknown_2 = 0x00000000; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_create_key(const char *desc, REG_Q_CREATE_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_create_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) - return False; - - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("reserved", ps, depth, &r_q->reserved)) - return False; - if(!sec_io_access("sam_access", &r_q->sam_access, ps, depth)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) - return False; - - if (r_q->ptr1 != 0) { - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) - return False; - if(!reg_io_hdrbuf_sec(r_q->ptr2, &r_q->ptr3, &r_q->hdr_sec, r_q->data, ps, depth)) - return False; - - if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_create_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_r->key_pol, ps, depth)) - return False; - if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd, - char *name) -{ - int len_name = name != NULL ? strlen(name ) + 1: 0; - ZERO_STRUCTP(q_c); - - memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - - init_uni_hdr(&q_c->hdr_name, len_name); - init_unistr2(&q_c->uni_name, name, len_name); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_delete_val(const char *desc, REG_Q_DELETE_VALUE *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_delete_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) - return False; - - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_delete_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd, - char *name) -{ - int len_name = name != NULL ? strlen(name ) + 1: 0; - ZERO_STRUCTP(q_c); - - memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol)); - - init_uni_hdr(&q_c->hdr_name, len_name); - init_unistr2(&q_c->uni_name, name, len_name); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_delete_key(const char *desc, REG_Q_DELETE_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_delete_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pnt_pol, ps, depth)) - return False; - - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_delete_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, - uint32 max_class_len) -{ - ZERO_STRUCTP(q_o); - - memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); - init_uni_hdr(&q_o->hdr_class, max_class_len); - q_o->uni_class.uni_max_len = max_class_len; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_query_key(const char *desc, REG_Q_QUERY_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_query_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_class, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_class, r_q->hdr_class.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_query_key(const char *desc, REG_R_QUERY_KEY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_query_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr ("", &r_r->hdr_class, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_r->uni_class, r_r->hdr_class.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_subkeys ", ps, depth, &r_r->num_subkeys)) - return False; - if(!prs_uint32("max_subkeylen ", ps, depth, &r_r->max_subkeylen)) - return False; - if(!prs_uint32("reserved ", ps, depth, &r_r->reserved)) - return False; - if(!prs_uint32("num_values ", ps, depth, &r_r->num_values)) - return False; - if(!prs_uint32("max_valnamelen", ps, depth, &r_r->max_valnamelen)) - return False; - if(!prs_uint32("max_valbufsize", ps, depth, &r_r->max_valbufsize)) - return False; - if(!prs_uint32("sec_desc ", ps, depth, &r_r->sec_desc)) - return False; - if(!smb_io_time("mod_time ", &r_r->mod_time, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_unknown_1a(REG_Q_UNKNOWN_1A *q_o, POLICY_HND *hnd) -{ - memcpy(&q_o->pol, hnd, sizeof(q_o->pol)); -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_unknown_1a(const char *desc, REG_Q_UNKNOWN_1A *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_unknown_1a"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_unknown_1a(const char *desc, REG_R_UNKNOWN_1A *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_unknown_1a"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("unknown", ps, depth, &r_r->unknown)) - return False; - if(!prs_ntstatus("status" , ps, depth, &r_r->status)) - return False; - - return True; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_save_key(const char *desc, REG_Q_SAVE_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_save_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - - if(!smb_io_unihdr ("hdr_file", &r_q->hdr_file, ps, depth)) - return False; - if(!smb_io_unistr2("uni_file", &r_q->uni_file, r_q->hdr_file.buffer, ps, depth)) - return False; - - if(!prs_uint32("unknown", ps, depth, &r_q->unknown)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_save_key(const char *desc, REG_R_SAVE_KEY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_save_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status" , ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_q_open_hku(REG_Q_OPEN_HKU *q_o, - uint16 unknown_0, uint32 access_mask) -{ - q_o->ptr = 1; - q_o->unknown_0 = unknown_0; - q_o->unknown_1 = 0x0; /* random - changes */ - q_o->access_mask = access_mask; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_open_hku(const char *desc, REG_Q_OPEN_HKU *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_open_hku"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - if (r_q->ptr != 0) { - if(!prs_uint16("unknown_0 ", ps, depth, &r_q->unknown_0)) - return False; - if(!prs_uint16("unknown_1 ", ps, depth, &r_q->unknown_1)) - return False; - if(!prs_uint32("access_mask ", ps, depth, &r_q->access_mask)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_open_hku(const char *desc, REG_R_OPEN_HKU *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_hku"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* - Inits an REG_Q_CLOSE structure. -********************************************************************/ - -void init_reg_q_close(REG_Q_CLOSE *q_c, POLICY_HND *hnd) -{ - DEBUG(5,("init_reg_q_close\n")); - - memcpy(&q_c->pol, hnd, sizeof(q_c->pol)); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_close(const char *desc, REG_Q_CLOSE *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_u->pol, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_close(const char *desc, REG_R_CLOSE *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_u->pol, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_set_key_sec(REG_Q_SET_KEY_SEC *q_i, POLICY_HND *pol, SEC_DESC_BUF *sec_desc_buf) -{ - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); - - q_i->sec_info = DACL_SECURITY_INFORMATION; - - q_i->ptr = 1; - init_buf_hdr(&q_i->hdr_sec, sec_desc_buf->len, sec_desc_buf->len); - q_i->data = sec_desc_buf; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_set_key_sec(const char *desc, REG_Q_SET_KEY_SEC *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_set_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - - if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_set_key_sec(const char *desc, REG_R_SET_KEY_SEC *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_set_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol, - uint32 sec_buf_size, SEC_DESC_BUF *psdb) -{ - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); - - q_i->sec_info = OWNER_SECURITY_INFORMATION | - GROUP_SECURITY_INFORMATION | - DACL_SECURITY_INFORMATION; - - q_i->ptr = psdb != NULL ? 1 : 0; - q_i->data = psdb; - - init_buf_hdr(&q_i->hdr_sec, sec_buf_size, 0); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_get_key_sec(const char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_get_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &r_q->sec_info)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - - if(!reg_io_hdrbuf_sec(r_q->ptr, NULL, &r_q->hdr_sec, r_q->data, ps, depth)) - return False; - - return True; -} - -#if 0 -/******************************************************************* -makes a structure. -********************************************************************/ - void init_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol, - uint32 buf_len, uint8 *buf, - NTSTATUS status) -{ - r_i->ptr = 1; - init_buf_hdr(&r_i->hdr_sec, buf_len, buf_len); - init_sec_desc_buf(r_i->data, buf_len, 1); - - r_i->status = status; /* 0x0000 0000 or 0x0000 007a */ -} -#endif - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_get_key_sec(const char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_get_key_sec"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &r_q->ptr)) - return False; - - if (r_q->ptr != 0) { - if(!smb_io_hdrbuf("", &r_q->hdr_sec, ps, depth)) - return False; - if(!sec_io_desc_buf("", &r_q->data, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name) -{ - int len_type = val_name != NULL ? strlen(val_name) + 1 : 0; - - if (q_i == NULL) - return False; - - q_i->pol = *pol; - - init_uni_hdr(&(q_i->hdr_type), len_type); - init_unistr2(&(q_i->uni_type), val_name, len_type); - - q_i->ptr_reserved = 1; - q_i->ptr_buf = 1; - - q_i->ptr_bufsize = 1; - q_i->bufsize = 0; - q_i->buf_unk = 0; - - q_i->unk1 = 0; - q_i->ptr_buflen = 1; - q_i->buflen = 0; - - q_i->ptr_buflen2 = 1; - q_i->buflen2 = 0; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_info(const char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_type, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_type, r_q->hdr_type.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved))) - return False; - - if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf))) - return False; - - if(r_q->ptr_buf) { - if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize))) - return False; - if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize))) - return False; - if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk))) - return False; - } - - if(!prs_uint32("unk1", ps, depth, &(r_q->unk1))) - return False; - - if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen))) - return False; - - if (r_q->ptr_buflen) { - if(!prs_uint32("buflen", ps, depth, &(r_q->buflen))) - return False; - if(!prs_uint32("ptr_buflen2", ps, depth, &(r_q->ptr_buflen2))) - return False; - if(!prs_uint32("buflen2", ps, depth, &(r_q->buflen2))) - return False; - } - - return True; -} - -/******************************************************************* - Inits a structure. - New version to replace older init_reg_r_info() -********************************************************************/ - -BOOL new_init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, - REGISTRY_VALUE *val, NTSTATUS status) -{ - uint32 buf_len = 0; - BUFFER2 buf2; - - if(r_r == NULL) - return False; - - if ( !val ) - return False; - - r_r->ptr_type = 1; - r_r->type = val->type; - - /* if include_keyval is not set, don't send the key value, just - the buflen data. probably used by NT5 to allocate buffer space - SK */ - - if ( include_keyval ) { - r_r->ptr_uni_val = 1; - buf_len = reg_init_buffer2( &r_r->uni_val, val ); - - } - else { - /* dummy buffer used so we can get the size */ - r_r->ptr_uni_val = 0; - buf_len = reg_init_buffer2( &buf2, val ); - } - - r_r->ptr_max_len = 1; - r_r->buf_max_len = buf_len; - - r_r->ptr_len = 1; - r_r->buf_len = buf_len; - - r_r->status = status; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, - BUFFER2* buf, uint32 type, NTSTATUS status) -{ - if(r_r == NULL) - return False; - - r_r->ptr_type = 1; - r_r->type = type; - - /* if include_keyval is not set, don't send the key value, just - the buflen data. probably used by NT5 to allocate buffer space - SK */ - - r_r->ptr_uni_val = include_keyval ? 1:0; - r_r->uni_val = *buf; - - r_r->ptr_max_len = 1; - r_r->buf_max_len = r_r->uni_val.buf_max_len; - - r_r->ptr_len = 1; - r_r->buf_len = r_r->uni_val.buf_len; - - r_r->status = status; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_info(const char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type))) - return False; - - if (r_r->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &r_r->type)) - return False; - } - - if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val))) - return False; - - if(r_r->ptr_uni_val != 0) { - if(!smb_io_buffer2("uni_val", &r_r->uni_val, r_r->ptr_uni_val, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len))) - return False; - - if (r_r->ptr_max_len != 0) { - if(!prs_uint32("buf_max_len", ps, depth, &(r_r->buf_max_len))) - return False; - } - - if(!prs_uint32("ptr_len", ps, depth, &(r_r->ptr_len))) - return False; - if (r_r->ptr_len != 0) { - if(!prs_uint32("buf_len", ps, depth, &(r_r->buf_len))) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol, - uint32 val_idx, uint32 max_val_len, - uint32 max_buf_len) -{ - ZERO_STRUCTP(q_i); - - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); - - q_i->val_index = val_idx; - init_uni_hdr(&q_i->hdr_name, max_val_len); - q_i->uni_name.uni_max_len = max_val_len; - - q_i->ptr_type = 1; - q_i->type = 0x0; - - q_i->ptr_value = 1; - q_i->buf_value.buf_max_len = max_buf_len; - - q_i->ptr1 = 1; - q_i->len_value1 = max_buf_len; - - q_i->ptr2 = 1; - q_i->len_value2 = 0; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val ) -{ - uint32 real_size; - - DEBUG(8,("init_reg_r_enum_val: Enter\n")); - - ZERO_STRUCTP(r_u); - - /* value name */ - - DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename)); - - init_uni_hdr( &r_u->hdr_name, strlen(val->valuename)+1 ); - init_unistr2( &r_u->uni_name, val->valuename, strlen(val->valuename)+1 ); - - /* type */ - - r_u->ptr_type = 1; - r_u->type = val->type; - - /* REG_SZ & REG_MULTI_SZ must be converted to UNICODE */ - - r_u->ptr_value = 1; - real_size = reg_init_buffer2( &r_u->buf_value, val ); - - /* lengths */ - - r_u->ptr1 = 1; - r_u->len_value1 = real_size; - - r_u->ptr2 = 1; - r_u->len_value2 = real_size; - - DEBUG(8,("init_reg_r_enum_val: Exit\n")); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_enum_val(const char *desc, REG_Q_ENUM_VALUE *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_enum_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!prs_uint32("val_index", ps, depth, &q_q->val_index)) - return False; - - if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_type", ps, depth, &q_q->ptr_type)) - return False; - - if (q_q->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &q_q->type)) - return False; - } - - if(!prs_uint32("ptr_value", ps, depth, &q_q->ptr_value)) - return False; - if(!smb_io_buffer2("buf_value", &q_q->buf_value, q_q->ptr_value, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) - return False; - if (q_q->ptr1 != 0) { - if(!prs_uint32("len_value1", ps, depth, &q_q->len_value1)) - return False; - } - if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) - return False; - if (q_q->ptr2 != 0) { - if(!prs_uint32("len_value2", ps, depth, &q_q->len_value2)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_enum_val(const char *desc, REG_R_ENUM_VALUE *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_enum_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr ("hdr_name", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_type", ps, depth, &r_q->ptr_type)) - return False; - - if (r_q->ptr_type != 0) { - if(!prs_uint32("type", ps, depth, &r_q->type)) - return False; - } - - if(!prs_uint32("ptr_value", ps, depth, &r_q->ptr_value)) - return False; - if(!smb_io_buffer2("buf_value", &r_q->buf_value, r_q->ptr_value, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) - return False; - if (r_q->ptr1 != 0) { - if(!prs_uint32("len_value1", ps, depth, &r_q->len_value1)) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) - return False; - if (r_q->ptr2 != 0) { - if(!prs_uint32("len_value2", ps, depth, &r_q->len_value2)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol, - char *val_name, uint32 type, - BUFFER3 *val) -{ - int val_len = strlen(val_name) + 1; - - ZERO_STRUCTP(q_i); - - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); - - init_uni_hdr(&q_i->hdr_name, val_len); - init_unistr2(&q_i->uni_name, val_name, val_len); - - q_i->type = type; - q_i->buf_value = val; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_create_val(const char *desc, REG_Q_CREATE_VALUE *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_create_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!smb_io_unihdr ("hdr_name", &q_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &q_q->uni_name, q_q->hdr_name.buffer, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_q->type)) - return False; - if(!smb_io_buffer3("buf_value", q_q->buf_value, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_create_val(const char *desc, REG_R_CREATE_VALUE *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_create_val"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_enum_key(REG_Q_ENUM_KEY *q_i, POLICY_HND *pol, uint32 key_idx) -{ - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); - - q_i->key_index = key_idx; - q_i->key_name_len = 0; - q_i->unknown_1 = 0x0414; - - q_i->ptr1 = 1; - q_i->unknown_2 = 0x0000020A; - memset(q_i->pad1, 0, sizeof(q_i->pad1)); - - q_i->ptr2 = 1; - memset(q_i->pad2, 0, sizeof(q_i->pad2)); - - q_i->ptr3 = 1; - unix_to_nt_time(&q_i->time, 0); /* current time? */ -} - -/******************************************************************* -makes a reply structure. -********************************************************************/ - -void init_reg_r_enum_key(REG_R_ENUM_KEY *r_u, char *subkey, uint32 unknown_1, - uint32 unknown_2) -{ - if ( !r_u ) - return; - - r_u->unknown_1 = unknown_1; - r_u->unknown_2 = unknown_2; - r_u->unknown_3 = 0x0; - - r_u->key_name_len = (strlen(subkey)+1) * 2; - if (r_u->key_name_len) - r_u->ptr1 = 0x1; - init_unistr3( &r_u->key_name, subkey ); - - r_u->ptr2 = 0x1; - r_u->ptr3 = 0x1; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_enum_key(const char *desc, REG_Q_ENUM_KEY *q_q, prs_struct *ps, int depth) -{ - if (q_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_enum_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &q_q->pol, ps, depth)) - return False; - - if(!prs_uint32("key_index", ps, depth, &q_q->key_index)) - return False; - if(!prs_uint16("key_name_len", ps, depth, &q_q->key_name_len)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &q_q->unknown_1)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &q_q->ptr1)) - return False; - - if (q_q->ptr1 != 0) { - if(!prs_uint32("unknown_2", ps, depth, &q_q->unknown_2)) - return False; - if(!prs_uint8s(False, "pad1", ps, depth, q_q->pad1, sizeof(q_q->pad1))) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &q_q->ptr2)) - return False; - - if (q_q->ptr2 != 0) { - if(!prs_uint8s(False, "pad2", ps, depth, q_q->pad2, sizeof(q_q->pad2))) - return False; - } - - if(!prs_uint32("ptr3", ps, depth, &q_q->ptr3)) - return False; - - if (q_q->ptr3 != 0) { - if(!smb_io_time("", &q_q->time, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_enum_key(const char *desc, REG_R_ENUM_KEY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_enum_key"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("key_name_len", ps, depth, &r_q->key_name_len)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &r_q->unknown_1)) - return False; - - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) - return False; - - if (r_q->ptr1 != 0) { - if(!prs_uint32("unknown_2", ps, depth, &r_q->unknown_2)) - return False; - if(!prs_uint32("unknown_3", ps, depth, &r_q->unknown_3)) - return False; - if(!smb_io_unistr3("key_name", &r_q->key_name, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) - return False; - - if (r_q->ptr2 != 0) { - if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2))) - return False; - } - - if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3)) - return False; - - if (r_q->ptr3 != 0) { - if(!smb_io_time("", &r_q->time, ps, depth)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_q->status)) - return False; - - return True; -} - -/******************************************************************* -makes a structure. -********************************************************************/ - -void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol, - char *key_name, uint32 access_desired) -{ - int len_name = strlen(key_name)+1; - - memcpy(&r_q->pol, pol, sizeof(r_q->pol)); - - init_uni_hdr(&r_q->hdr_name, len_name); - init_unistr2(&r_q->uni_name, key_name, len_name); - - r_q->unknown_0 = 0x00000000; - r_q->access_desired = access_desired; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_q_open_entry(const char *desc, REG_Q_OPEN_ENTRY *r_q, prs_struct *ps, int depth) -{ - if (r_q == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_entry"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_q->pol, ps, depth)) - return False; - if(!smb_io_unihdr ("", &r_q->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &r_q->uni_name, r_q->hdr_name.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("unknown_0 ", ps, depth, &r_q->unknown_0)) - return False; - if(!prs_uint32("access_desired ", ps, depth, &r_q->access_desired)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure. -********************************************************************/ - -void init_reg_r_open_entry(REG_R_OPEN_ENTRY *r_r, - POLICY_HND *pol, NTSTATUS status) -{ - if (NT_STATUS_IS_OK(status)) { - memcpy(&r_r->pol, pol, sizeof(r_r->pol)); - } else { - ZERO_STRUCT(r_r->pol); - } - r_r->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *ps, int depth) -{ - if (r_r == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_open_entry"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("", &r_r->pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_r->status)) - return False; - - return True; -} - -/******************************************************************* -Inits a structure. -********************************************************************/ -void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg, - uint32 timeout, BOOL do_reboot, BOOL force) -{ - int msg_len; - msg_len = strlen(msg); - - q_s->ptr_0 = 1; - q_s->ptr_1 = 1; - q_s->ptr_2 = 1; - - init_uni_hdr(&(q_s->hdr_msg), msg_len); - init_unistr2(&(q_s->uni_msg), msg, msg_len); - - q_s->timeout = timeout; - - q_s->reboot = do_reboot ? 1 : 0; - q_s->force = force ? 1 : 0; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps, - int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_0", ps, depth, &(q_s->ptr_0))) - return False; - if (!prs_uint32("ptr_1", ps, depth, &(q_s->ptr_1))) - return False; - if (!prs_uint32("ptr_2", ps, depth, &(q_s->ptr_2))) - return False; - - if (!smb_io_unihdr("hdr_msg", &(q_s->hdr_msg), ps, depth)) - return False; - if (!smb_io_unistr2("uni_msg", &(q_s->uni_msg), q_s->hdr_msg.buffer, ps, depth)) - return False; - if (!prs_align(ps)) - return False; - - if (!prs_uint32("timeout", ps, depth, &(q_s->timeout))) - return False; - if (!prs_uint8("force ", ps, depth, &(q_s->force))) - return False; - if (!prs_uint8("reboot ", ps, depth, &(q_s->reboot))) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_shutdown(const char *desc, REG_R_SHUTDOWN * r_s, prs_struct *ps, - int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_shutdown"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} - -/******************************************************************* -Inits a structure. -********************************************************************/ -void init_reg_q_abort_shutdown(REG_Q_ABORT_SHUTDOWN * q_s) -{ - - q_s->ptr_server = 0; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_q_abort_shutdown(const char *desc, REG_Q_ABORT_SHUTDOWN * q_s, - prs_struct *ps, int depth) -{ - if (q_s == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_q_abort_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_server", ps, depth, &(q_s->ptr_server))) - return False; - if (q_s->ptr_server != 0) - if (!prs_uint16("server", ps, depth, &(q_s->server))) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ -BOOL reg_io_r_abort_shutdown(const char *desc, REG_R_ABORT_SHUTDOWN * r_s, - prs_struct *ps, int depth) -{ - if (r_s == NULL) - return False; - - prs_debug(ps, depth, desc, "reg_io_r_abort_shutdown"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_ntstatus("status", ps, depth, &r_s->status)) - return False; - - return True; -} diff --git a/source4/rpc_parse/parse_rpc.c b/source4/rpc_parse/parse_rpc.c deleted file mode 100644 index fafbbb1965..0000000000 --- a/source4/rpc_parse/parse_rpc.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* - * 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) Jeremy Allison 1999. - * - * 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 - -/******************************************************************* -interface/version dce/rpc pipe identification -********************************************************************/ - -#define TRANS_SYNT_V2 \ -{ \ - { \ - 0x8a885d04, 0x1ceb, 0x11c9, \ - { 0x9f, 0xe8, 0x08, 0x00, \ - 0x2b, 0x10, 0x48, 0x60 } \ - }, 0x02 \ -} - -#define SYNT_NETLOGON_V2 \ -{ \ - { \ - 0x8a885d04, 0x1ceb, 0x11c9, \ - { 0x9f, 0xe8, 0x08, 0x00, \ - 0x2b, 0x10, 0x48, 0x60 } \ - }, 0x02 \ -} - -#define SYNT_WKSSVC_V1 \ -{ \ - { \ - 0x6bffd098, 0xa112, 0x3610, \ - { 0x98, 0x33, 0x46, 0xc3, \ - 0xf8, 0x7e, 0x34, 0x5a } \ - }, 0x01 \ -} - -#define SYNT_SRVSVC_V3 \ -{ \ - { \ - 0x4b324fc8, 0x1670, 0x01d3, \ - { 0x12, 0x78, 0x5a, 0x47, \ - 0xbf, 0x6e, 0xe1, 0x88 } \ - }, 0x03 \ -} - -#define SYNT_LSARPC_V0 \ -{ \ - { \ - 0x12345778, 0x1234, 0xabcd, \ - { 0xef, 0x00, 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xab } \ - }, 0x00 \ -} - -#define SYNT_LSARPC_V0_DS \ -{ \ - { \ - 0x3919286a, 0xb10c, 0x11d0, \ - { 0x9b, 0xa8, 0x00, 0xc0, \ - 0x4f, 0xd9, 0x2e, 0xf5 } \ - }, 0x00 \ -} - -#define SYNT_SAMR_V1 \ -{ \ - { \ - 0x12345778, 0x1234, 0xabcd, \ - { 0xef, 0x00, 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xac } \ - }, 0x01 \ -} - -#define SYNT_NETLOGON_V1 \ -{ \ - { \ - 0x12345678, 0x1234, 0xabcd, \ - { 0xef, 0x00, 0x01, 0x23, \ - 0x45, 0x67, 0xcf, 0xfb } \ - }, 0x01 \ -} - -#define SYNT_WINREG_V1 \ -{ \ - { \ - 0x338cd001, 0x2244, 0x31f1, \ - { 0xaa, 0xaa, 0x90, 0x00, \ - 0x38, 0x00, 0x10, 0x03 } \ - }, 0x01 \ -} - -#define SYNT_SPOOLSS_V1 \ -{ \ - { \ - 0x12345678, 0x1234, 0xabcd, \ - { 0xef, 0x00, 0x01, 0x23, \ - 0x45, 0x67, 0x89, 0xab } \ - }, 0x01 \ -} - -#define SYNT_NONE_V0 \ -{ \ - { \ - 0x0, 0x0, 0x0, \ - { 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00 } \ - }, 0x00 \ -} - -#define SYNT_NETDFS_V3 \ -{ \ - { \ - 0x4fc742e0, 0x4a10, 0x11cf, \ - { 0x82, 0x73, 0x00, 0xaa, \ - 0x00, 0x4a, 0xe6, 0x73 } \ - }, 0x03 \ -} - -/* - * IMPORTANT!! If you update this structure, make sure to - * update the index #defines in smb.h. - */ - -const struct pipe_id_info pipe_names [] = -{ - /* client pipe , abstract syntax , server pipe , transfer syntax */ - { PIPE_LSARPC , SYNT_LSARPC_V0 , PIPE_LSASS , TRANS_SYNT_V2 }, - { PIPE_LSARPC , SYNT_LSARPC_V0_DS , PIPE_LSASS , TRANS_SYNT_V2 }, - { PIPE_SAMR , SYNT_SAMR_V1 , PIPE_LSASS , TRANS_SYNT_V2 }, - { PIPE_NETLOGON, SYNT_NETLOGON_V1 , PIPE_LSASS , TRANS_SYNT_V2 }, - { PIPE_SRVSVC , SYNT_SRVSVC_V3 , PIPE_NTSVCS , TRANS_SYNT_V2 }, - { PIPE_WKSSVC , SYNT_WKSSVC_V1 , PIPE_NTSVCS , TRANS_SYNT_V2 }, - { PIPE_WINREG , SYNT_WINREG_V1 , PIPE_WINREG , TRANS_SYNT_V2 }, - { PIPE_SPOOLSS , SYNT_SPOOLSS_V1 , PIPE_SPOOLSS , TRANS_SYNT_V2 }, - { PIPE_NETDFS , SYNT_NETDFS_V3 , PIPE_NETDFS , TRANS_SYNT_V2 }, - { NULL , SYNT_NONE_V0 , NULL , SYNT_NONE_V0 } -}; - -/******************************************************************* - Inits an RPC_HDR structure. -********************************************************************/ - -void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags, - uint32 call_id, int data_len, int auth_len) -{ - hdr->major = 5; /* RPC version 5 */ - hdr->minor = 0; /* minor version 0 */ - hdr->pkt_type = pkt_type; /* RPC packet type */ - hdr->flags = flags; /* dce/rpc flags */ - hdr->pack_type[0] = 0x10; /* little-endian data representation */ - hdr->pack_type[1] = 0; /* packed data representation */ - hdr->pack_type[2] = 0; /* packed data representation */ - hdr->pack_type[3] = 0; /* packed data representation */ - hdr->frag_len = data_len; /* fragment length, fill in later */ - hdr->auth_len = auth_len; /* authentication length */ - hdr->call_id = call_id; /* call identifier - match incoming RPC */ -} - -/******************************************************************* - Reads or writes an RPC_HDR structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr(const char *desc, RPC_HDR *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr"); - depth++; - - if(!prs_uint8 ("major ", ps, depth, &rpc->major)) - return False; - - if(!prs_uint8 ("minor ", ps, depth, &rpc->minor)) - return False; - if(!prs_uint8 ("pkt_type ", ps, depth, &rpc->pkt_type)) - return False; - if(!prs_uint8 ("flags ", ps, depth, &rpc->flags)) - return False; - - /* We always marshall in little endian format. */ - if (MARSHALLING(ps)) - rpc->pack_type[0] = 0x10; - - if(!prs_uint8("pack_type0", ps, depth, &rpc->pack_type[0])) - return False; - if(!prs_uint8("pack_type1", ps, depth, &rpc->pack_type[1])) - return False; - if(!prs_uint8("pack_type2", ps, depth, &rpc->pack_type[2])) - return False; - if(!prs_uint8("pack_type3", ps, depth, &rpc->pack_type[3])) - return False; - - /* - * If reading and pack_type[0] == 0 then the data is in big-endian - * format. Set the flag in the prs_struct to specify reverse-endainness. - */ - - if (UNMARSHALLING(ps) && rpc->pack_type[0] == 0) { - DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n")); - prs_set_endian_data(ps, RPC_BIG_ENDIAN); - } - - if(!prs_uint16("frag_len ", ps, depth, &rpc->frag_len)) - return False; - if(!prs_uint16("auth_len ", ps, depth, &rpc->auth_len)) - return False; - if(!prs_uint32("call_id ", ps, depth, &rpc->call_id)) - return False; - return True; -} - -/******************************************************************* - Reads or writes an RPC_IFACE structure. -********************************************************************/ - -static BOOL smb_io_rpc_iface(const char *desc, RPC_IFACE *ifc, prs_struct *ps, int depth) -{ - if (ifc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_iface"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32 ("data ", ps, depth, &ifc->uuid.time_low)) - return False; - if(!prs_uint16 ("data ", ps, depth, &ifc->uuid.time_mid)) - return False; - if(!prs_uint16 ("data ", ps, depth, &ifc->uuid.time_hi_and_version)) - return False; - - if(!prs_uint8s (False, "data ", ps, depth, ifc->uuid.remaining, sizeof(ifc->uuid.remaining))) - return False; - if(!prs_uint32 ( "version", ps, depth, &ifc->version)) - return False; - - return True; -} - -/******************************************************************* - Inits an RPC_ADDR_STR structure. -********************************************************************/ - -static void init_rpc_addr_str(RPC_ADDR_STR *str, const char *name) -{ - str->len = strlen(name) + 1; - fstrcpy(str->str, name); -} - -/******************************************************************* - Reads or writes an RPC_ADDR_STR structure. -********************************************************************/ - -static BOOL smb_io_rpc_addr_str(const char *desc, RPC_ADDR_STR *str, prs_struct *ps, int depth) -{ - if (str == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_addr_str"); - depth++; - if(!prs_align(ps)) - return False; - - if(!prs_uint16 ( "len", ps, depth, &str->len)) - return False; - if(!prs_uint8s (True, "str", ps, depth, (uchar*)str->str, MIN(str->len, sizeof(str->str)) )) - return False; - return True; -} - -/******************************************************************* - Inits an RPC_HDR_BBA structure. -********************************************************************/ - -static void init_rpc_hdr_bba(RPC_HDR_BBA *bba, uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid) -{ - bba->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */ - bba->max_rsize = max_rsize; /* max receive fragment size (0x1630) */ - bba->assoc_gid = assoc_gid; /* associated group id (0x0) */ -} - -/******************************************************************* - Reads or writes an RPC_HDR_BBA structure. -********************************************************************/ - -static BOOL smb_io_rpc_hdr_bba(const char *desc, RPC_HDR_BBA *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_bba"); - depth++; - - if(!prs_uint16("max_tsize", ps, depth, &rpc->max_tsize)) - return False; - if(!prs_uint16("max_rsize", ps, depth, &rpc->max_rsize)) - return False; - if(!prs_uint32("assoc_gid", ps, depth, &rpc->assoc_gid)) - return False; - return True; -} - -/******************************************************************* - Inits an RPC_HDR_RB structure. -********************************************************************/ - -void init_rpc_hdr_rb(RPC_HDR_RB *rpc, - uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, - uint32 num_elements, uint16 context_id, uint8 num_syntaxes, - RPC_IFACE *abstract, RPC_IFACE *transfer) -{ - init_rpc_hdr_bba(&rpc->bba, max_tsize, max_rsize, assoc_gid); - - rpc->num_elements = num_elements ; /* the number of elements (0x1) */ - rpc->context_id = context_id ; /* presentation context identifier (0x0) */ - rpc->num_syntaxes = num_syntaxes ; /* the number of syntaxes (has always been 1?)(0x1) */ - - /* num and vers. of interface client is using */ - rpc->abstract = *abstract; - - /* num and vers. of interface to use for replies */ - rpc->transfer = *transfer; -} - -/******************************************************************* - Reads or writes an RPC_HDR_RB structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_rb(const char *desc, RPC_HDR_RB *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_rb"); - depth++; - - if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth)) - return False; - - if(!prs_uint32("num_elements", ps, depth, &rpc->num_elements)) - return False; - if(!prs_uint16("context_id ", ps, depth, &rpc->context_id )) - return False; - if(!prs_uint8 ("num_syntaxes", ps, depth, &rpc->num_syntaxes)) - return False; - - if(!smb_io_rpc_iface("", &rpc->abstract, ps, depth)) - return False; - if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits an RPC_RESULTS structure. - - lkclXXXX only one reason at the moment! -********************************************************************/ - -static void init_rpc_results(RPC_RESULTS *res, - uint8 num_results, uint16 result, uint16 reason) -{ - res->num_results = num_results; /* the number of results (0x01) */ - res->result = result ; /* result (0x00 = accept) */ - res->reason = reason ; /* reason (0x00 = no reason specified) */ -} - -/******************************************************************* - Reads or writes an RPC_RESULTS structure. - - lkclXXXX only one reason at the moment! -********************************************************************/ - -static BOOL smb_io_rpc_results(const char *desc, RPC_RESULTS *res, prs_struct *ps, int depth) -{ - if (res == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_results"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8 ("num_results", ps, depth, &res->num_results)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("result ", ps, depth, &res->result)) - return False; - if(!prs_uint16("reason ", ps, depth, &res->reason)) - return False; - return True; -} - -/******************************************************************* - Init an RPC_HDR_BA structure. - - lkclXXXX only one reason at the moment! - -********************************************************************/ - -void init_rpc_hdr_ba(RPC_HDR_BA *rpc, - uint16 max_tsize, uint16 max_rsize, uint32 assoc_gid, - const char *pipe_addr, - uint8 num_results, uint16 result, uint16 reason, - RPC_IFACE *transfer) -{ - init_rpc_hdr_bba (&rpc->bba, max_tsize, max_rsize, assoc_gid); - init_rpc_addr_str(&rpc->addr, pipe_addr); - init_rpc_results (&rpc->res, num_results, result, reason); - - /* the transfer syntax from the request */ - memcpy(&rpc->transfer, transfer, sizeof(rpc->transfer)); -} - -/******************************************************************* - Reads or writes an RPC_HDR_BA structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_ba(const char *desc, RPC_HDR_BA *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_ba"); - depth++; - - if(!smb_io_rpc_hdr_bba("", &rpc->bba, ps, depth)) - return False; - if(!smb_io_rpc_addr_str("", &rpc->addr, ps, depth)) - return False; - if(!smb_io_rpc_results("", &rpc->res, ps, depth)) - return False; - if(!smb_io_rpc_iface("", &rpc->transfer, ps, depth)) - return False; - return True; -} - -/******************************************************************* - Init an RPC_HDR_REQ structure. -********************************************************************/ - -void init_rpc_hdr_req(RPC_HDR_REQ *hdr, uint32 alloc_hint, uint16 opnum) -{ - hdr->alloc_hint = alloc_hint; /* allocation hint */ - hdr->context_id = 0; /* presentation context identifier */ - hdr->opnum = opnum; /* opnum */ -} - -/******************************************************************* - Reads or writes an RPC_HDR_REQ structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_req(const char *desc, RPC_HDR_REQ *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_req"); - depth++; - - if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint)) - return False; - if(!prs_uint16("context_id", ps, depth, &rpc->context_id)) - return False; - if(!prs_uint16("opnum ", ps, depth, &rpc->opnum)) - return False; - return True; -} - -/******************************************************************* - Reads or writes an RPC_HDR_RESP structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_resp(const char *desc, RPC_HDR_RESP *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_resp"); - depth++; - - if(!prs_uint32("alloc_hint", ps, depth, &rpc->alloc_hint)) - return False; - if(!prs_uint16("context_id", ps, depth, &rpc->context_id)) - return False; - if(!prs_uint8 ("cancel_ct ", ps, depth, &rpc->cancel_count)) - return False; - if(!prs_uint8 ("reserved ", ps, depth, &rpc->reserved)) - return False; - return True; -} - -/******************************************************************* - Reads or writes an RPC_HDR_FAULT structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_fault(const char *desc, RPC_HDR_FAULT *rpc, prs_struct *ps, int depth) -{ - if (rpc == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_fault"); - depth++; - - if(!prs_ntstatus("status ", ps, depth, &rpc->status)) - return False; - if(!prs_uint32("reserved", ps, depth, &rpc->reserved)) - return False; - - return True; -} - -/******************************************************************* - Init an RPC_HDR_AUTHA structure. -********************************************************************/ - -void init_rpc_hdr_autha(RPC_HDR_AUTHA *rai, - uint16 max_tsize, uint16 max_rsize, - uint8 auth_type, uint8 auth_level, - uint8 stub_type_len) -{ - rai->max_tsize = max_tsize; /* maximum transmission fragment size (0x1630) */ - rai->max_rsize = max_rsize; /* max receive fragment size (0x1630) */ - - rai->auth_type = auth_type; /* nt lm ssp 0x0a */ - rai->auth_level = auth_level; /* 0x06 */ - rai->stub_type_len = stub_type_len; /* 0x00 */ - rai->padding = 0; /* padding 0x00 */ - - rai->unknown = 0x0014a0c0; /* non-zero pointer to something */ -} - -/******************************************************************* - Reads or writes an RPC_HDR_AUTHA structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_autha(const char *desc, RPC_HDR_AUTHA *rai, prs_struct *ps, int depth) -{ - if (rai == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_autha"); - depth++; - - if(!prs_uint16("max_tsize ", ps, depth, &rai->max_tsize)) - return False; - if(!prs_uint16("max_rsize ", ps, depth, &rai->max_rsize)) - return False; - - if(!prs_uint8 ("auth_type ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */ - return False; - if(!prs_uint8 ("auth_level ", ps, depth, &rai->auth_level)) /* 0x06 */ - return False; - if(!prs_uint8 ("stub_type_len", ps, depth, &rai->stub_type_len)) - return False; - if(!prs_uint8 ("padding ", ps, depth, &rai->padding)) - return False; - - if(!prs_uint32("unknown ", ps, depth, &rai->unknown)) /* 0x0014a0c0 */ - return False; - - return True; -} - -/******************************************************************* - Checks an RPC_HDR_AUTH structure. -********************************************************************/ - -BOOL rpc_hdr_auth_chk(RPC_HDR_AUTH *rai) -{ - return (rai->auth_type == NTLMSSP_AUTH_TYPE && rai->auth_level == NTLMSSP_AUTH_LEVEL); -} - -/******************************************************************* - Inits an RPC_HDR_AUTH structure. -********************************************************************/ - -void init_rpc_hdr_auth(RPC_HDR_AUTH *rai, - uint8 auth_type, uint8 auth_level, - uint8 stub_type_len, - uint32 ptr) -{ - rai->auth_type = auth_type; /* nt lm ssp 0x0a */ - rai->auth_level = auth_level; /* 0x06 */ - rai->stub_type_len = stub_type_len; /* 0x00 */ - rai->padding = 0; /* padding 0x00 */ - - rai->unknown = ptr; /* non-zero pointer to something */ -} - -/******************************************************************* - Reads or writes an RPC_HDR_AUTH structure. -********************************************************************/ - -BOOL smb_io_rpc_hdr_auth(const char *desc, RPC_HDR_AUTH *rai, prs_struct *ps, int depth) -{ - if (rai == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_hdr_auth"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8 ("auth_type ", ps, depth, &rai->auth_type)) /* 0x0a nt lm ssp */ - return False; - if(!prs_uint8 ("auth_level ", ps, depth, &rai->auth_level)) /* 0x06 */ - return False; - if(!prs_uint8 ("stub_type_len", ps, depth, &rai->stub_type_len)) - return False; - if(!prs_uint8 ("padding ", ps, depth, &rai->padding)) - return False; - - if(!prs_uint32("unknown ", ps, depth, &rai->unknown)) /* 0x0014a0c0 */ - return False; - - return True; -} - -/******************************************************************* - Checks an RPC_AUTH_VERIFIER structure. -********************************************************************/ - -BOOL rpc_auth_verifier_chk(RPC_AUTH_VERIFIER *rav, - const char *signature, uint32 msg_type) -{ - return (strequal(rav->signature, signature) && rav->msg_type == msg_type); -} - -/******************************************************************* - Inits an RPC_AUTH_VERIFIER structure. -********************************************************************/ - -void init_rpc_auth_verifier(RPC_AUTH_VERIFIER *rav, - const char *signature, uint32 msg_type) -{ - fstrcpy(rav->signature, signature); /* "NTLMSSP" */ - rav->msg_type = msg_type; /* NTLMSSP_MESSAGE_TYPE */ -} - -/******************************************************************* - Reads or writes an RPC_AUTH_VERIFIER structure. -********************************************************************/ - -BOOL smb_io_rpc_auth_verifier(const char *desc, RPC_AUTH_VERIFIER *rav, prs_struct *ps, int depth) -{ - if (rav == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_auth_verifier"); - depth++; - - /* "NTLMSSP" */ - if(!prs_string("signature", ps, depth, rav->signature, strlen("NTLMSSP"), - sizeof(rav->signature))) - return False; - if(!prs_uint32("msg_type ", ps, depth, &rav->msg_type)) /* NTLMSSP_MESSAGE_TYPE */ - return False; - - return True; -} - -/******************************************************************* - Inits an RPC_AUTH_NTLMSSP_NEG structure. -********************************************************************/ - -void init_rpc_auth_ntlmssp_neg(RPC_AUTH_NTLMSSP_NEG *neg, - uint32 neg_flgs, - const char *myname, const char *domain) -{ - int len_myname = strlen(myname); - int len_domain = strlen(domain); - - neg->neg_flgs = neg_flgs ; /* 0x00b2b3 */ - - init_str_hdr(&neg->hdr_domain, len_domain, len_domain, 0x20 + len_myname); - init_str_hdr(&neg->hdr_myname, len_myname, len_myname, 0x20); - - fstrcpy(neg->myname, myname); - fstrcpy(neg->domain, domain); -} - -/******************************************************************* - Reads or writes an RPC_AUTH_NTLMSSP_NEG structure. - - *** lkclXXXX HACK ALERT! *** -********************************************************************/ - -BOOL smb_io_rpc_auth_ntlmssp_neg(const char *desc, RPC_AUTH_NTLMSSP_NEG *neg, prs_struct *ps, int depth) -{ - uint32 start_offset = prs_offset(ps); - if (neg == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_neg"); - depth++; - - if(!prs_uint32("neg_flgs ", ps, depth, &neg->neg_flgs)) - return False; - - if (ps->io) { - uint32 old_offset; - uint32 old_neg_flags = neg->neg_flgs; - - /* reading */ - - ZERO_STRUCTP(neg); - - neg->neg_flgs = old_neg_flags; - - if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth)) - return False; - - old_offset = prs_offset(ps); - - if(!prs_set_offset(ps, neg->hdr_myname.buffer + start_offset - 12)) - return False; - - if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, - MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname)))) - return False; - - old_offset += neg->hdr_myname.str_str_len; - - if(!prs_set_offset(ps, neg->hdr_domain.buffer + start_offset - 12)) - return False; - - if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, - MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain )))) - return False; - - old_offset += neg->hdr_domain .str_str_len; - - if(!prs_set_offset(ps, old_offset)) - return False; - } else { - /* writing */ - if(!smb_io_strhdr("hdr_domain", &neg->hdr_domain, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_myname", &neg->hdr_myname, ps, depth)) - return False; - - if(!prs_uint8s(True, "myname", ps, depth, (uint8*)neg->myname, - MIN(neg->hdr_myname.str_str_len, sizeof(neg->myname)))) - return False; - if(!prs_uint8s(True, "domain", ps, depth, (uint8*)neg->domain, - MIN(neg->hdr_domain.str_str_len, sizeof(neg->domain )))) - return False; - } - - return True; -} - -/******************************************************************* -creates an RPC_AUTH_NTLMSSP_CHAL structure. -********************************************************************/ - -void init_rpc_auth_ntlmssp_chal(RPC_AUTH_NTLMSSP_CHAL *chl, - uint32 neg_flags, - uint8 challenge[8]) -{ - chl->unknown_1 = 0x0; - chl->unknown_2 = 0x00000028; - chl->neg_flags = neg_flags; /* 0x0082b1 */ - - memcpy(chl->challenge, challenge, sizeof(chl->challenge)); - memset((char *)chl->reserved , '\0', sizeof(chl->reserved)); -} - -/******************************************************************* - Reads or writes an RPC_AUTH_NTLMSSP_CHAL structure. -********************************************************************/ - -BOOL smb_io_rpc_auth_ntlmssp_chal(const char *desc, RPC_AUTH_NTLMSSP_CHAL *chl, prs_struct *ps, int depth) -{ - if (chl == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chal"); - depth++; - - if(!prs_uint32("unknown_1", ps, depth, &chl->unknown_1)) /* 0x0000 0000 */ - return False; - if(!prs_uint32("unknown_2", ps, depth, &chl->unknown_2)) /* 0x0000 b2b3 */ - return False; - if(!prs_uint32("neg_flags", ps, depth, &chl->neg_flags)) /* 0x0000 82b1 */ - return False; - - if(!prs_uint8s (False, "challenge", ps, depth, chl->challenge, sizeof(chl->challenge))) - return False; - if(!prs_uint8s (False, "reserved ", ps, depth, chl->reserved , sizeof(chl->reserved ))) - return False; - - return True; -} - -/******************************************************************* - Inits an RPC_AUTH_NTLMSSP_RESP structure. - - *** lkclXXXX FUDGE! HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) *** - *** lkclXXXX the actual offset is at the start of the auth verifier *** -********************************************************************/ - -void init_rpc_auth_ntlmssp_resp(RPC_AUTH_NTLMSSP_RESP *rsp, - uchar lm_resp[24], uchar nt_resp[24], - const char *domain, const char *user, const char *wks, - uint32 neg_flags) -{ - uint32 offset; - int dom_len = strlen(domain); - int wks_len = strlen(wks); - int usr_len = strlen(user); - int lm_len = (lm_resp != NULL) ? 24 : 0; - int nt_len = (nt_resp != NULL) ? 24 : 0; - - DEBUG(5,("make_rpc_auth_ntlmssp_resp\n")); - -#ifdef DEBUG_PASSWORD - DEBUG(100,("lm_resp\n")); - dump_data(100, (char *)lm_resp, 24); - DEBUG(100,("nt_resp\n")); - dump_data(100, (char *)nt_resp, 24); -#endif - - DEBUG(6,("dom: %s user: %s wks: %s neg_flgs: 0x%x\n", - domain, user, wks, neg_flags)); - - offset = 0x40; - - if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) { - dom_len *= 2; - wks_len *= 2; - usr_len *= 2; - } - - init_str_hdr(&rsp->hdr_domain, dom_len, dom_len, offset); - offset += dom_len; - - init_str_hdr(&rsp->hdr_usr, usr_len, usr_len, offset); - offset += usr_len; - - init_str_hdr(&rsp->hdr_wks, wks_len, wks_len, offset); - offset += wks_len; - - init_str_hdr(&rsp->hdr_lm_resp, lm_len, lm_len, offset); - offset += lm_len; - - init_str_hdr(&rsp->hdr_nt_resp, nt_len, nt_len, offset); - offset += nt_len; - - init_str_hdr(&rsp->hdr_sess_key, 0, 0, offset); - - rsp->neg_flags = neg_flags; - - memcpy(rsp->lm_resp, lm_resp, 24); - memcpy(rsp->nt_resp, nt_resp, 24); - - if (neg_flags & NTLMSSP_NEGOTIATE_UNICODE) { - rpcstr_push(rsp->domain, domain, sizeof(rsp->domain), 0); - rpcstr_push(rsp->user, user, sizeof(rsp->user), 0); - rpcstr_push(rsp->wks, wks, sizeof(rsp->wks), 0); - } else { - fstrcpy(rsp->domain, domain); - fstrcpy(rsp->user, user); - fstrcpy(rsp->wks, wks); - } - - rsp->sess_key[0] = 0; -} - -/******************************************************************* - Reads or writes an RPC_AUTH_NTLMSSP_RESP structure. - - *** lkclXXXX FUDGE! HAVE TO MANUALLY SPECIFY OFFSET HERE (0x1c bytes) *** - *** lkclXXXX the actual offset is at the start of the auth verifier *** -********************************************************************/ - -BOOL smb_io_rpc_auth_ntlmssp_resp(const char *desc, RPC_AUTH_NTLMSSP_RESP *rsp, prs_struct *ps, int depth) -{ - if (rsp == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_resp"); - depth++; - - if (ps->io) { - uint32 old_offset; - - /* reading */ - - ZERO_STRUCTP(rsp); - - if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_domain ", &rsp->hdr_domain, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_user ", &rsp->hdr_usr, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_wks ", &rsp->hdr_wks, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth)) - return False; - - if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */ - return False; - - old_offset = prs_offset(ps); - - if(!prs_set_offset(ps, rsp->hdr_domain.buffer + 0xc)) - return False; - - if(!prs_uint8s(True , "domain ", ps, depth, (uint8*)rsp->domain, - MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain)))) - return False; - - old_offset += rsp->hdr_domain.str_str_len; - - if(!prs_set_offset(ps, rsp->hdr_usr.buffer + 0xc)) - return False; - - if(!prs_uint8s(True , "user ", ps, depth, (uint8*)rsp->user, - MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user)))) - return False; - - old_offset += rsp->hdr_usr.str_str_len; - - if(!prs_set_offset(ps, rsp->hdr_wks.buffer + 0xc)) - return False; - - if(!prs_uint8s(True, "wks ", ps, depth, (uint8*)rsp->wks, - MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks)))) - return False; - - old_offset += rsp->hdr_wks.str_str_len; - - if(!prs_set_offset(ps, rsp->hdr_lm_resp.buffer + 0xc)) - return False; - - if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp, - MIN(rsp->hdr_lm_resp.str_str_len, sizeof(rsp->lm_resp )))) - return False; - - old_offset += rsp->hdr_lm_resp.str_str_len; - - if(!prs_set_offset(ps, rsp->hdr_nt_resp.buffer + 0xc)) - return False; - - if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp, - MIN(rsp->hdr_nt_resp.str_str_len, sizeof(rsp->nt_resp )))) - return False; - - old_offset += rsp->hdr_nt_resp.str_str_len; - - if (rsp->hdr_sess_key.str_str_len != 0) { - - if(!prs_set_offset(ps, rsp->hdr_sess_key.buffer + 0x10)) - return False; - - old_offset += rsp->hdr_sess_key.str_str_len; - - if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key, - MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key)))) - return False; - } - - if(!prs_set_offset(ps, old_offset)) - return False; - } else { - /* writing */ - if(!smb_io_strhdr("hdr_lm_resp ", &rsp->hdr_lm_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_nt_resp ", &rsp->hdr_nt_resp, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_domain ", &rsp->hdr_domain, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_user ", &rsp->hdr_usr, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_wks ", &rsp->hdr_wks, ps, depth)) - return False; - if(!smb_io_strhdr("hdr_sess_key", &rsp->hdr_sess_key, ps, depth)) - return False; - - if(!prs_uint32("neg_flags", ps, depth, &rsp->neg_flags)) /* 0x0000 82b1 */ - return False; - - if(!prs_uint8s(True , "domain ", ps, depth, (uint8*)rsp->domain, - MIN(rsp->hdr_domain.str_str_len, sizeof(rsp->domain)))) - return False; - - if(!prs_uint8s(True , "user ", ps, depth, (uint8*)rsp->user, - MIN(rsp->hdr_usr.str_str_len, sizeof(rsp->user)))) - return False; - - if(!prs_uint8s(True , "wks ", ps, depth, (uint8*)rsp->wks, - MIN(rsp->hdr_wks.str_str_len, sizeof(rsp->wks)))) - return False; - if(!prs_uint8s(False, "lm_resp ", ps, depth, (uint8*)rsp->lm_resp, - MIN(rsp->hdr_lm_resp .str_str_len, sizeof(rsp->lm_resp)))) - return False; - if(!prs_uint8s(False, "nt_resp ", ps, depth, (uint8*)rsp->nt_resp, - MIN(rsp->hdr_nt_resp .str_str_len, sizeof(rsp->nt_resp )))) - return False; - if(!prs_uint8s(False, "sess_key", ps, depth, (uint8*)rsp->sess_key, - MIN(rsp->hdr_sess_key.str_str_len, sizeof(rsp->sess_key)))) - return False; - } - - return True; -} - -/******************************************************************* - Checks an RPC_AUTH_NTLMSSP_CHK structure. -********************************************************************/ - -BOOL rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk, uint32 crc32, uint32 seq_num) -{ - if (chk == NULL) - return False; - - if (chk->crc32 != crc32 || - chk->ver != NTLMSSP_SIGN_VERSION || - chk->seq_num != seq_num) - { - DEBUG(5,("verify failed - crc %x ver %x seq %d\n", - crc32, NTLMSSP_SIGN_VERSION, seq_num)); - DEBUG(5,("verify expect - crc %x ver %x seq %d\n", - chk->crc32, chk->ver, chk->seq_num)); - return False; - } - return True; -} - -/******************************************************************* - Inits an RPC_AUTH_NTLMSSP_CHK structure. -********************************************************************/ - -void init_rpc_auth_ntlmssp_chk(RPC_AUTH_NTLMSSP_CHK *chk, - uint32 ver, uint32 crc32, uint32 seq_num) -{ - chk->ver = ver; - chk->reserved = 0x0; - chk->crc32 = crc32; - chk->seq_num = seq_num; -} - -/******************************************************************* - Reads or writes an RPC_AUTH_NTLMSSP_CHK structure. -********************************************************************/ - -BOOL smb_io_rpc_auth_ntlmssp_chk(const char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_struct *ps, int depth) -{ - if (chk == NULL) - return False; - - prs_debug(ps, depth, desc, "smb_io_rpc_auth_ntlmssp_chk"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ver ", ps, depth, &chk->ver)) - return False; - if(!prs_uint32("reserved", ps, depth, &chk->reserved)) - return False; - if(!prs_uint32("crc32 ", ps, depth, &chk->crc32)) - return False; - if(!prs_uint32("seq_num ", ps, depth, &chk->seq_num)) - return False; - - return True; -} diff --git a/source4/rpc_parse/parse_samr.c b/source4/rpc_parse/parse_samr.c deleted file mode 100644 index d031d13955..0000000000 --- a/source4/rpc_parse/parse_samr.c +++ /dev/null @@ -1,7448 +0,0 @@ -/* - * 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çois Micouleau 1998-2001, - * Copyright (C) Anthony Liguori 2002, - * Copyright (C) Jim McDonough 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" -#include "rpc_parse.h" -#include "nterr.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) -{ - int len_name = strlen(dom_name); - - DEBUG(5, ("init_samr_q_lookup_domain\n")); - - q_u->connect_pol = *pol; - - init_uni_hdr(&q_u->hdr_domain, len_name); - init_unistr2(&q_u->uni_domain, dom_name, len_name); -} - -/******************************************************************* -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_unknown_2d(SAMR_Q_UNKNOWN_2D * q_u, POLICY_HND *dom_pol, DOM_SID *sid) -{ - DEBUG(5, ("samr_init_samr_q_unknown_2d\n")); - - q_u->dom_pol = *dom_pol; - init_dom_sid2(&q_u->sid, sid); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_unknown_2d(const char *desc, SAMR_Q_UNKNOWN_2D * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_unknown_2d"); - 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_unknown_2d(const char *desc, SAMR_R_UNKNOWN_2D * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_unknown_2d"); - 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)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - - return True; -} - - -/******************************************************************* -inits a structure. -********************************************************************/ - -void init_unk_info3(SAM_UNK_INFO_3 *u_3, NTTIME nt_logout) -{ - u_3->logout.low = nt_logout.low; - u_3->logout.high = nt_logout.high; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info3(const char *desc, SAM_UNK_INFO_3 * u_3, - prs_struct *ps, int depth) -{ - if (u_3 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info3"); - depth++; - - if(!smb_io_time("logout", &u_3->logout, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ - -void init_unk_info6(SAM_UNK_INFO_6 * u_6) -{ - u_6->unknown_0 = 0x00000000; - u_6->ptr_0 = 1; - memset(u_6->padding, 0, sizeof(u_6->padding)); /* 12 bytes zeros */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info6(const char *desc, SAM_UNK_INFO_6 * u_6, - prs_struct *ps, int depth) -{ - if (u_6 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info6"); - depth++; - - if(!prs_uint32("unknown_0", ps, depth, &u_6->unknown_0)) /* 0x0000 0000 */ - return False; - if(!prs_uint32("ptr_0", ps, depth, &u_6->ptr_0)) /* pointer to unknown structure */ - return False; - if(!prs_uint8s(False, "padding", ps, depth, u_6->padding, sizeof(u_6->padding))) /* 12 bytes zeros */ - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ - -void init_unk_info7(SAM_UNK_INFO_7 * u_7) -{ - u_7->unknown_0 = 0x0003; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info7(const char *desc, SAM_UNK_INFO_7 * u_7, - prs_struct *ps, int depth) -{ - if (u_7 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info7"); - depth++; - - if(!prs_uint16("unknown_0", ps, depth, &u_7->unknown_0)) /* 0x0003 */ - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ - -void init_unk_info12(SAM_UNK_INFO_12 * u_12, NTTIME nt_lock_duration, NTTIME nt_reset_time, uint16 lockout) -{ - u_12->duration.low = nt_lock_duration.low; - u_12->duration.high = nt_lock_duration.high; - u_12->reset_count.low = nt_reset_time.low; - u_12->reset_count.high = nt_reset_time.high; - - u_12->bad_attempt_lockout = lockout; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12, - prs_struct *ps, int depth) -{ - if (u_12 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info12"); - depth++; - - if(!smb_io_time("duration", &u_12->duration, ps, depth)) - return False; - if(!smb_io_time("reset_count", &u_12->reset_count, ps, depth)) - return False; - if(!prs_uint16("bad_attempt_lockout", ps, depth, &u_12->bad_attempt_lockout)) - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ -void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server) -{ - int len_server = strlen(server); - - init_uni_hdr(&u_5->hdr_server, len_server); - - init_unistr2(&u_5->uni_server, server, len_server); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5, - prs_struct *ps, int depth) -{ - if (u_5 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info5"); - depth++; - - if(!smb_io_unihdr("hdr_server", &u_5->hdr_server, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_server", &u_5->uni_server, u_5->hdr_server.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ -void init_unk_info2(SAM_UNK_INFO_2 * u_2, - const char *domain, const char *server, - uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias) -{ - int len_domain = strlen(domain); - int len_server = strlen(server); - - u_2->unknown_0 = 0x00000000; - u_2->unknown_1 = 0x80000000; - u_2->unknown_2 = 0x00000000; - - u_2->ptr_0 = 1; - init_uni_hdr(&u_2->hdr_domain, len_domain); - init_uni_hdr(&u_2->hdr_server, len_server); - - u_2->seq_num = seq_num; - u_2->unknown_3 = 0x00000000; - - u_2->unknown_4 = 0x00000001; - u_2->unknown_5 = 0x00000003; - u_2->unknown_6 = 0x00000001; - u_2->num_domain_usrs = num_users; - u_2->num_domain_grps = num_groups; - u_2->num_local_grps = num_alias; - - memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */ - - init_unistr2(&u_2->uni_domain, domain, len_domain); - init_unistr2(&u_2->uni_server, server, len_server); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info2(const char *desc, SAM_UNK_INFO_2 * u_2, - prs_struct *ps, int depth) -{ - if (u_2 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info2"); - depth++; - - if(!prs_uint32("unknown_0", ps, depth, &u_2->unknown_0)) /* 0x0000 0000 */ - return False; - if(!prs_uint32("unknown_1", ps, depth, &u_2->unknown_1)) /* 0x8000 0000 */ - return False; - if(!prs_uint32("unknown_2", ps, depth, &u_2->unknown_2)) /* 0x0000 0000 */ - return False; - - if(!prs_uint32("ptr_0", ps, depth, &u_2->ptr_0)) - return False; - if(!smb_io_unihdr("hdr_domain", &u_2->hdr_domain, ps, depth)) - return False; - if(!smb_io_unihdr("hdr_server", &u_2->hdr_server, ps, depth)) - return False; - - /* put all the data in here, at the moment, including what the above - pointer is referring to - */ - - if(!prs_uint32("seq_num ", ps, depth, &u_2->seq_num)) /* 0x0000 0099 or 0x1000 0000 */ - return False; - if(!prs_uint32("unknown_3 ", ps, depth, &u_2->unknown_3)) /* 0x0000 0000 */ - return False; - - if(!prs_uint32("unknown_4 ", ps, depth, &u_2->unknown_4)) /* 0x0000 0001 */ - return False; - if(!prs_uint32("unknown_5 ", ps, depth, &u_2->unknown_5)) /* 0x0000 0003 */ - return False; - if(!prs_uint32("unknown_6 ", ps, depth, &u_2->unknown_6)) /* 0x0000 0001 */ - return False; - if(!prs_uint32("num_domain_usrs ", ps, depth, &u_2->num_domain_usrs)) - return False; - if(!prs_uint32("num_domain_grps", ps, depth, &u_2->num_domain_grps)) - return False; - if(!prs_uint32("num_local_grps", ps, depth, &u_2->num_local_grps)) - return False; - - if (u_2->ptr_0) { - /* this was originally marked as 'padding'. It isn't - padding, it is some sort of optional 12 byte - structure. When it is present it contains zeros - !? */ - if(!prs_uint8s(False, "unknown", ps, depth, u_2->padding,sizeof(u_2->padding))) - return False; - } - - if(!smb_io_unistr2("uni_domain", &u_2->uni_domain, u_2->hdr_domain.buffer, ps, depth)) - return False; - if(!smb_io_unistr2("uni_server", &u_2->uni_server, u_2->hdr_server.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a structure. -********************************************************************/ - -void init_unk_info1(SAM_UNK_INFO_1 *u_1, uint16 min_pass_len, uint16 pass_hist, - uint32 flag, NTTIME nt_expire, NTTIME nt_min_age) -{ - u_1->min_length_password = min_pass_len; - u_1->password_history = pass_hist; - u_1->flag = flag; - - /* password never expire */ - u_1->expire.high = nt_expire.high; - u_1->expire.low = nt_expire.low; - - /* can change the password now */ - u_1->min_passwordage.high = nt_min_age.high; - u_1->min_passwordage.low = nt_min_age.low; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_unk_info1(const char *desc, SAM_UNK_INFO_1 * u_1, - prs_struct *ps, int depth) -{ - if (u_1 == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_unk_info1"); - depth++; - - if(!prs_uint16("min_length_password", ps, depth, &u_1->min_length_password)) - return False; - if(!prs_uint16("password_history", ps, depth, &u_1->password_history)) - return False; - if(!prs_uint32("flag", ps, depth, &u_1->flag)) - return False; - if(!smb_io_time("expire", &u_1->expire, ps, depth)) - return False; - if(!smb_io_time("min_passwordage", &u_1->min_passwordage, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_DOMAIN_INFO structure. -********************************************************************/ - -void init_samr_r_query_dom_info(SAMR_R_QUERY_DOMAIN_INFO * r_u, - uint16 switch_value, SAM_UNK_CTR * ctr, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_dom_info\n")); - - r_u->ptr_0 = 0; - r_u->switch_value = 0; - r_u->status = status; /* return status */ - - if (NT_STATUS_IS_OK(status)) { - r_u->switch_value = switch_value; - r_u->ptr_0 = 1; - r_u->ctr = ctr; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_dom_info(const char *desc, SAMR_R_QUERY_DOMAIN_INFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_dom_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) - return False; - - if (r_u->ptr_0 != 0 && r_u->ctr != NULL) { - if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) - return False; - if(!prs_align(ps)) - return False; - - switch (r_u->switch_value) { - case 0x0c: - if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth)) - return False; - break; - case 0x07: - if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth)) - return False; - break; - case 0x06: - if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth)) - return False; - break; - case 0x05: - if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth)) - return False; - break; - case 0x03: - if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth)) - return False; - break; - case 0x02: - if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth)) - return False; - break; - case 0x01: - if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth)) - return False; - break; - default: - DEBUG(0, ("samr_io_r_query_dom_info: unknown switch level 0x%x\n", - r_u->switch_value)); - r_u->status = NT_STATUS_INVALID_INFO_CLASS; - 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 SAMR_R_SET_SEC_OBJ structure. -********************************************************************/ - -BOOL samr_io_r_set_sec_obj(const char *desc, SAMR_R_SET_SEC_OBJ * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_set_sec_obj"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a SAMR_R_QUERY_SEC_OBJ structure. -********************************************************************/ - -BOOL samr_io_r_query_sec_obj(const char *desc, SAMR_R_QUERY_SEC_OBJ * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_sec_obj"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - if (r_u->ptr != 0) { - if(!sec_io_desc_buf("sec", &r_u->buf, ps, depth)) - return False; - } - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a SAM_STR1 structure. -********************************************************************/ - -static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf, - uint32 name_buf, uint32 desc_buf, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_str1"); - depth++; - - if(!prs_align(ps)) - return False; - if (!smb_io_unistr2("name", &sam->uni_acct_name, acct_buf, ps, depth)) - return False; - - if (!smb_io_unistr2("desc", &sam->uni_acct_desc, desc_buf, ps, depth)) - return False; - - if (!smb_io_unistr2("full", &sam->uni_full_name, name_buf, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY1 structure. -********************************************************************/ - -static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx, - uint32 len_sam_name, uint32 len_sam_full, - uint32 len_sam_desc, uint32 rid_user, - uint16 acb_info) -{ - DEBUG(5, ("init_sam_entry1\n")); - - ZERO_STRUCTP(sam); - - sam->user_idx = user_idx; - sam->rid_user = rid_user; - sam->acb_info = acb_info; - - init_uni_hdr(&sam->hdr_acct_name, len_sam_name); - init_uni_hdr(&sam->hdr_user_name, len_sam_full); - init_uni_hdr(&sam->hdr_user_desc, len_sam_desc); -} - -/******************************************************************* -reads or writes a SAM_ENTRY1 structure. -********************************************************************/ - -static BOOL sam_io_sam_entry1(const char *desc, SAM_ENTRY1 * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx)) - return False; - - if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user)) - return False; - if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info)) - return False; - - if(!prs_align(ps)) - return False; - - if (!smb_io_unihdr("hdr_acct_name", &sam->hdr_acct_name, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_user_desc", &sam->hdr_user_desc, ps, depth)) - return False; - if (!smb_io_unihdr("hdr_user_name", &sam->hdr_user_name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a SAM_STR2 structure. -********************************************************************/ - -static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf, - uint32 desc_buf, prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_str2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_srv_name", &sam->uni_srv_name, acct_buf, ps, depth)) /* account name unicode string */ - return False; - if(!smb_io_unistr2("uni_srv_desc", &sam->uni_srv_desc, desc_buf, ps, depth)) /* account desc unicode string */ - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY2 structure. -********************************************************************/ -static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx, - uint32 len_sam_name, uint32 len_sam_desc, - uint32 rid_user, uint16 acb_info) -{ - DEBUG(5, ("init_sam_entry2\n")); - - sam->user_idx = user_idx; - sam->rid_user = rid_user; - sam->acb_info = acb_info; - - init_uni_hdr(&sam->hdr_srv_name, len_sam_name); - init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc); -} - -/******************************************************************* -reads or writes a SAM_ENTRY2 structure. -********************************************************************/ - -static BOOL sam_io_sam_entry2(const char *desc, SAM_ENTRY2 * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("user_idx ", ps, depth, &sam->user_idx)) - return False; - - if(!prs_uint32("rid_user ", ps, depth, &sam->rid_user)) - return False; - if(!prs_uint16("acb_info ", ps, depth, &sam->acb_info)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("unihdr", &sam->hdr_srv_name, ps, depth)) /* account name unicode string header */ - return False; - if(!smb_io_unihdr("unihdr", &sam->hdr_srv_desc, ps, depth)) /* account name unicode string header */ - return False; - - return True; -} - -/******************************************************************* -reads or writes a SAM_STR3 structure. -********************************************************************/ - -static BOOL sam_io_sam_str3(const char *desc, SAM_STR3 * sam, uint32 acct_buf, - uint32 desc_buf, prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_str3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_grp_name", &sam->uni_grp_name, acct_buf, ps, depth)) /* account name unicode string */ - return False; - if(!smb_io_unistr2("uni_grp_desc", &sam->uni_grp_desc, desc_buf, ps, depth)) /* account desc unicode string */ - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY3 structure. -********************************************************************/ - -static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx, - uint32 len_grp_name, uint32 len_grp_desc, - uint32 rid_grp) -{ - DEBUG(5, ("init_sam_entry3\n")); - - sam->grp_idx = grp_idx; - sam->rid_grp = rid_grp; - sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */ - - init_uni_hdr(&sam->hdr_grp_name, len_grp_name); - init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc); -} - -/******************************************************************* -reads or writes a SAM_ENTRY3 structure. -********************************************************************/ - -static BOOL sam_io_sam_entry3(const char *desc, SAM_ENTRY3 * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx)) - return False; - - if(!prs_uint32("rid_grp", ps, depth, &sam->rid_grp)) - return False; - if(!prs_uint32("attr ", ps, depth, &sam->attr)) - return False; - - if(!smb_io_unihdr("unihdr", &sam->hdr_grp_name, ps, depth)) /* account name unicode string header */ - return False; - if(!smb_io_unihdr("unihdr", &sam->hdr_grp_desc, ps, depth)) /* account name unicode string header */ - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY4 structure. -********************************************************************/ - -static void init_sam_entry4(SAM_ENTRY4 * sam, uint32 user_idx, - uint32 len_acct_name) -{ - DEBUG(5, ("init_sam_entry4\n")); - - sam->user_idx = user_idx; - init_str_hdr(&sam->hdr_acct_name, len_acct_name+1, len_acct_name, len_acct_name != 0); -} - -/******************************************************************* -reads or writes a SAM_ENTRY4 structure. -********************************************************************/ - -static BOOL sam_io_sam_entry4(const char *desc, SAM_ENTRY4 * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("user_idx", ps, depth, &sam->user_idx)) - return False; - if(!smb_io_strhdr("strhdr", &sam->hdr_acct_name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY5 structure. -********************************************************************/ - -static void init_sam_entry5(SAM_ENTRY5 * sam, uint32 grp_idx, - uint32 len_grp_name) -{ - DEBUG(5, ("init_sam_entry5\n")); - - sam->grp_idx = grp_idx; - init_str_hdr(&sam->hdr_grp_name, len_grp_name, len_grp_name, - len_grp_name != 0); -} - -/******************************************************************* -reads or writes a SAM_ENTRY5 structure. -********************************************************************/ - -static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry5"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("grp_idx", ps, depth, &sam->grp_idx)) - return False; - if(!smb_io_strhdr("strhdr", &sam->hdr_grp_name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_ENTRY structure. -********************************************************************/ - -void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid) -{ - DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid)); - - sam->rid = rid; - init_uni_hdr(&sam->hdr_name, len_sam_name); -} - -/******************************************************************* -reads or writes a SAM_ENTRY structure. -********************************************************************/ - -static BOOL sam_io_sam_entry(const char *desc, SAM_ENTRY * sam, - prs_struct *ps, int depth) -{ - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_entry"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("rid", ps, depth, &sam->rid)) - return False; - if(!smb_io_unihdr("unihdr", &sam->hdr_name, ps, depth)) /* account name unicode string header */ - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ENUM_DOM_USERS structure. -********************************************************************/ - -void init_samr_q_enum_dom_users(SAMR_Q_ENUM_DOM_USERS * q_e, POLICY_HND *pol, - uint32 start_idx, - uint16 acb_mask, uint16 unk_1, uint32 size) -{ - DEBUG(5, ("init_samr_q_enum_dom_users\n")); - - q_e->pol = *pol; - - q_e->start_idx = start_idx; /* zero indicates lots */ - q_e->acb_mask = acb_mask; - q_e->unknown_1 = unk_1; - q_e->max_size = size; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_enum_dom_users(const char *desc, SAMR_Q_ENUM_DOM_USERS * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_enum_dom_users"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) - return False; - if(!prs_uint16("acb_mask ", ps, depth, &q_e->acb_mask)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &q_e->unknown_1)) - return False; - - if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) - return False; - - return True; -} - - -/******************************************************************* -inits a SAMR_R_ENUM_DOM_USERS structure. -********************************************************************/ - -void init_samr_r_enum_dom_users(SAMR_R_ENUM_DOM_USERS * r_u, - uint32 next_idx, uint32 num_sam_entries) -{ - DEBUG(5, ("init_samr_r_enum_dom_users\n")); - - r_u->next_idx = next_idx; - - if (num_sam_entries != 0) { - r_u->ptr_entries1 = 1; - r_u->ptr_entries2 = 1; - r_u->num_entries2 = num_sam_entries; - r_u->num_entries3 = num_sam_entries; - - r_u->num_entries4 = num_sam_entries; - } else { - r_u->ptr_entries1 = 0; - r_u->num_entries2 = num_sam_entries; - r_u->ptr_entries2 = 1; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_enum_dom_users(const char *desc, SAMR_R_ENUM_DOM_USERS * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_enum_dom_users"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) - return False; - if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) - return False; - - if (r_u->ptr_entries1 != 0) { - if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) - return False; - if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) - return False; - if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) - return False; - - if (UNMARSHALLING(ps) && (r_u->num_entries2 != 0)) { - r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2); - r_u->uni_acct_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2); - } - - if ((r_u->sam == NULL || r_u->uni_acct_name == NULL) && r_u->num_entries2 != 0) { - DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_USERS\n")); - r_u->num_entries4 = 0; - r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!smb_io_unistr2("", &r_u->uni_acct_name[i],r_u->sam[i].hdr_name.buffer, ps,depth)) - return False; - } - - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_DISPINFO structure. -********************************************************************/ - -void init_samr_q_query_dispinfo(SAMR_Q_QUERY_DISPINFO * q_e, POLICY_HND *pol, - uint16 switch_level, uint32 start_idx, - uint32 max_entries, uint32 max_size) -{ - DEBUG(5, ("init_samr_q_query_dispinfo\n")); - - q_e->domain_pol = *pol; - - q_e->switch_level = switch_level; - - q_e->start_idx = start_idx; - q_e->max_entries = max_entries; - q_e->max_size = max_size; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth)) - return False; - - if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("start_idx ", ps, depth, &q_e->start_idx)) - return False; - if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries)) - return False; - if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_DISPINFO_1 structure. -********************************************************************/ - -NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_entries, - uint32 start_idx, DISP_USER_INFO *disp_user_info, - DOM_SID *domain_sid) -{ - uint32 len_sam_name, len_sam_full, len_sam_desc; - uint32 i; - - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - - DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries)); - - if (num_entries==0) - return NT_STATUS_OK; - - sam->sam=(SAM_ENTRY1 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY1)); - if (!sam->sam) - return NT_STATUS_NO_MEMORY; - - sam->str=(SAM_STR1 *)talloc(ctx, num_entries*sizeof(SAM_STR1)); - if (!sam->str) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); - - for (i = 0; i < num_entries ; i++) { - const char *username; - const char *fullname; - const char *acct_desc; - uint32 user_rid; - const DOM_SID *user_sid; - fstring user_sid_string, domain_sid_string; - - DEBUG(11, ("init_sam_dispinfo_1: entry: %d\n",i)); - - pwd=disp_user_info[i+start_idx].sam; - - username = pdb_get_username(pwd); - fullname = pdb_get_fullname(pwd); - acct_desc = pdb_get_acct_desc(pwd); - - if (!username) - username = ""; - - if (!fullname) - fullname = ""; - - if (!acct_desc) - acct_desc = ""; - - user_sid = pdb_get_user_sid(pwd); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - DEBUG(0, ("init_sam_dispinfo_1: User %s has SID %s, which conflicts with " - "the domain sid %s. Failing operation.\n", - username, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - len_sam_name = strlen(username); - len_sam_full = strlen(fullname); - len_sam_desc = strlen(acct_desc); - - init_sam_entry1(&sam->sam[i], start_idx + i + 1, - len_sam_name, len_sam_full, len_sam_desc, - user_rid, pdb_get_acct_ctrl(pwd)); - - ZERO_STRUCTP(&sam->str[i].uni_acct_name); - ZERO_STRUCTP(&sam->str[i].uni_full_name); - ZERO_STRUCTP(&sam->str[i].uni_acct_desc); - - init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name); - init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full); - init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc); - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam, - uint32 num_entries, - prs_struct *ps, int depth) -{ - uint32 i; - - prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if (UNMARSHALLING(ps) && num_entries > 0) { - - if ((sam->sam = (SAM_ENTRY1 *) - prs_alloc_mem(ps, sizeof(SAM_ENTRY1) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_ENTRY1\n")); - return False; - } - - if ((sam->str = (SAM_STR1 *) - prs_alloc_mem(ps, sizeof(SAM_STR1) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_STR1\n")); - return False; - } - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_str1("", &sam->str[i], - sam->sam[i].hdr_acct_name.buffer, - sam->sam[i].hdr_user_name.buffer, - sam->sam[i].hdr_user_desc.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAM_DISPINFO_2 structure. -********************************************************************/ - -NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_entries, - uint32 start_idx, DISP_USER_INFO *disp_user_info, - DOM_SID *domain_sid ) -{ - uint32 len_sam_name, len_sam_desc; - uint32 i; - - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - - DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries)); - - if (num_entries==0) - return NT_STATUS_OK; - - if (!(sam->sam=(SAM_ENTRY2 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY2)))) - return NT_STATUS_NO_MEMORY; - - if (!(sam->str=(SAM_STR2 *)talloc(ctx, num_entries*sizeof(SAM_STR2)))) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); - - for (i = 0; i < num_entries; i++) { - uint32 user_rid; - const DOM_SID *user_sid; - const char *username; - const char *acct_desc; - fstring user_sid_string, domain_sid_string; - - DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); - pwd=disp_user_info[i+start_idx].sam; - - username = pdb_get_username(pwd); - acct_desc = pdb_get_acct_desc(pwd); - user_sid = pdb_get_user_sid(pwd); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - DEBUG(0, ("init_sam_dispinfo_2: User %s has SID %s, which conflicts with " - "the domain sid %s. Failing operation.\n", - username, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - len_sam_name = strlen(username); - len_sam_desc = strlen(acct_desc); - - init_sam_entry2(&sam->sam[i], start_idx + i + 1, - len_sam_name, len_sam_desc, - user_rid, pdb_get_acct_ctrl(pwd)); - - ZERO_STRUCTP(&sam->str[i].uni_srv_name); - ZERO_STRUCTP(&sam->str[i].uni_srv_desc); - - init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name); - init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc); - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam, - uint32 num_entries, - prs_struct *ps, int depth) -{ - uint32 i; - - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if (UNMARSHALLING(ps) && num_entries > 0) { - - if ((sam->sam = (SAM_ENTRY2 *) - prs_alloc_mem(ps, sizeof(SAM_ENTRY2) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_ENTRY2\n")); - return False; - } - - if ((sam->str = (SAM_STR2 *) - prs_alloc_mem(ps, sizeof(SAM_STR2) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_STR2\n")); - return False; - } - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_str2("", &sam->str[i], - sam->sam[i].hdr_srv_name.buffer, - sam->sam[i].hdr_srv_desc.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAM_DISPINFO_3 structure. -********************************************************************/ - -NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries, - uint32 start_idx, DISP_GROUP_INFO *disp_group_info) -{ - uint32 len_sam_name, len_sam_desc; - uint32 i; - - ZERO_STRUCTP(sam); - - DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries)); - - if (num_entries==0) - return NT_STATUS_OK; - - if (!(sam->sam=(SAM_ENTRY3 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY3)))) - return NT_STATUS_NO_MEMORY; - - if (!(sam->str=(SAM_STR3 *)talloc(ctx, num_entries*sizeof(SAM_STR3)))) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); - - for (i = 0; i < num_entries; i++) { - DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp; - - DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i)); - - len_sam_name = strlen(grp->name); - len_sam_desc = strlen(grp->comment); - - init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid); - - init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name); - init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc); - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam, - uint32 num_entries, - prs_struct *ps, int depth) -{ - uint32 i; - - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if (UNMARSHALLING(ps) && num_entries > 0) { - - if ((sam->sam = (SAM_ENTRY3 *) - prs_alloc_mem(ps, sizeof(SAM_ENTRY3) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_ENTRY3\n")); - return False; - } - - if ((sam->str = (SAM_STR3 *) - prs_alloc_mem(ps, sizeof(SAM_STR3) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_STR3\n")); - return False; - } - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_str3("", &sam->str[i], - sam->sam[i].hdr_grp_name.buffer, - sam->sam[i].hdr_grp_desc.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAM_DISPINFO_4 structure. -********************************************************************/ - -NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 *sam, uint32 num_entries, - uint32 start_idx, DISP_USER_INFO *disp_user_info) -{ - uint32 len_sam_name; - uint32 i; - - SAM_ACCOUNT *pwd = NULL; - ZERO_STRUCTP(sam); - - DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries)); - - if (num_entries==0) - return NT_STATUS_OK; - - if (!(sam->sam=(SAM_ENTRY4 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY4)))) - return NT_STATUS_NO_MEMORY; - - if (!(sam->str=(SAM_STR4 *)talloc(ctx, num_entries*sizeof(SAM_STR4)))) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); - - for (i = 0; i < num_entries; i++) { - DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i)); - pwd=disp_user_info[i+start_idx].sam; - - len_sam_name = strlen(pdb_get_username(pwd)); - - init_sam_entry4(&sam->sam[i], start_idx + i + 1, len_sam_name); - - init_string2(&sam->str[i].acct_name, pdb_get_username(pwd), len_sam_name+1, len_sam_name); - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam, - uint32 num_entries, - prs_struct *ps, int depth) -{ - uint32 i; - - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4"); - depth++; - - if(!prs_align(ps)) - return False; - - if (UNMARSHALLING(ps) && num_entries > 0) { - - if ((sam->sam = (SAM_ENTRY4 *) - prs_alloc_mem(ps, sizeof(SAM_ENTRY4) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_ENTRY4\n")); - return False; - } - - if ((sam->str = (SAM_STR4 *) - prs_alloc_mem(ps, sizeof(SAM_STR4) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_STR4\n")); - return False; - } - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!smb_io_string2("acct_name", &sam->str[i].acct_name, - sam->sam[i].hdr_acct_name.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAM_DISPINFO_5 structure. -********************************************************************/ - -NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 *sam, uint32 num_entries, - uint32 start_idx, DISP_GROUP_INFO *disp_group_info) -{ - uint32 len_sam_name; - uint32 i; - - ZERO_STRUCTP(sam); - - DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries)); - - if (num_entries==0) - return NT_STATUS_OK; - - if (!(sam->sam=(SAM_ENTRY5 *)talloc(ctx, num_entries*sizeof(SAM_ENTRY5)))) - return NT_STATUS_NO_MEMORY; - - if (!(sam->str=(SAM_STR5 *)talloc(ctx, num_entries*sizeof(SAM_STR5)))) - return NT_STATUS_NO_MEMORY; - - ZERO_STRUCTP(sam->sam); - ZERO_STRUCTP(sam->str); - - for (i = 0; i < num_entries; i++) { - DOMAIN_GRP *grp = disp_group_info[i+start_idx].grp; - - DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i)); - - len_sam_name = strlen(grp->name); - - init_sam_entry5(&sam->sam[i], start_idx + i + 1, len_sam_name); - init_string2(&sam->str[i].grp_name, grp->name, len_sam_name+1, len_sam_name); - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam, - uint32 num_entries, - prs_struct *ps, int depth) -{ - uint32 i; - - if (sam == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5"); - depth++; - - if(!prs_align(ps)) - return False; - - if (UNMARSHALLING(ps) && num_entries > 0) { - - if ((sam->sam = (SAM_ENTRY5 *) - prs_alloc_mem(ps, sizeof(SAM_ENTRY5) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_ENTRY5\n")); - return False; - } - - if ((sam->str = (SAM_STR5 *) - prs_alloc_mem(ps, sizeof(SAM_STR5) * - num_entries)) == NULL) { - DEBUG(0, ("out of memory allocating SAM_STR5\n")); - return False; - } - } - - for (i = 0; i < num_entries; i++) { - if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!smb_io_string2("grp_name", &sam->str[i].grp_name, - sam->sam[i].hdr_grp_name.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_DISPINFO structure. -********************************************************************/ - -void init_samr_r_query_dispinfo(SAMR_R_QUERY_DISPINFO * r_u, - uint32 num_entries, uint32 total_size, uint32 data_size, - uint16 switch_level, SAM_DISPINFO_CTR * ctr, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_dispinfo: level %d\n", switch_level)); - - r_u->total_size = total_size; - - r_u->data_size = data_size; - - r_u->switch_level = switch_level; - r_u->num_entries = num_entries; - - if (num_entries==0) - r_u->ptr_entries = 0; - else - r_u->ptr_entries = 1; - - r_u->num_entries2 = num_entries; - r_u->ctr = ctr; - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_dispinfo(const char *desc, SAMR_R_QUERY_DISPINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_dispinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("total_size ", ps, depth, &r_u->total_size)) - return False; - if(!prs_uint32("data_size ", ps, depth, &r_u->data_size)) - return False; - if(!prs_uint16("switch_level", ps, depth, &r_u->switch_level)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) - return False; - if(!prs_uint32("ptr_entries ", ps, depth, &r_u->ptr_entries)) - return False; - - if (r_u->ptr_entries==0) { - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; - } - - if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) - return False; - - switch (r_u->switch_level) { - case 0x1: - if(!sam_io_sam_dispinfo_1("users", r_u->ctr->sam.info1, - r_u->num_entries, ps, depth)) - return False; - break; - case 0x2: - if(!sam_io_sam_dispinfo_2("servers", r_u->ctr->sam.info2, - r_u->num_entries, ps, depth)) - return False; - break; - case 0x3: - if(!sam_io_sam_dispinfo_3("groups", r_u->ctr->sam.info3, - r_u->num_entries, ps, depth)) - return False; - break; - case 0x4: - if(!sam_io_sam_dispinfo_4("user list", - r_u->ctr->sam.info4, - r_u->num_entries, ps, depth)) - return False; - break; - case 0x5: - if(!sam_io_sam_dispinfo_5("group list", - r_u->ctr->sam.info5, - r_u->num_entries, ps, depth)) - return False; - break; - default: - DEBUG(0,("samr_io_r_query_dispinfo: unknown switch value\n")); - break; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_OPEN_GROUP structure. -********************************************************************/ - -void init_samr_q_open_group(SAMR_Q_OPEN_GROUP * q_c, - POLICY_HND *hnd, - uint32 access_mask, uint32 rid) -{ - DEBUG(5, ("init_samr_q_open_group\n")); - - q_c->domain_pol = *hnd; - q_c->access_mask = access_mask; - q_c->rid_group = rid; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_open_group(const char *desc, SAMR_Q_OPEN_GROUP * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_open_group"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) - return False; - - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - if(!prs_uint32("rid_group", ps, depth, &q_u->rid_group)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_open_group(const char *desc, SAMR_R_OPEN_GROUP * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_open_group"); - 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 GROUP_INFO1 structure. -********************************************************************/ - -void init_samr_group_info1(GROUP_INFO1 * gr1, - char *acct_name, char *acct_desc, - uint32 num_members) -{ - int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0; - int acct_len = acct_name != NULL ? strlen(acct_name) : 0; - - DEBUG(5, ("init_samr_group_info1\n")); - - init_uni_hdr(&gr1->hdr_acct_name, acct_len); - - gr1->unknown_1 = 0x3; - gr1->num_members = num_members; - - init_uni_hdr(&gr1->hdr_acct_desc, desc_len); - - init_unistr2(&gr1->uni_acct_name, acct_name, acct_len); - init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_group_info1(const char *desc, GROUP_INFO1 * gr1, - prs_struct *ps, int depth) -{ - if (gr1 == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_group_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr_acct_name", &gr1->hdr_acct_name, ps, depth)) - return False; - - if(!prs_uint32("unknown_1", ps, depth, &gr1->unknown_1)) - return False; - if(!prs_uint32("num_members", ps, depth, &gr1->num_members)) - return False; - - if(!smb_io_unihdr("hdr_acct_desc", &gr1->hdr_acct_desc, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_acct_name", &gr1->uni_acct_name, - gr1->hdr_acct_name.buffer, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_acct_desc", &gr1->uni_acct_desc, - gr1->hdr_acct_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a GROUP_INFO3 structure. -********************************************************************/ - -void init_samr_group_info3(GROUP_INFO3 *gr3) -{ - DEBUG(5, ("init_samr_group_info3\n")); - - gr3->unknown_1 = 0x3; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_group_info3(const char *desc, GROUP_INFO3 *gr3, prs_struct *ps, int depth) -{ - if (gr3 == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_group_info3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("unknown_1", ps, depth, &gr3->unknown_1)) - return False; - - return True; -} - -/******************************************************************* -inits a GROUP_INFO4 structure. -********************************************************************/ - -void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc) -{ - int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0; - - DEBUG(5, ("init_samr_group_info4\n")); - - init_uni_hdr(&gr4->hdr_acct_desc, acct_len); - init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_group_info4(const char *desc, GROUP_INFO4 * gr4, - prs_struct *ps, int depth) -{ - if (gr4 == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_group_info4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr_acct_desc", &gr4->hdr_acct_desc, ps, depth)) - return False; - if(!smb_io_unistr2("uni_acct_desc", &gr4->uni_acct_desc, - gr4->hdr_acct_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL samr_group_info_ctr(const char *desc, GROUP_INFO_CTR **ctr, - prs_struct *ps, int depth) -{ - if (UNMARSHALLING(ps)) - *ctr = (GROUP_INFO_CTR *)prs_alloc_mem(ps,sizeof(GROUP_INFO_CTR)); - - if (*ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_group_info_ctr"); - depth++; - - if(!prs_uint16("switch_value1", ps, depth, &(*ctr)->switch_value1)) - return False; - - switch ((*ctr)->switch_value1) { - case 1: - if(!samr_io_group_info1("group_info1", &(*ctr)->group.info1, ps, depth)) - return False; - break; - case 3: - if(!samr_io_group_info3("group_info3", &(*ctr)->group.info3, ps, depth)) - return False; - break; - case 4: - if(!samr_io_group_info4("group_info4", &(*ctr)->group.info4, ps, depth)) - return False; - break; - default: - DEBUG(0,("samr_group_info_ctr: unsupported switch level\n")); - break; - } - - return True; -} - -/******************************************************************* -inits a SAMR_Q_CREATE_DOM_GROUP structure. -********************************************************************/ - -void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e, - POLICY_HND *pol, char *acct_desc, - uint32 access_mask) -{ - int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0; - - DEBUG(5, ("init_samr_q_create_dom_group\n")); - - q_e->pol = *pol; - - init_uni_hdr(&q_e->hdr_acct_desc, acct_len); - init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len); - - q_e->access_mask = access_mask; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_create_dom_group(const char *desc, SAMR_Q_CREATE_DOM_GROUP * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_create_dom_group"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_acct_desc", &q_e->hdr_acct_desc, ps, depth)) - return False; - if(!smb_io_unistr2("uni_acct_desc", &q_e->uni_acct_desc, - q_e->hdr_acct_desc.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("access", ps, depth, &q_e->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_create_dom_group(const char *desc, SAMR_R_CREATE_DOM_GROUP * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_create_dom_group"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &r_u->pol, ps, depth)) - return False; - - if(!prs_uint32("rid ", ps, depth, &r_u->rid)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_DELETE_DOM_GROUP structure. -********************************************************************/ - -void init_samr_q_delete_dom_group(SAMR_Q_DELETE_DOM_GROUP * q_c, - POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_delete_dom_group\n")); - - q_c->group_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_delete_dom_group(const char *desc, SAMR_Q_DELETE_DOM_GROUP * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_delete_dom_group"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_delete_dom_group(const char *desc, SAMR_R_DELETE_DOM_GROUP * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_delete_dom_group"); - 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_DEL_GROUPMEM structure. -********************************************************************/ - -void init_samr_q_del_groupmem(SAMR_Q_DEL_GROUPMEM * q_e, - POLICY_HND *pol, uint32 rid) -{ - DEBUG(5, ("init_samr_q_del_groupmem\n")); - - q_e->pol = *pol; - q_e->rid = rid; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_del_groupmem(const char *desc, SAMR_Q_DEL_GROUPMEM * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_del_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("rid", ps, depth, &q_e->rid)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_DEL_GROUPMEM structure. -********************************************************************/ - -void init_samr_r_del_groupmem(SAMR_R_DEL_GROUPMEM * r_u, POLICY_HND *pol, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_del_groupmem\n")); - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_del_groupmem(const char *desc, SAMR_R_DEL_GROUPMEM * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_del_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ADD_GROUPMEM structure. -********************************************************************/ - -void init_samr_q_add_groupmem(SAMR_Q_ADD_GROUPMEM * q_e, - POLICY_HND *pol, uint32 rid) -{ - DEBUG(5, ("init_samr_q_add_groupmem\n")); - - q_e->pol = *pol; - q_e->rid = rid; - q_e->unknown = 0x0005; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_add_groupmem(const char *desc, SAMR_Q_ADD_GROUPMEM * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_add_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("rid ", ps, depth, &q_e->rid)) - return False; - if(!prs_uint32("unknown", ps, depth, &q_e->unknown)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_ADD_GROUPMEM structure. -********************************************************************/ - -void init_samr_r_add_groupmem(SAMR_R_ADD_GROUPMEM * r_u, POLICY_HND *pol, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_add_groupmem\n")); - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_add_groupmem(const char *desc, SAMR_R_ADD_GROUPMEM * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_add_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_SET_GROUPINFO structure. -********************************************************************/ - -void init_samr_q_set_groupinfo(SAMR_Q_SET_GROUPINFO * q_e, - POLICY_HND *pol, GROUP_INFO_CTR * ctr) -{ - DEBUG(5, ("init_samr_q_set_groupinfo\n")); - - q_e->pol = *pol; - q_e->ctr = ctr; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_set_groupinfo(const char *desc, SAMR_Q_SET_GROUPINFO * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_set_groupinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!samr_group_info_ctr("ctr", &q_e->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_SET_GROUPINFO structure. -********************************************************************/ - -void init_samr_r_set_groupinfo(SAMR_R_SET_GROUPINFO * r_u, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_set_groupinfo\n")); - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_set_groupinfo(const char *desc, SAMR_R_SET_GROUPINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_set_groupinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_GROUPINFO structure. -********************************************************************/ - -void init_samr_q_query_groupinfo(SAMR_Q_QUERY_GROUPINFO * q_e, - POLICY_HND *pol, uint16 switch_level) -{ - DEBUG(5, ("init_samr_q_query_groupinfo\n")); - - q_e->pol = *pol; - - q_e->switch_level = switch_level; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_groupinfo(const char *desc, SAMR_Q_QUERY_GROUPINFO * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_groupinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_GROUPINFO structure. -********************************************************************/ - -void init_samr_r_query_groupinfo(SAMR_R_QUERY_GROUPINFO * r_u, - GROUP_INFO_CTR * ctr, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_groupinfo\n")); - - r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0; - r_u->ctr = ctr; - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_groupinfo(const char *desc, SAMR_R_QUERY_GROUPINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_groupinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - if(!samr_group_info_ctr("ctr", &r_u->ctr, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_GROUPMEM structure. -********************************************************************/ - -void init_samr_q_query_groupmem(SAMR_Q_QUERY_GROUPMEM * q_c, POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_query_groupmem\n")); - - q_c->group_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_groupmem(const char *desc, SAMR_Q_QUERY_GROUPMEM * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("group_pol", &q_u->group_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_GROUPMEM structure. -********************************************************************/ - -void init_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM * r_u, - uint32 num_entries, uint32 *rid, - uint32 *attr, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_groupmem\n")); - - if (NT_STATUS_IS_OK(status)) { - r_u->ptr = 1; - r_u->num_entries = num_entries; - - r_u->ptr_attrs = attr != NULL ? 1 : 0; - r_u->ptr_rids = rid != NULL ? 1 : 0; - - r_u->num_rids = num_entries; - r_u->rid = rid; - - r_u->num_attrs = num_entries; - r_u->attr = attr; - } else { - r_u->ptr = 0; - r_u->num_entries = 0; - } - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_groupmem(const char *desc, SAMR_R_QUERY_GROUPMEM * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) - return False; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(r_u); - - prs_debug(ps, depth, desc, "samr_io_r_query_groupmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) - return False; - - if (r_u->ptr != 0) { - if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids)) - return False; - if(!prs_uint32("ptr_attrs", ps, depth, &r_u->ptr_attrs)) - return False; - - if (r_u->ptr_rids != 0) { - if(!prs_uint32("num_rids", ps, depth, &r_u->num_rids)) - return False; - if (UNMARSHALLING(ps) && r_u->num_rids != 0) { - r_u->rid = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->rid[0])*r_u->num_rids); - if (r_u->rid == NULL) - return False; - } - - for (i = 0; i < r_u->num_rids; i++) { - if(!prs_uint32("", ps, depth, &r_u->rid[i])) - return False; - } - } - - if (r_u->ptr_attrs != 0) { - if(!prs_uint32("num_attrs", ps, depth, &r_u->num_attrs)) - return False; - - if (UNMARSHALLING(ps) && r_u->num_attrs != 0) { - r_u->attr = (uint32 *)prs_alloc_mem(ps,sizeof(r_u->attr[0])*r_u->num_attrs); - if (r_u->attr == NULL) - return False; - } - - for (i = 0; i < r_u->num_attrs; i++) { - if(!prs_uint32("", ps, depth, &r_u->attr[i])) - return False; - } - } - } - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_USERGROUPS structure. -********************************************************************/ - -void init_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS * q_u, - POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_query_usergroups\n")); - - q_u->pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_usergroups(const char *desc, SAMR_Q_QUERY_USERGROUPS * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_usergroups"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_USERGROUPS structure. -********************************************************************/ - -void init_samr_r_query_usergroups(SAMR_R_QUERY_USERGROUPS * r_u, - uint32 num_gids, DOM_GID * gid, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_usergroups\n")); - - if (NT_STATUS_IS_OK(status)) { - r_u->ptr_0 = 1; - r_u->num_entries = num_gids; - r_u->ptr_1 = (num_gids != 0) ? 1 : 0; - r_u->num_entries2 = num_gids; - - r_u->gid = gid; - } else { - r_u->ptr_0 = 0; - r_u->num_entries = 0; - r_u->ptr_1 = 0; - r_u->gid = NULL; - } - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_gids(const char *desc, uint32 *num_gids, DOM_GID ** gid, - prs_struct *ps, int depth) -{ - uint32 i; - if (gid == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_gids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_gids", ps, depth, num_gids)) - return False; - - if ((*num_gids) != 0) { - if (UNMARSHALLING(ps)) { - (*gid) = (DOM_GID *)prs_alloc_mem(ps,sizeof(DOM_GID)*(*num_gids)); - } - - if ((*gid) == NULL) { - return False; - } - - for (i = 0; i < (*num_gids); i++) { - if(!smb_io_gid("gids", &(*gid)[i], ps, depth)) - return False; - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_usergroups(const char *desc, SAMR_R_QUERY_USERGROUPS * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_usergroups"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) - return False; - - if (r_u->ptr_0 != 0) { - if(!prs_uint32("num_entries ", ps, depth, &r_u->num_entries)) - return False; - if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1)) - return False; - - if (r_u->num_entries != 0 && r_u->ptr_1 != 0) { - if(!samr_io_gids("gids", &r_u->num_entries2, &r_u->gid, ps, depth)) - return False; - } - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ENUM_DOMAINS structure. -********************************************************************/ - -void init_samr_q_enum_domains(SAMR_Q_ENUM_DOMAINS * q_e, - POLICY_HND *pol, - uint32 start_idx, uint32 size) -{ - DEBUG(5, ("init_samr_q_enum_domains\n")); - - q_e->pol = *pol; - - q_e->start_idx = start_idx; - q_e->max_size = size; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_enum_domains(const char *desc, SAMR_Q_ENUM_DOMAINS * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_enum_domains"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) - return False; - if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_ENUM_DOMAINS structure. -********************************************************************/ - -void init_samr_r_enum_domains(SAMR_R_ENUM_DOMAINS * r_u, - uint32 next_idx, uint32 num_sam_entries) -{ - DEBUG(5, ("init_samr_r_enum_domains\n")); - - r_u->next_idx = next_idx; - - if (num_sam_entries != 0) { - r_u->ptr_entries1 = 1; - r_u->ptr_entries2 = 1; - r_u->num_entries2 = num_sam_entries; - r_u->num_entries3 = num_sam_entries; - - r_u->num_entries4 = num_sam_entries; - } else { - r_u->ptr_entries1 = 0; - r_u->num_entries2 = num_sam_entries; - r_u->ptr_entries2 = 1; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_enum_domains(const char *desc, SAMR_R_ENUM_DOMAINS * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_enum_domains"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) - return False; - if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) - return False; - - if (r_u->ptr_entries1 != 0) { - if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) - return False; - if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) - return False; - if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) - return False; - - if (UNMARSHALLING(ps)) { - r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2); - r_u->uni_dom_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2); - } - - if ((r_u->sam == NULL || r_u->uni_dom_name == NULL) && r_u->num_entries2 != 0) { - DEBUG(0, ("NULL pointers in SAMR_R_ENUM_DOMAINS\n")); - r_u->num_entries4 = 0; - r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - fstring tmp; - slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i); - if(!sam_io_sam_entry(tmp, &r_u->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - fstring tmp; - slprintf(tmp, sizeof(tmp) - 1, "dom[%d]", i); - if(!smb_io_unistr2(tmp, &r_u->uni_dom_name[i], - r_u->sam[i].hdr_name.buffer, ps, - depth)) - return False; - } - - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ENUM_DOM_GROUPS structure. -********************************************************************/ - -void init_samr_q_enum_dom_groups(SAMR_Q_ENUM_DOM_GROUPS * q_e, - POLICY_HND *pol, - uint32 start_idx, uint32 size) -{ - DEBUG(5, ("init_samr_q_enum_dom_groups\n")); - - q_e->pol = *pol; - - q_e->start_idx = start_idx; - q_e->max_size = size; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_enum_dom_groups(const char *desc, SAMR_Q_ENUM_DOM_GROUPS * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_enum_dom_groups"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth)) - return False; - - if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) - return False; - if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_ENUM_DOM_GROUPS structure. -********************************************************************/ - -void init_samr_r_enum_dom_groups(SAMR_R_ENUM_DOM_GROUPS * r_u, - uint32 next_idx, uint32 num_sam_entries) -{ - DEBUG(5, ("init_samr_r_enum_dom_groups\n")); - - r_u->next_idx = next_idx; - - if (num_sam_entries != 0) { - r_u->ptr_entries1 = 1; - r_u->ptr_entries2 = 1; - r_u->num_entries2 = num_sam_entries; - r_u->num_entries3 = num_sam_entries; - - r_u->num_entries4 = num_sam_entries; - } else { - r_u->ptr_entries1 = 0; - r_u->num_entries2 = num_sam_entries; - r_u->ptr_entries2 = 1; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_enum_dom_groups(const char *desc, SAMR_R_ENUM_DOM_GROUPS * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_enum_dom_groups"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) - return False; - if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) - return False; - - if (r_u->ptr_entries1 != 0) { - if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) - return False; - if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) - return False; - if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) - return False; - - if (UNMARSHALLING(ps)) { - r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2); - r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2); - } - - if ((r_u->sam == NULL || r_u->uni_grp_name == NULL) && r_u->num_entries2 != 0) { - DEBUG(0, - ("NULL pointers in SAMR_R_ENUM_DOM_GROUPS\n")); - r_u->num_entries4 = 0; - r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!smb_io_unistr2("", &r_u->uni_grp_name[i], - r_u->sam[i].hdr_name.buffer, ps, depth)) - return False; - } - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ENUM_DOM_ALIASES structure. -********************************************************************/ - -void init_samr_q_enum_dom_aliases(SAMR_Q_ENUM_DOM_ALIASES * q_e, - POLICY_HND *pol, uint32 start_idx, - uint32 size) -{ - DEBUG(5, ("init_samr_q_enum_dom_aliases\n")); - - q_e->pol = *pol; - - q_e->start_idx = start_idx; - q_e->max_size = size; -} - - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_enum_dom_aliases(const char *desc, SAMR_Q_ENUM_DOM_ALIASES * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_enum_dom_aliases"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_e->pol, ps, depth)) - return False; - - if(!prs_uint32("start_idx", ps, depth, &q_e->start_idx)) - return False; - if(!prs_uint32("max_size ", ps, depth, &q_e->max_size)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_ENUM_DOM_ALIASES structure. -********************************************************************/ - -void init_samr_r_enum_dom_aliases(SAMR_R_ENUM_DOM_ALIASES *r_u, uint32 next_idx, uint32 num_sam_entries) -{ - DEBUG(5, ("init_samr_r_enum_dom_aliases\n")); - - r_u->next_idx = next_idx; - - if (num_sam_entries != 0) { - r_u->ptr_entries1 = 1; - r_u->ptr_entries2 = 1; - r_u->num_entries2 = num_sam_entries; - r_u->num_entries3 = num_sam_entries; - - r_u->num_entries4 = num_sam_entries; - } else { - r_u->ptr_entries1 = 0; - r_u->num_entries2 = num_sam_entries; - r_u->ptr_entries2 = 1; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_enum_dom_aliases(const char *desc, SAMR_R_ENUM_DOM_ALIASES * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_enum_dom_aliases"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("next_idx ", ps, depth, &r_u->next_idx)) - return False; - if(!prs_uint32("ptr_entries1", ps, depth, &r_u->ptr_entries1)) - return False; - - if (r_u->ptr_entries1 != 0) { - if(!prs_uint32("num_entries2", ps, depth, &r_u->num_entries2)) - return False; - if(!prs_uint32("ptr_entries2", ps, depth, &r_u->ptr_entries2)) - return False; - if(!prs_uint32("num_entries3", ps, depth, &r_u->num_entries3)) - return False; - - if (UNMARSHALLING(ps) && (r_u->num_entries2 > 0)) { - r_u->sam = (SAM_ENTRY *)prs_alloc_mem(ps,sizeof(SAM_ENTRY)*r_u->num_entries2); - r_u->uni_grp_name = (UNISTR2 *)prs_alloc_mem(ps,sizeof(UNISTR2)*r_u->num_entries2); - } - - if (r_u->num_entries2 != 0 && - (r_u->sam == NULL || r_u->uni_grp_name == NULL)) { - DEBUG(0,("NULL pointers in SAMR_R_ENUM_DOM_ALIASES\n")); - r_u->num_entries4 = 0; - r_u->status = NT_STATUS_MEMORY_NOT_ALLOCATED; - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!sam_io_sam_entry("", &r_u->sam[i], ps, depth)) - return False; - } - - for (i = 0; i < r_u->num_entries2; i++) { - if(!smb_io_unistr2("", &r_u->uni_grp_name[i], - r_u->sam[i].hdr_name.buffer, ps, - depth)) - return False; - } - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_entries4", ps, depth, &r_u->num_entries4)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a ALIAS_INFO1 structure. -********************************************************************/ - -void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc) -{ - int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0; - int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0; - - DEBUG(5, ("init_samr_alias_info1\n")); - - init_uni_hdr(&al1->hdr_acct_name, acct_len_name); - init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name); - - al1->num_member=num_member; - - init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc); - init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_alias_info1(const char *desc, ALIAS_INFO1 * al1, - prs_struct *ps, int depth) -{ - if (al1 == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_alias_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr_acct_name", &al1->hdr_acct_name, ps, depth)) - return False; - if(!prs_uint32("num_member", ps, depth, &al1->num_member)) - return False; - if(!smb_io_unihdr("hdr_acct_desc", &al1->hdr_acct_desc, ps, depth)) - return False; - - if(!smb_io_unistr2("uni_acct_name", &al1->uni_acct_name, - al1->hdr_acct_name.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_acct_desc", &al1->uni_acct_desc, - al1->hdr_acct_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a ALIAS_INFO3 structure. -********************************************************************/ - -void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc) -{ - int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0; - - DEBUG(5, ("init_samr_alias_info3\n")); - - init_uni_hdr(&al3->hdr_acct_desc, acct_len); - init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_alias_info3(const char *desc, ALIAS_INFO3 * al3, - prs_struct *ps, int depth) -{ - if (al3 == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_alias_info3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr_acct_desc", &al3->hdr_acct_desc, ps, depth)) - return False; - if(!smb_io_unistr2("uni_acct_desc", &al3->uni_acct_desc, - al3->hdr_acct_desc.buffer, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_alias_info_ctr(const char *desc, ALIAS_INFO_CTR * ctr, - prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_alias_info_ctr"); - depth++; - - if(!prs_uint16("switch_value1", ps, depth, &ctr->switch_value1)) - return False; - if(!prs_uint16("switch_value2", ps, depth, &ctr->switch_value2)) - return False; - - switch (ctr->switch_value1) { - case 1: - if(!samr_io_alias_info1("alias_info1", &ctr->alias.info1, ps, depth)) - return False; - break; - case 3: - if(!samr_io_alias_info3("alias_info3", &ctr->alias.info3, ps, depth)) - return False; - break; - default: - DEBUG(0,("samr_alias_info_ctr: unsupported switch level\n")); - break; - } - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_ALIASINFO structure. -********************************************************************/ - -void init_samr_q_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO * q_e, - POLICY_HND *pol, uint16 switch_level) -{ - DEBUG(5, ("init_samr_q_query_aliasinfo\n")); - - q_e->pol = *pol; - q_e->switch_level = switch_level; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_aliasinfo(const char *desc, SAMR_Q_QUERY_ALIASINFO * q_e, - prs_struct *ps, int depth) -{ - if (q_e == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_aliasinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &(q_e->pol), ps, depth)) - return False; - - if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_ALIASINFO structure. -********************************************************************/ - -void init_samr_r_query_aliasinfo(SAMR_R_QUERY_ALIASINFO * r_u, - ALIAS_INFO_CTR * ctr, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_aliasinfo\n")); - - r_u->ptr = (NT_STATUS_IS_OK(status) && ctr != NULL) ? 1 : 0; - r_u->ctr = *ctr; - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_aliasinfo(const char *desc, SAMR_R_QUERY_ALIASINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_aliasinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - if(!samr_alias_info_ctr("ctr", &r_u->ctr, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_SET_ALIASINFO structure. -********************************************************************/ - -void init_samr_q_set_aliasinfo(SAMR_Q_SET_ALIASINFO * q_u, - POLICY_HND *hnd, ALIAS_INFO_CTR * ctr) -{ - DEBUG(5, ("init_samr_q_set_aliasinfo\n")); - - q_u->alias_pol = *hnd; - q_u->ctr = *ctr; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_set_aliasinfo(const char *desc, SAMR_Q_SET_ALIASINFO * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_set_aliasinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - if(!samr_alias_info_ctr("ctr", &q_u->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_set_aliasinfo(const char *desc, SAMR_R_SET_ALIASINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_set_aliasinfo"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_USERALIASES structure. -********************************************************************/ - -void init_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES * q_u, - POLICY_HND *hnd, - uint32 num_sids, - uint32 *ptr_sid, DOM_SID2 * sid) -{ - DEBUG(5, ("init_samr_q_query_useraliases\n")); - - q_u->pol = *hnd; - - q_u->num_sids1 = num_sids; - q_u->ptr = 1; - q_u->num_sids2 = num_sids; - - q_u->ptr_sid = ptr_sid; - q_u->sid = sid; -} - -/******************************************************************* -reads or writes a SAMR_Q_QUERY_USERALIASES structure. -********************************************************************/ - -BOOL samr_io_q_query_useraliases(const char *desc, SAMR_Q_QUERY_USERALIASES * q_u, - prs_struct *ps, int depth) -{ - fstring tmp; - uint32 i; - - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_useraliases"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint32("num_sids1", ps, depth, &q_u->num_sids1)) - return False; - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - - if (q_u->ptr==0) - return True; - - if(!prs_uint32("num_sids2", ps, depth, &q_u->num_sids2)) - return False; - - if (UNMARSHALLING(ps) && (q_u->num_sids2 != 0)) { - q_u->ptr_sid = (uint32 *)prs_alloc_mem(ps,sizeof(q_u->ptr_sid[0])*q_u->num_sids2); - if (q_u->ptr_sid == NULL) - return False; - - q_u->sid = (DOM_SID2 *)prs_alloc_mem(ps, sizeof(q_u->sid[0]) * q_u->num_sids2); - if (q_u->sid == NULL) - return False; - } - - for (i = 0; i < q_u->num_sids2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "ptr[%02d]", i); - if(!prs_uint32(tmp, ps, depth, &q_u->ptr_sid[i])) - return False; - } - - for (i = 0; i < q_u->num_sids2; i++) { - if (q_u->ptr_sid[i] != 0) { - slprintf(tmp, sizeof(tmp) - 1, "sid[%02d]", i); - if(!smb_io_dom_sid2(tmp, &q_u->sid[i], ps, depth)) - return False; - } - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_USERALIASES structure. -********************************************************************/ - -void init_samr_r_query_useraliases(SAMR_R_QUERY_USERALIASES * r_u, - uint32 num_rids, uint32 *rid, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_useraliases\n")); - - if (NT_STATUS_IS_OK(status)) { - r_u->num_entries = num_rids; - r_u->ptr = 1; - r_u->num_entries2 = num_rids; - - r_u->rid = rid; - } else { - r_u->num_entries = 0; - r_u->ptr = 0; - r_u->num_entries2 = 0; - } - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_rids(const char *desc, uint32 *num_rids, uint32 **rid, - prs_struct *ps, int depth) -{ - fstring tmp; - uint32 i; - if (rid == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_rids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_rids", ps, depth, num_rids)) - return False; - - if ((*num_rids) != 0) { - if (UNMARSHALLING(ps)) { - /* reading */ - (*rid) = (uint32 *)prs_alloc_mem(ps,sizeof(uint32)*(*num_rids)); - } - if ((*rid) == NULL) - return False; - - for (i = 0; i < (*num_rids); i++) { - slprintf(tmp, sizeof(tmp) - 1, "rid[%02d]", i); - if(!prs_uint32(tmp, ps, depth, &((*rid)[i]))) - return False; - } - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_useraliases(const char *desc, SAMR_R_QUERY_USERALIASES * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_useraliases"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries", ps, depth, &r_u->num_entries)) - return False; - if(!prs_uint32("ptr ", ps, depth, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - if(!samr_io_rids("rids", &r_u->num_entries2, &r_u->rid, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_OPEN_ALIAS structure. -********************************************************************/ - -void init_samr_q_open_alias(SAMR_Q_OPEN_ALIAS * q_u, POLICY_HND *pol, - uint32 access_mask, uint32 rid) -{ - DEBUG(5, ("init_samr_q_open_alias\n")); - - q_u->dom_pol = *pol; - q_u->access_mask = access_mask; - q_u->rid_alias = rid; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_open_alias(const char *desc, SAMR_Q_OPEN_ALIAS * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_open_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->dom_pol, ps, depth)) - return False; - - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - if(!prs_uint32("rid_alias", ps, depth, &q_u->rid_alias)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_open_alias(const char *desc, SAMR_R_OPEN_ALIAS * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_open_alias"); - 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_RIDS structure. -********************************************************************/ - -void init_samr_q_lookup_rids(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_RIDS * q_u, - POLICY_HND *pol, uint32 flags, - uint32 num_rids, uint32 *rid) -{ - DEBUG(5, ("init_samr_q_lookup_rids\n")); - - q_u->pol = *pol; - - q_u->num_rids1 = num_rids; - q_u->flags = flags; - q_u->ptr = 0; - q_u->num_rids2 = num_rids; - q_u->rid = (uint32 *)talloc_zero(ctx, num_rids * sizeof(q_u->rid[0])); - if (q_u->rid == NULL) { - q_u->num_rids1 = 0; - q_u->num_rids2 = 0; - } else { - memcpy(q_u->rid, rid, num_rids * sizeof(q_u->rid[0])); - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_lookup_rids(const char *desc, SAMR_Q_LOOKUP_RIDS * q_u, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_lookup_rids"); - depth++; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(q_u); - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint32("num_rids1", ps, depth, &q_u->num_rids1)) - return False; - if(!prs_uint32("flags ", ps, depth, &q_u->flags)) - return False; - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - if(!prs_uint32("num_rids2", ps, depth, &q_u->num_rids2)) - return False; - - if (UNMARSHALLING(ps) && (q_u->num_rids2 != 0)) { - q_u->rid = (uint32 *)prs_alloc_mem(ps, sizeof(q_u->rid[0])*q_u->num_rids2); - if (q_u->rid == NULL) - return False; - } - - for (i = 0; i < q_u->num_rids2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i); - if(!prs_uint32(tmp, ps, depth, &q_u->rid[i])) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_LOOKUP_RIDS structure. -********************************************************************/ - -void init_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS * r_u, - uint32 num_names, UNIHDR * hdr_name, - UNISTR2 *uni_name, uint32 *type) -{ - DEBUG(5, ("init_samr_r_lookup_rids\n")); - - r_u->hdr_name = NULL; - r_u->uni_name = NULL; - r_u->type = NULL; - - if (num_names != 0) { - r_u->num_names1 = num_names; - r_u->ptr_names = 1; - r_u->num_names2 = num_names; - - r_u->num_types1 = num_names; - r_u->ptr_types = 1; - r_u->num_types2 = num_names; - - r_u->hdr_name = hdr_name; - r_u->uni_name = uni_name; - r_u->type = type; - } else { - r_u->num_names1 = num_names; - r_u->ptr_names = 0; - r_u->num_names2 = num_names; - - r_u->num_types1 = num_names; - r_u->ptr_types = 0; - r_u->num_types2 = num_names; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_lookup_rids(const char *desc, SAMR_R_LOOKUP_RIDS * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_lookup_rids"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_names1", ps, depth, &r_u->num_names1)) - return False; - if(!prs_uint32("ptr_names ", ps, depth, &r_u->ptr_names)) - return False; - - if (r_u->ptr_names != 0) { - - if(!prs_uint32("num_names2", ps, depth, &r_u->num_names2)) - return False; - - - if (UNMARSHALLING(ps) && (r_u->num_names2 != 0)) { - r_u->hdr_name = (UNIHDR *) prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->hdr_name[0])); - if (r_u->hdr_name == NULL) - return False; - - r_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, r_u->num_names2 * sizeof(r_u->uni_name[0])); - if (r_u->uni_name == NULL) - return False; - } - - for (i = 0; i < r_u->num_names2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "hdr[%02d] ", i); - if(!smb_io_unihdr("", &r_u->hdr_name[i], ps, depth)) - return False; - } - for (i = 0; i < r_u->num_names2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "str[%02d] ", i); - if(!smb_io_unistr2("", &r_u->uni_name[i], r_u->hdr_name[i].buffer, ps, depth)) - return False; - } - - } - - if(!prs_align(ps)) - return False; - if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1)) - return False; - if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types)) - return False; - - if (r_u->ptr_types != 0) { - - if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2)) - return False; - - if (UNMARSHALLING(ps) && (r_u->num_types2 != 0)) { - r_u->type = (uint32 *)prs_alloc_mem(ps, r_u->num_types2 * sizeof(r_u->type[0])); - if (r_u->type == NULL) - return False; - } - - for (i = 0; i < r_u->num_types2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i); - if(!prs_uint32(tmp, ps, depth, &r_u->type[i])) - return False; - } - } - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_OPEN_ALIAS structure. -********************************************************************/ - -void init_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS * q_u, POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_delete_alias\n")); - - q_u->alias_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_delete_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_delete_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_delete_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_delete_alias"); - 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_CREATE_DOM_ALIAS structure. -********************************************************************/ - -void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u, - POLICY_HND *hnd, char *acct_desc) -{ - int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0; - - DEBUG(5, ("init_samr_q_create_dom_alias\n")); - - q_u->dom_pol = *hnd; - - init_uni_hdr(&q_u->hdr_acct_desc, acct_len); - init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len); - - q_u->access_mask = 0x001f000f; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_create_dom_alias(const char *desc, SAMR_Q_CREATE_DOM_ALIAS * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_create_dom_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("dom_pol", &q_u->dom_pol, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_acct_desc", &q_u->hdr_acct_desc, ps, depth)) - return False; - if(!smb_io_unistr2("uni_acct_desc", &q_u->uni_acct_desc, - q_u->hdr_acct_desc.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_create_dom_alias(const char *desc, SAMR_R_CREATE_DOM_ALIAS * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_create_dom_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &r_u->alias_pol, ps, depth)) - return False; - - if(!prs_uint32("rid", ps, depth, &r_u->rid)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_ADD_ALIASMEM structure. -********************************************************************/ - -void init_samr_q_add_aliasmem(SAMR_Q_ADD_ALIASMEM * q_u, POLICY_HND *hnd, - DOM_SID *sid) -{ - DEBUG(5, ("init_samr_q_add_aliasmem\n")); - - q_u->alias_pol = *hnd; - init_dom_sid2(&q_u->sid, sid); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_add_aliasmem(const char *desc, SAMR_Q_ADD_ALIASMEM * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_add_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_add_aliasmem(const char *desc, SAMR_R_ADD_ALIASMEM * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_add_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_DEL_ALIASMEM structure. -********************************************************************/ - -void init_samr_q_del_aliasmem(SAMR_Q_DEL_ALIASMEM * q_u, POLICY_HND *hnd, - DOM_SID *sid) -{ - DEBUG(5, ("init_samr_q_del_aliasmem\n")); - - q_u->alias_pol = *hnd; - init_dom_sid2(&q_u->sid, sid); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_del_aliasmem(const char *desc, SAMR_Q_DEL_ALIASMEM * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_del_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - if(!smb_io_dom_sid2("sid ", &q_u->sid, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_del_aliasmem(const char *desc, SAMR_R_DEL_ALIASMEM * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_del_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_DELETE_DOM_ALIAS structure. -********************************************************************/ - -void init_samr_q_delete_dom_alias(SAMR_Q_DELETE_DOM_ALIAS * q_c, - POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_delete_dom_alias\n")); - - q_c->alias_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_delete_dom_alias(const char *desc, SAMR_Q_DELETE_DOM_ALIAS * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_delete_dom_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_DELETE_DOM_ALIAS structure. -********************************************************************/ - -void init_samr_r_delete_dom_alias(SAMR_R_DELETE_DOM_ALIAS * r_u, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_delete_dom_alias\n")); - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_delete_dom_alias(const char *desc, SAMR_R_DELETE_DOM_ALIAS * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_delete_dom_alias"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_ALIASMEM structure. -********************************************************************/ - -void init_samr_q_query_aliasmem(SAMR_Q_QUERY_ALIASMEM * q_c, - POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_query_aliasmem\n")); - - q_c->alias_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_aliasmem(const char *desc, SAMR_Q_QUERY_ALIASMEM * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("alias_pol", &q_u->alias_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_ALIASMEM structure. -********************************************************************/ - -void init_samr_r_query_aliasmem(SAMR_R_QUERY_ALIASMEM * r_u, - uint32 num_sids, DOM_SID2 * sid, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_aliasmem\n")); - - if (NT_STATUS_IS_OK(status)) { - r_u->num_sids = num_sids; - r_u->ptr = (num_sids != 0) ? 1 : 0; - r_u->num_sids1 = num_sids; - - r_u->sid = sid; - } else { - r_u->ptr = 0; - r_u->num_sids = 0; - } - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_aliasmem(const char *desc, SAMR_R_QUERY_ALIASMEM * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - uint32 ptr_sid[MAX_LOOKUP_SIDS]; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_aliasmem"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_sids ", ps, depth, &r_u->num_sids)) - return False; - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - SMB_ASSERT_ARRAY(ptr_sid, r_u->num_sids); - - if (r_u->num_sids != 0) { - if(!prs_uint32("num_sids1", ps, depth, &r_u->num_sids1)) - return False; - - for (i = 0; i < r_u->num_sids1; i++) { - ptr_sid[i] = 1; - if(!prs_uint32("", ps, depth, &ptr_sid[i])) - return False; - } - - for (i = 0; i < r_u->num_sids1; i++) { - if (ptr_sid[i] != 0) { - if(!smb_io_dom_sid2("", &r_u->sid[i], ps, depth)) - return False; - } - } - } - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_LOOKUP_NAMES structure. -********************************************************************/ - -NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u, - POLICY_HND *pol, uint32 flags, - uint32 num_names, const char **name) -{ - uint32 i; - - DEBUG(5, ("init_samr_q_lookup_names\n")); - - q_u->pol = *pol; - - q_u->num_names1 = num_names; - q_u->flags = flags; - q_u->ptr = 0; - q_u->num_names2 = num_names; - - if (!(q_u->hdr_name = (UNIHDR *)talloc_zero(ctx, num_names * sizeof(UNIHDR)))) - return NT_STATUS_NO_MEMORY; - - if (!(q_u->uni_name = (UNISTR2 *)talloc_zero(ctx, num_names * sizeof(UNISTR2)))) - return NT_STATUS_NO_MEMORY; - - for (i = 0; i < num_names; i++) { - int len_name = name[i] != NULL ? strlen(name[i]) : 0; - init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */ - init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */ - } - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_lookup_names(const char *desc, SAMR_Q_LOOKUP_NAMES * q_u, - prs_struct *ps, int depth) -{ - uint32 i; - - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_lookup_names"); - depth++; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(q_u); - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint32("num_names1", ps, depth, &q_u->num_names1)) - return False; - if(!prs_uint32("flags ", ps, depth, &q_u->flags)) - return False; - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - if(!prs_uint32("num_names2", ps, depth, &q_u->num_names2)) - return False; - - if (UNMARSHALLING(ps) && (q_u->num_names2 != 0)) { - q_u->hdr_name = (UNIHDR *)prs_alloc_mem(ps, sizeof(UNIHDR) * - q_u->num_names2); - q_u->uni_name = (UNISTR2 *)prs_alloc_mem(ps, sizeof(UNISTR2) * - q_u->num_names2); - if (!q_u->hdr_name || !q_u->uni_name) - return False; - } - - for (i = 0; i < q_u->num_names2; i++) { - if(!smb_io_unihdr("", &q_u->hdr_name[i], ps, depth)) - return False; - } - - for (i = 0; i < q_u->num_names2; i++) { - if(!smb_io_unistr2("", &q_u->uni_name[i], q_u->hdr_name[i].buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_LOOKUP_NAMES structure. -********************************************************************/ - -NTSTATUS init_samr_r_lookup_names(TALLOC_CTX *ctx, SAMR_R_LOOKUP_NAMES * r_u, - uint32 num_rids, - uint32 *rid, uint32 *type, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_lookup_names\n")); - - if (NT_STATUS_IS_OK(status) && (num_rids != 0)) { - uint32 i; - - r_u->num_types1 = num_rids; - r_u->ptr_types = 1; - r_u->num_types2 = num_rids; - - r_u->num_rids1 = num_rids; - r_u->ptr_rids = 1; - r_u->num_rids2 = num_rids; - - if (!(r_u->rids = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids))) - return NT_STATUS_NO_MEMORY; - if (!(r_u->types = (uint32 *)talloc_zero(ctx, sizeof(uint32)*num_rids))) - return NT_STATUS_NO_MEMORY; - - if (!r_u->rids || !r_u->types) - goto empty; - - for (i = 0; i < num_rids; i++) { - r_u->rids[i] = rid[i]; - r_u->types[i] = type[i]; - } - } else { - - empty: - r_u->num_types1 = 0; - r_u->ptr_types = 0; - r_u->num_types2 = 0; - - r_u->num_rids1 = 0; - r_u->ptr_rids = 0; - r_u->num_rids2 = 0; - - r_u->rids = NULL; - r_u->types = NULL; - } - - r_u->status = status; - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_lookup_names(const char *desc, SAMR_R_LOOKUP_NAMES * r_u, - prs_struct *ps, int depth) -{ - uint32 i; - fstring tmp; - - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_lookup_names"); - depth++; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(r_u); - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_rids1", ps, depth, &r_u->num_rids1)) - return False; - if(!prs_uint32("ptr_rids ", ps, depth, &r_u->ptr_rids)) - return False; - - if (r_u->ptr_rids != 0) { - if(!prs_uint32("num_rids2", ps, depth, &r_u->num_rids2)) - return False; - - if (r_u->num_rids2 != r_u->num_rids1) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) - r_u->rids = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_rids2); - - if (!r_u->rids) { - DEBUG(0, ("NULL rids in samr_io_r_lookup_names\n")); - return False; - } - - for (i = 0; i < r_u->num_rids2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "rid[%02d] ", i); - if(!prs_uint32(tmp, ps, depth, &r_u->rids[i])) - return False; - } - } - - if(!prs_uint32("num_types1", ps, depth, &r_u->num_types1)) - return False; - if(!prs_uint32("ptr_types ", ps, depth, &r_u->ptr_types)) - return False; - - if (r_u->ptr_types != 0) { - if(!prs_uint32("num_types2", ps, depth, &r_u->num_types2)) - return False; - - if (r_u->num_types2 != r_u->num_types1) { - /* RPC fault */ - return False; - } - - if (UNMARSHALLING(ps)) - r_u->types = (uint32 *)prs_alloc_mem(ps, sizeof(uint32)*r_u->num_types2); - - if (!r_u->types) { - DEBUG(0, ("NULL types in samr_io_r_lookup_names\n")); - return False; - } - - for (i = 0; i < r_u->num_types2; i++) { - slprintf(tmp, sizeof(tmp) - 1, "type[%02d] ", i); - if(!prs_uint32(tmp, ps, depth, &r_u->types[i])) - return False; - } - } - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_DELETE_DOM_USER structure. -********************************************************************/ - -void init_samr_q_delete_dom_user(SAMR_Q_DELETE_DOM_USER * q_c, - POLICY_HND *hnd) -{ - DEBUG(5, ("init_samr_q_delete_dom_user\n")); - - q_c->user_pol = *hnd; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_delete_dom_user(const char *desc, SAMR_Q_DELETE_DOM_USER * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_delete_dom_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("user_pol", &q_u->user_pol, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_delete_dom_user(const char *desc, SAMR_R_DELETE_DOM_USER * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_delete_dom_user"); - 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; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -void init_samr_q_open_user(SAMR_Q_OPEN_USER * q_u, - POLICY_HND *pol, - uint32 access_mask, uint32 rid) -{ - DEBUG(5, ("samr_init_samr_q_open_user\n")); - - q_u->domain_pol = *pol; - q_u->access_mask = access_mask; - q_u->user_rid = rid; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_open_user(const char *desc, SAMR_Q_OPEN_USER * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_open_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) - return False; - - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - if(!prs_uint32("user_rid ", ps, depth, &q_u->user_rid)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_open_user(const char *desc, SAMR_R_OPEN_USER * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_open_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("user_pol", &r_u->user_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_create_user(SAMR_Q_CREATE_USER * q_u, - POLICY_HND *pol, - const char *name, - uint32 acb_info, uint32 access_mask) -{ - int len_name; - len_name = strlen(name); - - DEBUG(5, ("samr_init_samr_q_create_user\n")); - - q_u->domain_pol = *pol; - - init_uni_hdr(&q_u->hdr_name, len_name); - init_unistr2(&q_u->uni_name, name, len_name); - - q_u->acb_info = acb_info; - q_u->access_mask = access_mask; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_create_user(const char *desc, SAMR_Q_CREATE_USER * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_create_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_name", &q_u->hdr_name, ps, depth)) - return False; - if(!smb_io_unistr2("uni_name", &q_u->uni_name, q_u->hdr_name.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("acb_info ", ps, depth, &q_u->acb_info)) - return False; - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_create_user(const char *desc, SAMR_R_CREATE_USER * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_create_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("user_pol", &r_u->user_pol, ps, depth)) - return False; - - if(!prs_uint32("access_granted", ps, depth, &r_u->access_granted)) - return False; - if(!prs_uint32("user_rid ", ps, depth, &r_u->user_rid)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_QUERY_USERINFO structure. -********************************************************************/ - -void init_samr_q_query_userinfo(SAMR_Q_QUERY_USERINFO * q_u, - POLICY_HND *hnd, uint16 switch_value) -{ - DEBUG(5, ("init_samr_q_query_userinfo\n")); - - q_u->pol = *hnd; - q_u->switch_value = switch_value; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_query_userinfo(const char *desc, SAMR_Q_QUERY_USERINFO * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_query_userinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) /* 0x0015 or 0x0011 */ - return False; - - return True; -} - -/******************************************************************* -reads or writes a LOGON_HRS structure. -********************************************************************/ - -static BOOL sam_io_logon_hrs(const char *desc, LOGON_HRS * hrs, - prs_struct *ps, int depth) -{ - if (hrs == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_logon_hrs"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("len ", ps, depth, &hrs->len)) - return False; - - if (hrs->len > sizeof(hrs->hours)) { - DEBUG(3, ("sam_io_logon_hrs: truncating length from %d\n", hrs->len)); - hrs->len = sizeof(hrs->hours); - } - - if(!prs_uint8s(False, "hours", ps, depth, hrs->hours, hrs->len)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_USER_INFO_12 structure. -********************************************************************/ - -void init_sam_user_info12(SAM_USER_INFO_12 * usr, - const uint8 lm_pwd[16], const uint8 nt_pwd[16]) -{ - DEBUG(5, ("init_sam_user_info12\n")); - - usr->lm_pwd_active = - memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)) ? 1 : 0; - usr->nt_pwd_active = - memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)) ? 1 : 0; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info12(const char *desc, SAM_USER_INFO_12 * u, - prs_struct *ps, int depth) -{ - if (u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_user_info12"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s(False, "lm_pwd", ps, depth, u->lm_pwd, sizeof(u->lm_pwd))) - return False; - if(!prs_uint8s(False, "nt_pwd", ps, depth, u->nt_pwd, sizeof(u->nt_pwd))) - return False; - - if(!prs_uint8("lm_pwd_active", ps, depth, &u->lm_pwd_active)) - return False; - if(!prs_uint8("nt_pwd_active", ps, depth, &u->nt_pwd_active)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_USER_INFO_10 structure. -********************************************************************/ - -void init_sam_user_info10(SAM_USER_INFO_10 * usr, uint32 acb_info) -{ - DEBUG(5, ("init_sam_user_info10\n")); - - usr->acb_info = acb_info; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info10(const char *desc, SAM_USER_INFO_10 * usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_user_info10"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("acb_info", ps, depth, &usr->acb_info)) - return False; - - return True; -} - -/******************************************************************* -inits a SAM_USER_INFO_11 structure. -********************************************************************/ - -void init_sam_user_info11(SAM_USER_INFO_11 * usr, - NTTIME * expiry, - char *mach_acct, - uint32 rid_user, uint32 rid_group, uint16 acct_ctrl) -{ - int len_mach_acct; - - DEBUG(5, ("init_sam_user_info11\n")); - - len_mach_acct = strlen(mach_acct); - - memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */ - ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */ - - init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */ - usr->padding_2 = 0; /* 0 - padding 4 bytes */ - - usr->ptr_1 = 1; /* pointer */ - ZERO_STRUCT(usr->padding_3); /* 0 - padding 32 bytes */ - usr->padding_4 = 0; /* 0 - padding 4 bytes */ - - usr->ptr_2 = 1; /* pointer */ - usr->padding_5 = 0; /* 0 - padding 4 bytes */ - - usr->ptr_3 = 1; /* pointer */ - ZERO_STRUCT(usr->padding_6); /* 0 - padding 32 bytes */ - - usr->rid_user = rid_user; - usr->rid_group = rid_group; - - usr->acct_ctrl = acct_ctrl; - usr->unknown_3 = 0x0000; - - usr->unknown_4 = 0x003f; /* 0x003f - 16 bit unknown */ - usr->unknown_5 = 0x003c; /* 0x003c - 16 bit unknown */ - - ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */ - usr->padding_8 = 0; /* 0 - padding 4 bytes */ - - init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info11(const char *desc, SAM_USER_INFO_11 * usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_unknown_11"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s(False, "padding_0", ps, depth, usr->padding_0, sizeof(usr->padding_0))) - return False; - - if(!smb_io_time("time", &usr->expiry, ps, depth)) - return False; - - if(!prs_uint8s(False, "padding_1", ps, depth, usr->padding_1, sizeof(usr->padding_1))) - return False; - - if(!smb_io_unihdr("unihdr", &usr->hdr_mach_acct, ps, depth)) - return False; - - if(!prs_uint32("padding_2", ps, depth, &usr->padding_2)) - return False; - - if(!prs_uint32("ptr_1 ", ps, depth, &usr->ptr_1)) - return False; - if(!prs_uint8s(False, "padding_3", ps, depth, usr->padding_3, sizeof(usr->padding_3))) - return False; - - if(!prs_uint32("padding_4", ps, depth, &usr->padding_4)) - return False; - - if(!prs_uint32("ptr_2 ", ps, depth, &usr->ptr_2)) - return False; - if(!prs_uint32("padding_5", ps, depth, &usr->padding_5)) - return False; - - if(!prs_uint32("ptr_3 ", ps, depth, &usr->ptr_3)) - return False; - if(!prs_uint8s(False, "padding_6", ps, depth, usr->padding_6,sizeof(usr->padding_6))) - return False; - - if(!prs_uint32("rid_user ", ps, depth, &usr->rid_user)) - return False; - if(!prs_uint32("rid_group", ps, depth, &usr->rid_group)) - return False; - if(!prs_uint16("acct_ctrl", ps, depth, &usr->acct_ctrl)) - return False; - if(!prs_uint16("unknown_3", ps, depth, &usr->unknown_3)) - return False; - if(!prs_uint16("unknown_4", ps, depth, &usr->unknown_4)) - return False; - if(!prs_uint16("unknown_5", ps, depth, &usr->unknown_5)) - return False; - - if(!prs_uint8s(False, "padding_7", ps, depth, usr->padding_7, sizeof(usr->padding_7))) - return False; - - if(!prs_uint32("padding_8", ps, depth, &(usr->padding_8))) - return False; - - if(!smb_io_unistr2("unistr2", &usr->uni_mach_acct, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s(False, "padding_9", ps, depth, usr->padding_9, sizeof(usr->padding_9))) - return False; - - return True; -} - -/************************************************************************* - init_sam_user_infoa - - unknown_3 = 0x09f8 27fa - unknown_5 = 0x0001 0000 - unknown_6 = 0x0000 04ec - - *************************************************************************/ - -void init_sam_user_info24(SAM_USER_INFO_24 * usr, char newpass[516], uint16 pw_len) -{ - DEBUG(10, ("init_sam_user_info24:\n")); - memcpy(usr->pass, newpass, sizeof(usr->pass)); - usr->pw_len = pw_len; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info24(const char *desc, SAM_USER_INFO_24 * usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_user_info24"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint8s(False, "password", ps, depth, usr->pass, - sizeof(usr->pass))) - return False; - - if (MARSHALLING(ps) && (usr->pw_len != 0)) { - if (!prs_uint16("pw_len", ps, depth, &usr->pw_len)) - return False; - } - if(!prs_align(ps)) - return False; - - return True; -} - -/************************************************************************* - init_sam_user_info23 - - unknown_3 = 0x09f8 27fa - unknown_5 = 0x0001 0000 - unknown_6 = 0x0000 04ec - - *************************************************************************/ - -void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */ - NTTIME * logoff_time, /* all zeros */ - NTTIME * kickoff_time, /* all zeros */ - NTTIME * pass_last_set_time, /* all zeros */ - NTTIME * pass_can_change_time, /* all zeros */ - NTTIME * pass_must_change_time, /* all zeros */ - UNISTR2 *user_name, - UNISTR2 *full_name, - UNISTR2 *home_dir, - UNISTR2 *dir_drive, - UNISTR2 *log_scr, - UNISTR2 *prof_path, - UNISTR2 *desc, - UNISTR2 *wkstas, - UNISTR2 *unk_str, - UNISTR2 *mung_dial, - uint32 user_rid, /* 0x0000 0000 */ - uint32 group_rid, - uint32 acb_info, - uint32 unknown_3, - uint16 logon_divs, - LOGON_HRS * hrs, - uint32 unknown_5, - char newpass[516], uint32 unknown_6) -{ - int len_user_name = user_name != NULL ? user_name->uni_str_len : 0; - int len_full_name = full_name != NULL ? full_name->uni_str_len : 0; - int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0; - int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0; - int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0; - int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0; - int len_description = desc != NULL ? desc->uni_str_len : 0; - int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0; - int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0; - int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0; - - usr->logon_time = *logon_time; /* all zeros */ - usr->logoff_time = *logoff_time; /* all zeros */ - usr->kickoff_time = *kickoff_time; /* all zeros */ - usr->pass_last_set_time = *pass_last_set_time; /* all zeros */ - usr->pass_can_change_time = *pass_can_change_time; /* all zeros */ - usr->pass_must_change_time = *pass_must_change_time; /* all zeros */ - - init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */ - init_uni_hdr(&usr->hdr_full_name, len_full_name); - init_uni_hdr(&usr->hdr_home_dir, len_home_dir); - init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive); - init_uni_hdr(&usr->hdr_logon_script, len_logon_script); - init_uni_hdr(&usr->hdr_profile_path, len_profile_path); - init_uni_hdr(&usr->hdr_acct_desc, len_description); - init_uni_hdr(&usr->hdr_workstations, len_workstations); - init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str); - init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial); - - ZERO_STRUCT(usr->nt_pwd); - ZERO_STRUCT(usr->lm_pwd); - - usr->user_rid = user_rid; /* 0x0000 0000 */ - usr->group_rid = group_rid; - usr->acb_info = acb_info; - usr->unknown_3 = unknown_3; /* 09f8 27fa */ - - usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ - usr->ptr_logon_hrs = hrs ? 1 : 0; - - if (nt_time_is_zero(pass_must_change_time)) { - usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; - } else { - usr->passmustchange=0; - } - - - ZERO_STRUCT(usr->padding1); - ZERO_STRUCT(usr->padding2); - - usr->unknown_5 = unknown_5; /* 0x0001 0000 */ - - memcpy(usr->pass, newpass, sizeof(usr->pass)); - - copy_unistr2(&usr->uni_user_name, user_name); - copy_unistr2(&usr->uni_full_name, full_name); - copy_unistr2(&usr->uni_home_dir, home_dir); - copy_unistr2(&usr->uni_dir_drive, dir_drive); - copy_unistr2(&usr->uni_logon_script, log_scr); - copy_unistr2(&usr->uni_profile_path, prof_path); - copy_unistr2(&usr->uni_acct_desc, desc); - copy_unistr2(&usr->uni_workstations, wkstas); - copy_unistr2(&usr->uni_unknown_str, unk_str); - copy_unistr2(&usr->uni_munged_dial, mung_dial); - - usr->unknown_6 = unknown_6; /* 0x0000 04ec */ - usr->padding4 = 0; - - memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); -} - -/************************************************************************* - init_sam_user_info23 - - unknown_3 = 0x09f8 27fa - unknown_5 = 0x0001 0000 - unknown_6 = 0x0000 04ec - - *************************************************************************/ - -void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all zeros */ - NTTIME * logoff_time, /* all zeros */ - NTTIME * kickoff_time, /* all zeros */ - NTTIME * pass_last_set_time, /* all zeros */ - NTTIME * pass_can_change_time, /* all zeros */ - NTTIME * pass_must_change_time, /* all zeros */ - char *user_name, /* NULL */ - char *full_name, - char *home_dir, char *dir_drive, char *log_scr, - char *prof_path, const char *desc, char *wkstas, - char *unk_str, char *mung_dial, uint32 user_rid, /* 0x0000 0000 */ - uint32 group_rid, uint32 acb_info, - uint32 unknown_3, uint16 logon_divs, - LOGON_HRS * hrs, uint32 unknown_5, - char newpass[516], uint32 unknown_6) -{ - int len_user_name = user_name != NULL ? strlen(user_name) : 0; - int len_full_name = full_name != NULL ? strlen(full_name) : 0; - int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0; - int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0; - int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0; - int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0; - int len_description = desc != NULL ? strlen(desc) : 0; - int len_workstations = wkstas != NULL ? strlen(wkstas) : 0; - int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0; - int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0; - - usr->logon_time = *logon_time; /* all zeros */ - usr->logoff_time = *logoff_time; /* all zeros */ - usr->kickoff_time = *kickoff_time; /* all zeros */ - usr->pass_last_set_time = *pass_last_set_time; /* all zeros */ - usr->pass_can_change_time = *pass_can_change_time; /* all zeros */ - usr->pass_must_change_time = *pass_must_change_time; /* all zeros */ - - init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */ - init_uni_hdr(&usr->hdr_full_name, len_full_name); - init_uni_hdr(&usr->hdr_home_dir, len_home_dir); - init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive); - init_uni_hdr(&usr->hdr_logon_script, len_logon_script); - init_uni_hdr(&usr->hdr_profile_path, len_profile_path); - init_uni_hdr(&usr->hdr_acct_desc, len_description); - init_uni_hdr(&usr->hdr_workstations, len_workstations); - init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str); - init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial); - - ZERO_STRUCT(usr->nt_pwd); - ZERO_STRUCT(usr->lm_pwd); - - usr->user_rid = user_rid; /* 0x0000 0000 */ - usr->group_rid = group_rid; - usr->acb_info = acb_info; - usr->unknown_3 = unknown_3; /* 09f8 27fa */ - - usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ - usr->ptr_logon_hrs = hrs ? 1 : 0; - - if (nt_time_is_zero(pass_must_change_time)) { - usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; - } else { - usr->passmustchange=0; - } - - ZERO_STRUCT(usr->padding1); - ZERO_STRUCT(usr->padding2); - - usr->unknown_5 = unknown_5; /* 0x0001 0000 */ - - memcpy(usr->pass, newpass, sizeof(usr->pass)); - - init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */ - init_unistr2(&usr->uni_full_name, full_name, len_full_name); - init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir); - init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive); - init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script); - init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path); - init_unistr2(&usr->uni_acct_desc, desc, len_description); - init_unistr2(&usr->uni_workstations, wkstas, len_workstations); - init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str); - init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial); - - usr->unknown_6 = unknown_6; /* 0x0000 04ec */ - usr->padding4 = 0; - - memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info23(const char *desc, SAM_USER_INFO_23 * usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_user_info23"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) - return False; - if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) - return False; - if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) - return False; - if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth)) - return False; - if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth)) - return False; - if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ - return False; - if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ - return False; - if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ - return False; - if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ - return False; - if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ - return False; - if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ - return False; - if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ - return False; - if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ - return False; - if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ - return False; - if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ - return False; - - if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) - return False; - if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) - return False; - - if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ - return False; - if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ - return False; - if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) - return False; - - if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3)) - return False; - if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */ - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs)) - return False; - - if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5)) - return False; - - if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1))) - return False; - if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange)) - return False; - if(!prs_uint8("padding2 ", ps, depth, &usr->padding2)) - return False; - - - if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass))) - return False; - - /* here begins pointed-to data */ - - if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ - return False; - - if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ - return False; - - if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ - return False; - - if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ - return False; - - if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ - return False; - - if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ - return False; - - if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ - return False; - - if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ - return False; - - if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ - return False; - - if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth)) - return False; - - /* ok, this is only guess-work (as usual) */ - if (usr->ptr_logon_hrs) { - if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6)) - return False; - if(!prs_uint32("padding4 ", ps, depth, &usr->padding4)) - return False; - if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) - return False; - } else if (UNMARSHALLING(ps)) { - usr->unknown_6 = 0; - usr->padding4 = 0; - } - - return True; -} - -/******************************************************************* - reads or writes a structure. - NB. This structure is *definately* incorrect. It's my best guess - currently for W2K SP2. The password field is encrypted in a different - way than normal... And there are definately other problems. JRA. -********************************************************************/ - -static BOOL sam_io_user_info25(const char *desc, SAM_USER_INFO_25 * usr, prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_user_info25"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) - return False; - if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) - return False; - if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) - return False; - if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps, depth)) - return False; - if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps, depth)) - return False; - if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ - return False; - if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ - return False; - if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ - return False; - if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ - return False; - if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ - return False; - if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ - return False; - if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ - return False; - if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ - return False; - if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ - return False; - if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ - return False; - - if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) - return False; - if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) - return False; - - if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ - return False; - if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ - return False; - if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) - return False; - - if(!prs_uint32s(False, "unknown_6 ", ps, depth, usr->unknown_6, 6)) - return False; - - if(!prs_uint8s(False, "password ", ps, depth, usr->pass, sizeof(usr->pass))) - return False; - - /* here begins pointed-to data */ - - if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ - return False; - - if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ - return False; - - if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ - return False; - - if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ - return False; - - if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ - return False; - - if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ - return False; - - if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ - return False; - - if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ - return False; - - if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ - return False; - - if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial, usr->hdr_munged_dial.buffer, ps, depth)) - return False; - -#if 0 /* JRA - unknown... */ - /* ok, this is only guess-work (as usual) */ - if (usr->ptr_logon_hrs) { - if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6)) - return False; - if(!prs_uint32("padding4 ", ps, depth, &usr->padding4)) - return False; - if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) - return False; - } else if (UNMARSHALLING(ps)) { - usr->unknown_6 = 0; - usr->padding4 = 0; - } -#endif - - return True; -} - - -/************************************************************************* - init_sam_user_info21W - - unknown_3 = 0x00ff ffff - unknown_5 = 0x0002 0000 - unknown_6 = 0x0000 04ec - - *************************************************************************/ - -void init_sam_user_info21W(SAM_USER_INFO_21 * usr, - NTTIME * logon_time, - NTTIME * logoff_time, - NTTIME * kickoff_time, - NTTIME * pass_last_set_time, - NTTIME * pass_can_change_time, - NTTIME * pass_must_change_time, - UNISTR2 *user_name, - UNISTR2 *full_name, - UNISTR2 *home_dir, - UNISTR2 *dir_drive, - UNISTR2 *log_scr, - UNISTR2 *prof_path, - UNISTR2 *desc, - UNISTR2 *wkstas, - UNISTR2 *unk_str, - UNISTR2 *mung_dial, - uchar lm_pwd[16], - uchar nt_pwd[16], - uint32 user_rid, - uint32 group_rid, - uint32 acb_info, - uint32 unknown_3, - uint16 logon_divs, - LOGON_HRS * hrs, - uint32 unknown_5, uint32 unknown_6) -{ - int len_user_name = user_name != NULL ? user_name->uni_str_len : 0; - int len_full_name = full_name != NULL ? full_name->uni_str_len : 0; - int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0; - int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0; - int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0; - int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0; - int len_description = desc != NULL ? desc->uni_str_len : 0; - int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0; - int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0; - int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0; - - usr->logon_time = *logon_time; - usr->logoff_time = *logoff_time; - usr->kickoff_time = *kickoff_time; - usr->pass_last_set_time = *pass_last_set_time; - usr->pass_can_change_time = *pass_can_change_time; - usr->pass_must_change_time = *pass_must_change_time; - - init_uni_hdr(&usr->hdr_user_name, len_user_name); - init_uni_hdr(&usr->hdr_full_name, len_full_name); - init_uni_hdr(&usr->hdr_home_dir, len_home_dir); - init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive); - init_uni_hdr(&usr->hdr_logon_script, len_logon_script); - init_uni_hdr(&usr->hdr_profile_path, len_profile_path); - init_uni_hdr(&usr->hdr_acct_desc, len_description); - init_uni_hdr(&usr->hdr_workstations, len_workstations); - init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str); - init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial); - - memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd)); - memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd)); - - usr->user_rid = user_rid; - usr->group_rid = group_rid; - usr->acb_info = acb_info; - usr->unknown_3 = unknown_3; /* 0x00ff ffff */ - - usr->logon_divs = logon_divs; /* should be 168 (hours/week) */ - usr->ptr_logon_hrs = hrs ? 1 : 0; - usr->unknown_5 = unknown_5; /* 0x0002 0000 */ - - if (nt_time_is_zero(pass_must_change_time)) { - usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; - } else { - usr->passmustchange=0; - } - - - ZERO_STRUCT(usr->padding1); - ZERO_STRUCT(usr->padding2); - - copy_unistr2(&usr->uni_user_name, user_name); - copy_unistr2(&usr->uni_full_name, full_name); - copy_unistr2(&usr->uni_home_dir, home_dir); - copy_unistr2(&usr->uni_dir_drive, dir_drive); - copy_unistr2(&usr->uni_logon_script, log_scr); - copy_unistr2(&usr->uni_profile_path, prof_path); - copy_unistr2(&usr->uni_acct_desc, desc); - copy_unistr2(&usr->uni_workstations, wkstas); - copy_unistr2(&usr->uni_unknown_str, unk_str); - copy_unistr2(&usr->uni_munged_dial, mung_dial); - - usr->unknown_6 = unknown_6; /* 0x0000 04ec */ - usr->padding4 = 0; - - memcpy(&usr->logon_hrs, hrs, sizeof(usr->logon_hrs)); -} - -/************************************************************************* - init_sam_user_info21 - - unknown_3 = 0x00ff ffff - unknown_5 = 0x0002 0000 - unknown_6 = 0x0000 04ec - - *************************************************************************/ - -NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *domain_sid) -{ - NTTIME logon_time, logoff_time, kickoff_time, - pass_last_set_time, pass_can_change_time, - pass_must_change_time; - - int len_user_name, len_full_name, len_home_dir, - len_dir_drive, len_logon_script, len_profile_path, - len_description, len_workstations, len_unknown_str, - len_munged_dial; - - const char* user_name = pdb_get_username(pw); - const char* full_name = pdb_get_fullname(pw); - const char* home_dir = pdb_get_homedir(pw); - const char* dir_drive = pdb_get_dir_drive(pw); - const char* logon_script = pdb_get_logon_script(pw); - const char* profile_path = pdb_get_profile_path(pw); - const char* description = pdb_get_acct_desc(pw); - const char* workstations = pdb_get_workstations(pw); - const char* munged_dial = pdb_get_munged_dial(pw); - - uint32 user_rid; - const DOM_SID *user_sid; - - uint32 group_rid; - const DOM_SID *group_sid; - - len_user_name = user_name != NULL ? strlen(user_name )+1 : 0; - len_full_name = full_name != NULL ? strlen(full_name )+1 : 0; - len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0; - len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0; - len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0; - len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0; - len_description = description != NULL ? strlen(description )+1 : 0; - len_workstations = workstations != NULL ? strlen(workstations)+1 : 0; - len_unknown_str = 0; - len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0; - - - /* Create NTTIME structs */ - unix_to_nt_time (&logon_time, pdb_get_logon_time(pw)); - unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw)); - unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(pw)); - unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(pw)); - unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(pw)); - unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(pw)); - - /* structure assignment */ - usr->logon_time = logon_time; - usr->logoff_time = logoff_time; - usr->kickoff_time = kickoff_time; - usr->pass_last_set_time = pass_last_set_time; - usr->pass_can_change_time = pass_can_change_time; - usr->pass_must_change_time = pass_must_change_time; - - init_uni_hdr(&usr->hdr_user_name, len_user_name); - init_uni_hdr(&usr->hdr_full_name, len_full_name); - init_uni_hdr(&usr->hdr_home_dir, len_home_dir); - init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive); - init_uni_hdr(&usr->hdr_logon_script, len_logon_script); - init_uni_hdr(&usr->hdr_profile_path, len_profile_path); - init_uni_hdr(&usr->hdr_acct_desc, len_description); - init_uni_hdr(&usr->hdr_workstations, len_workstations); - init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str); - init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial); - - ZERO_STRUCT(usr->nt_pwd); - ZERO_STRUCT(usr->lm_pwd); - - user_sid = pdb_get_user_sid(pw); - - if (!sid_peek_check_rid(domain_sid, user_sid, &user_rid)) { - fstring user_sid_string; - fstring domain_sid_string; - DEBUG(0, ("init_sam_user_info_21A: User %s has SID %s, \nwhich conflicts with " - "the domain sid %s. Failing operation.\n", - user_name, - sid_to_string(user_sid_string, user_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - group_sid = pdb_get_group_sid(pw); - - if (!sid_peek_check_rid(domain_sid, group_sid, &group_rid)) { - fstring group_sid_string; - fstring domain_sid_string; - DEBUG(0, ("init_sam_user_info_21A: User %s has Primary Group SID %s, \n" - "which conflicts with the domain sid %s. Failing operation.\n", - user_name, - sid_to_string(group_sid_string, group_sid), - sid_to_string(domain_sid_string, domain_sid))); - return NT_STATUS_UNSUCCESSFUL; - } - - usr->user_rid = user_rid; - usr->group_rid = group_rid; - usr->acb_info = pdb_get_acct_ctrl(pw); - - /* - Look at a user on a real NT4 PDC with usrmgr, press - 'ok'. Then you will see that unknown_3 is set to - 0x08f827fa. Look at the user immediately after that again, - and you will see that 0x00fffff is returned. This solves - the problem that you get access denied after having looked - at the user. - -- Volker - */ - usr->unknown_3 = 0x00ffffff; - - usr->logon_divs = pdb_get_logon_divs(pw); - usr->ptr_logon_hrs = pdb_get_hours(pw) ? 1 : 0; - usr->unknown_5 = pdb_get_unknown_5(pw); /* 0x0002 0000 */ - - if (pdb_get_pass_must_change_time(pw) == 0) { - usr->passmustchange=PASS_MUST_CHANGE_AT_NEXT_LOGON; - } else { - usr->passmustchange=0; - } - - - ZERO_STRUCT(usr->padding1); - ZERO_STRUCT(usr->padding2); - - init_unistr2(&usr->uni_user_name, user_name, len_user_name); - init_unistr2(&usr->uni_full_name, full_name, len_full_name); - init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir); - init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive); - init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script); - init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path); - init_unistr2(&usr->uni_acct_desc, description, len_description); - init_unistr2(&usr->uni_workstations, workstations, len_workstations); - init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str); - init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial); - - usr->unknown_6 = pdb_get_unknown_6(pw); - usr->padding4 = 0; - - if (pdb_get_hours(pw)) { - usr->logon_hrs.len = pdb_get_hours_len(pw); - memcpy(&usr->logon_hrs.hours, pdb_get_hours(pw), MAX_HOURS_LEN); - } else - memset(&usr->logon_hrs, 0xff, sizeof(usr->logon_hrs)); - - return NT_STATUS_OK; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_user_info21"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_time("logon_time ", &usr->logon_time, ps, depth)) - return False; - if(!smb_io_time("logoff_time ", &usr->logoff_time, ps, depth)) - return False; - if(!smb_io_time("pass_last_set_time ", &usr->pass_last_set_time, ps,depth)) - return False; - if(!smb_io_time("kickoff_time ", &usr->kickoff_time, ps, depth)) - return False; - if(!smb_io_time("pass_can_change_time ", &usr->pass_can_change_time, ps,depth)) - return False; - if(!smb_io_time("pass_must_change_time", &usr->pass_must_change_time, ps, depth)) - return False; - - if(!smb_io_unihdr("hdr_user_name ", &usr->hdr_user_name, ps, depth)) /* username unicode string header */ - return False; - if(!smb_io_unihdr("hdr_full_name ", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */ - return False; - if(!smb_io_unihdr("hdr_home_dir ", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */ - return False; - if(!smb_io_unihdr("hdr_dir_drive ", &usr->hdr_dir_drive, ps, depth)) /* home directory drive */ - return False; - if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */ - return False; - if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */ - return False; - if(!smb_io_unihdr("hdr_acct_desc ", &usr->hdr_acct_desc, ps, depth)) /* account desc */ - return False; - if(!smb_io_unihdr("hdr_workstations", &usr->hdr_workstations, ps, depth)) /* wkstas user can log on from */ - return False; - if(!smb_io_unihdr("hdr_unknown_str ", &usr->hdr_unknown_str, ps, depth)) /* unknown string */ - return False; - if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ - return False; - - if(!prs_uint8s(False, "lm_pwd ", ps, depth, usr->lm_pwd, sizeof(usr->lm_pwd))) - return False; - if(!prs_uint8s(False, "nt_pwd ", ps, depth, usr->nt_pwd, sizeof(usr->nt_pwd))) - return False; - - if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User ID */ - return False; - if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group ID */ - return False; - if(!prs_uint32("acb_info ", ps, depth, &usr->acb_info)) - return False; - - if(!prs_uint32("unknown_3 ", ps, depth, &usr->unknown_3)) - return False; - if(!prs_uint16("logon_divs ", ps, depth, &usr->logon_divs)) /* logon divisions per week */ - return False; - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_logon_hrs ", ps, depth, &usr->ptr_logon_hrs)) - return False; - - if(!prs_uint32("unknown_5 ", ps, depth, &usr->unknown_5)) - return False; - - if(!prs_uint8s(False, "padding1 ", ps, depth, usr->padding1, sizeof(usr->padding1))) - return False; - if(!prs_uint8("passmustchange ", ps, depth, &usr->passmustchange)) - return False; - if(!prs_uint8("padding2 ", ps, depth, &usr->padding2)) - return False; - - /* here begins pointed-to data */ - - if(!smb_io_unistr2("uni_user_name ", &usr->uni_user_name,usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */ - return False; - if(!smb_io_unistr2("uni_full_name ", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */ - return False; - if(!smb_io_unistr2("uni_home_dir ", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */ - return False; - if(!smb_io_unistr2("uni_dir_drive ", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */ - return False; - if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */ - return False; - if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */ - return False; - if(!smb_io_unistr2("uni_acct_desc ", &usr->uni_acct_desc, usr->hdr_acct_desc.buffer, ps, depth)) /* user desc unicode string */ - return False; - if(!smb_io_unistr2("uni_workstations", &usr->uni_workstations, usr->hdr_workstations.buffer, ps, depth)) /* worksations user can log on from */ - return False; - if(!smb_io_unistr2("uni_unknown_str ", &usr->uni_unknown_str, usr->hdr_unknown_str.buffer, ps, depth)) /* unknown string */ - return False; - if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */ - return False; - - /* ok, this is only guess-work (as usual) */ - if (usr->ptr_logon_hrs) { - if(!prs_align(ps)) - return False; - if(!prs_uint32("unknown_6 ", ps, depth, &usr->unknown_6)) - return False; - if(!prs_uint32("padding4 ", ps, depth, &usr->padding4)) - return False; - if(!sam_io_logon_hrs("logon_hrs", &usr->logon_hrs, ps, depth)) - return False; - } else if (UNMARSHALLING(ps)) { - usr->unknown_6 = 0; - usr->padding4 = 0; - } - - return True; -} - -void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw) -{ - int len_munged_dial; - const char* munged_dial = pdb_get_munged_dial(pw); - - len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0; - init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial); - init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial); - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL sam_io_user_info20(const char *desc, SAM_USER_INFO_20 *usr, - prs_struct *ps, int depth) -{ - if (usr == NULL) - return False; - - prs_debug(ps, depth, desc, "sam_io_user_info20"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unihdr("hdr_munged_dial ", &usr->hdr_munged_dial, ps, depth)) /* wkstas user can log on from */ - return False; - - if(!smb_io_unistr2("uni_munged_dial ", &usr->uni_munged_dial,usr->hdr_munged_dial.buffer, ps, depth)) /* worksations user can log on from */ - return False; - - return True; -} - -/******************************************************************* -inits a SAM_USERINFO_CTR structure. -********************************************************************/ - -NTSTATUS make_samr_userinfo_ctr_usr21(TALLOC_CTX *ctx, SAM_USERINFO_CTR * ctr, - uint16 switch_value, - SAM_USER_INFO_21 * usr) -{ - DEBUG(5, ("init_samr_userinfo_ctr\n")); - - ctr->switch_value = switch_value; - ctr->info.id = NULL; - - switch (switch_value) { - case 0x10: - ctr->info.id10 = (SAM_USER_INFO_10 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_10)); - if (ctr->info.id10 == NULL) - return NT_STATUS_NO_MEMORY; - - init_sam_user_info10(ctr->info.id10, usr->acb_info); - break; -#if 0 -/* whoops - got this wrong. i think. or don't understand what's happening. */ - case 0x11: - { - NTTIME expire; - info = (void *)&id11; - - expire.low = 0xffffffff; - expire.high = 0x7fffffff; - - ctr->info.id = (SAM_USER_INFO_11 *) talloc_zero(ctx,sizeof(*ctr->info.id11)); - init_sam_user_info11(ctr->info.id11, &expire, - "BROOKFIELDS$", /* name */ - 0x03ef, /* user rid */ - 0x201, /* group rid */ - 0x0080); /* acb info */ - - break; - } -#endif - case 0x12: - ctr->info.id12 = (SAM_USER_INFO_12 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_12)); - if (ctr->info.id12 == NULL) - return NT_STATUS_NO_MEMORY; - - init_sam_user_info12(ctr->info.id12, usr->lm_pwd, usr->nt_pwd); - break; - case 21: - { - SAM_USER_INFO_21 *cusr; - cusr = (SAM_USER_INFO_21 *)talloc_zero(ctx,sizeof(SAM_USER_INFO_21)); - ctr->info.id21 = cusr; - if (ctr->info.id21 == NULL) - return NT_STATUS_NO_MEMORY; - memcpy(cusr, usr, sizeof(*usr)); - memset(cusr->lm_pwd, 0, sizeof(cusr->lm_pwd)); - memset(cusr->nt_pwd, 0, sizeof(cusr->nt_pwd)); - break; - } - default: - DEBUG(4,("make_samr_userinfo_ctr: unsupported info\n")); - return NT_STATUS_INVALID_INFO_CLASS; - } - - return NT_STATUS_OK; -} - -/******************************************************************* -inits a SAM_USERINFO_CTR structure. -********************************************************************/ - -void init_samr_userinfo_ctr(SAM_USERINFO_CTR * ctr, uchar * sess_key, - uint16 switch_value, void *info) -{ - DEBUG(5, ("init_samr_userinfo_ctr\n")); - - ctr->switch_value = switch_value; - ctr->info.id = info; - - switch (switch_value) { - case 0x18: - SamOEMhash(ctr->info.id24->pass, sess_key, 516); - dump_data(100, (char *)sess_key, 16); - dump_data(100, (char *)ctr->info.id24->pass, 516); - break; - case 0x17: - SamOEMhash(ctr->info.id23->pass, sess_key, 516); - dump_data(100, (char *)sess_key, 16); - dump_data(100, (char *)ctr->info.id23->pass, 516); - break; - default: - DEBUG(4,("init_samr_userinfo_ctr: unsupported switch level\n")); - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL samr_io_userinfo_ctr(const char *desc, SAM_USERINFO_CTR **ppctr, - prs_struct *ps, int depth) -{ - BOOL ret; - SAM_USERINFO_CTR *ctr; - - prs_debug(ps, depth, desc, "samr_io_userinfo_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - ctr = (SAM_USERINFO_CTR *)prs_alloc_mem(ps,sizeof(SAM_USERINFO_CTR)); - if (ctr == NULL) - return False; - *ppctr = ctr; - } else { - ctr = *ppctr; - } - - /* lkclXXXX DO NOT ALIGN BEFORE READING SWITCH VALUE! */ - - if(!prs_uint16("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_align(ps)) - return False; - - ret = False; - - switch (ctr->switch_value) { - case 0x10: - if (UNMARSHALLING(ps)) - ctr->info.id10 = (SAM_USER_INFO_10 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_10)); - if (ctr->info.id10 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info10("", ctr->info.id10, ps, depth); - break; - case 0x11: - if (UNMARSHALLING(ps)) - ctr->info.id11 = (SAM_USER_INFO_11 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_11)); - - if (ctr->info.id11 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info11("", ctr->info.id11, ps, depth); - break; - case 0x12: - if (UNMARSHALLING(ps)) - ctr->info.id12 = (SAM_USER_INFO_12 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_12)); - - if (ctr->info.id12 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info12("", ctr->info.id12, ps, depth); - break; - case 20: - if (UNMARSHALLING(ps)) - ctr->info.id20 = (SAM_USER_INFO_20 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_20)); - - if (ctr->info.id20 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info20("", ctr->info.id20, ps, depth); - break; - case 21: - if (UNMARSHALLING(ps)) - ctr->info.id21 = (SAM_USER_INFO_21 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_21)); - - if (ctr->info.id21 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info21("", ctr->info.id21, ps, depth); - break; - case 23: - if (UNMARSHALLING(ps)) - ctr->info.id23 = (SAM_USER_INFO_23 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_23)); - - if (ctr->info.id23 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info23("", ctr->info.id23, ps, depth); - break; - case 24: - if (UNMARSHALLING(ps)) - ctr->info.id24 = (SAM_USER_INFO_24 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_24)); - - if (ctr->info.id24 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info24("", ctr->info.id24, ps, depth); - break; - case 25: - if (UNMARSHALLING(ps)) - ctr->info.id25 = (SAM_USER_INFO_25 *)prs_alloc_mem(ps,sizeof(SAM_USER_INFO_25)); - - if (ctr->info.id25 == NULL) { - DEBUG(2,("samr_io_userinfo_ctr: info pointer not initialised\n")); - return False; - } - ret = sam_io_user_info25("", ctr->info.id25, ps, depth); - break; - default: - DEBUG(2, ("samr_io_userinfo_ctr: unknown switch level 0x%x\n", ctr->switch_value)); - ret = False; - break; - } - - return ret; -} - -/******************************************************************* -inits a SAMR_R_QUERY_USERINFO structure. -********************************************************************/ - -void init_samr_r_query_userinfo(SAMR_R_QUERY_USERINFO * r_u, - SAM_USERINFO_CTR * ctr, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_query_userinfo\n")); - - r_u->ptr = 0; - r_u->ctr = NULL; - - if (NT_STATUS_IS_OK(status)) { - r_u->ptr = 1; - r_u->ctr = ctr; - } - - r_u->status = status; /* return status */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_query_userinfo(const char *desc, SAMR_R_QUERY_USERINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_query_userinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &r_u->ptr)) - return False; - - if (r_u->ptr != 0) { - if(!samr_io_userinfo_ctr("ctr", &r_u->ctr, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_SET_USERINFO structure. -********************************************************************/ - -void init_samr_q_set_userinfo(SAMR_Q_SET_USERINFO * q_u, - POLICY_HND *hnd, unsigned char sess_key[16], - uint16 switch_value, void *info) -{ - DEBUG(5, ("init_samr_q_set_userinfo\n")); - - q_u->pol = *hnd; - q_u->switch_value = switch_value; - init_samr_userinfo_ctr(q_u->ctr, sess_key, switch_value, info); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_set_userinfo(const char *desc, SAMR_Q_SET_USERINFO * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_set_userinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - smb_io_pol_hnd("pol", &(q_u->pol), ps, depth); - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_SET_USERINFO structure. -********************************************************************/ - -void init_samr_r_set_userinfo(SAMR_R_SET_USERINFO * r_u, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_set_userinfo\n")); - - r_u->status = status; /* return status */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_set_userinfo(const char *desc, SAMR_R_SET_USERINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_set_userinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_SET_USERINFO2 structure. -********************************************************************/ - -void init_samr_q_set_userinfo2(SAMR_Q_SET_USERINFO2 * q_u, - POLICY_HND *hnd, unsigned char sess_key[16], - uint16 switch_value, SAM_USERINFO_CTR * ctr) -{ - DEBUG(5, ("init_samr_q_set_userinfo2\n")); - - q_u->pol = *hnd; - q_u->switch_value = switch_value; - q_u->ctr = ctr; - - if (q_u->ctr != NULL) - q_u->ctr->switch_value = switch_value; - - switch (switch_value) { - case 0x12: - SamOEMhash(ctr->info.id12->lm_pwd, sess_key, 16); - SamOEMhash(ctr->info.id12->nt_pwd, sess_key, 16); - dump_data(100, (char *)sess_key, 16); - dump_data(100, (char *)ctr->info.id12->lm_pwd, 16); - dump_data(100, (char *)ctr->info.id12->nt_pwd, 16); - break; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_set_userinfo2(const char *desc, SAMR_Q_SET_USERINFO2 * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_set_userinfo2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("pol", &q_u->pol, ps, depth)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - if(!samr_io_userinfo_ctr("ctr", &q_u->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_SET_USERINFO2 structure. -********************************************************************/ - -void init_samr_r_set_userinfo2(SAMR_R_SET_USERINFO2 * r_u, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_set_userinfo2\n")); - - r_u->status = status; /* return status */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_set_userinfo2(const char *desc, SAMR_R_SET_USERINFO2 * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_set_userinfo2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_CONNECT structure. -********************************************************************/ - -void init_samr_q_connect(SAMR_Q_CONNECT * q_u, - char *srv_name, uint32 access_mask) -{ - int len_srv_name = strlen(srv_name); - - DEBUG(5, ("init_samr_q_connect\n")); - - /* make PDC server name \\server */ - q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0; - init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1); - - /* example values: 0x0000 0002 */ - q_u->access_mask = access_mask; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_connect(const char *desc, SAMR_Q_CONNECT * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_connect"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_connect(const char *desc, SAMR_R_CONNECT * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_connect"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_CONNECT4 structure. -********************************************************************/ - -void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u, - char *srv_name, uint32 access_mask) -{ - int len_srv_name = strlen(srv_name); - - DEBUG(5, ("init_samr_q_connect\n")); - - /* make PDC server name \\server */ - q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0; - init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1); - - /* Only value we've seen, possibly an address type ? */ - q_u->unk_0 = 2; - - /* example values: 0x0000 0002 */ - q_u->access_mask = access_mask; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_connect4(const char *desc, SAMR_Q_CONNECT4 * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_connect4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("unk_0", ps, depth, &q_u->unk_0)) - return False; - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_connect4(const char *desc, SAMR_R_CONNECT4 * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_connect4"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_CONNECT_ANON structure. -********************************************************************/ - -void init_samr_q_connect_anon(SAMR_Q_CONNECT_ANON * q_u) -{ - DEBUG(5, ("init_samr_q_connect_anon\n")); - - q_u->ptr = 1; - q_u->unknown_0 = 0x5c; /* server name (?!!) */ - q_u->unknown_1 = 0x01; - q_u->access_mask = 0x20; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_connect_anon(const char *desc, SAMR_Q_CONNECT_ANON * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_connect_anon"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &q_u->ptr)) - return False; - if(!prs_uint16("unknown_0", ps, depth, &q_u->unknown_0)) - return False; - if(!prs_uint16("unknown_1", ps, depth, &q_u->unknown_1)) - return False; - if(!prs_uint32("access_mask", ps, depth, &q_u->access_mask)) - return False; - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_connect_anon(const char *desc, SAMR_R_CONNECT_ANON * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_connect_anon"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("connect_pol", &r_u->connect_pol, ps, depth)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_Q_GET_DOM_PWINFO structure. -********************************************************************/ - -void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u, - char *srv_name) -{ - int len_srv_name = strlen(srv_name); - - DEBUG(5, ("init_samr_q_get_dom_pwinfo\n")); - - q_u->ptr = 1; - init_uni_hdr(&q_u->hdr_srv_name, len_srv_name); - init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_get_dom_pwinfo(const char *desc, SAMR_Q_GET_DOM_PWINFO * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_get_dom_pwinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &q_u->ptr)) - return False; - if (q_u->ptr != 0) { - if(!smb_io_unihdr("", &q_u->hdr_srv_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->hdr_srv_name.buffer, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_get_dom_pwinfo(const char *desc, SAMR_R_GET_DOM_PWINFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_get_dom_pwinfo"); - depth++; - - if(!prs_align(ps)) - return False; - - /* - * We need 16 bytes here according to tests. Don't know - * what they are, but the length is important for the singing - */ - - if(!prs_uint32("unk_0", ps, depth, &r_u->unk_0)) - return False; - if(!prs_uint32("unk_1", ps, depth, &r_u->unk_1)) - return False; - if(!prs_uint32("unk_2", ps, depth, &r_u->unk_2)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -make a SAMR_ENC_PASSWD structure. -********************************************************************/ - -void init_enc_passwd(SAMR_ENC_PASSWD * pwd, char pass[512]) -{ - ZERO_STRUCTP(pwd); - - if (pass == NULL) { - pwd->ptr = 0; - } else { - pwd->ptr = 1; - memcpy(pwd->pass, pass, sizeof(pwd->pass)); - } -} - -/******************************************************************* -reads or writes a SAMR_ENC_PASSWD structure. -********************************************************************/ - -BOOL samr_io_enc_passwd(const char *desc, SAMR_ENC_PASSWD * pwd, - prs_struct *ps, int depth) -{ - if (pwd == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_enc_passwd"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr", ps, depth, &pwd->ptr)) - return False; - - if (pwd->ptr != 0) { - if(!prs_uint8s(False, "pwd", ps, depth, pwd->pass, sizeof(pwd->pass))) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_ENC_HASH structure. -********************************************************************/ - -void init_enc_hash(SAMR_ENC_HASH * hsh, uchar hash[16]) -{ - ZERO_STRUCTP(hsh); - - if (hash == NULL) { - hsh->ptr = 0; - } else { - hsh->ptr = 1; - memcpy(hsh->hash, hash, sizeof(hsh->hash)); - } -} - -/******************************************************************* -reads or writes a SAMR_ENC_HASH structure. -********************************************************************/ - -BOOL samr_io_enc_hash(const char *desc, SAMR_ENC_HASH * hsh, - prs_struct *ps, int depth) -{ - if (hsh == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_enc_hash"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr ", ps, depth, &hsh->ptr)) - return False; - if (hsh->ptr != 0) { - if(!prs_uint8s(False, "hash", ps, depth, hsh->hash,sizeof(hsh->hash))) - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_GET_DOM_PWINFO structure. -********************************************************************/ - -void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u, - char *dest_host, char *user_name, - char nt_newpass[516], - uchar nt_oldhash[16], - char lm_newpass[516], - uchar lm_oldhash[16]) -{ - int len_dest_host = strlen(dest_host); - int len_user_name = strlen(user_name); - - DEBUG(5, ("init_samr_q_chgpasswd_user\n")); - - q_u->ptr_0 = 1; - init_uni_hdr(&q_u->hdr_dest_host, len_dest_host); - init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host); - init_uni_hdr(&q_u->hdr_user_name, len_user_name); - init_unistr2(&q_u->uni_user_name, user_name, len_user_name); - - init_enc_passwd(&q_u->nt_newpass, nt_newpass); - init_enc_hash(&q_u->nt_oldhash, nt_oldhash); - - q_u->unknown = 0x01; - - init_enc_passwd(&q_u->lm_newpass, lm_newpass); - init_enc_hash(&q_u->lm_oldhash, lm_oldhash); -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_chgpasswd_user(const char *desc, SAMR_Q_CHGPASSWD_USER * q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_chgpasswd_user"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_0", ps, depth, &q_u->ptr_0)) - return False; - - if(!smb_io_unihdr("", &q_u->hdr_dest_host, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->uni_dest_host, q_u->hdr_dest_host.buffer, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!smb_io_unihdr("", &q_u->hdr_user_name, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->uni_user_name, q_u->hdr_user_name.buffer,ps, depth)) - return False; - - if(!samr_io_enc_passwd("nt_newpass", &q_u->nt_newpass, ps, depth)) - return False; - if(!samr_io_enc_hash("nt_oldhash", &q_u->nt_oldhash, ps, depth)) - return False; - - if(!prs_uint32("unknown", ps, depth, &q_u->unknown)) - return False; - - if(!samr_io_enc_passwd("lm_newpass", &q_u->lm_newpass, ps, depth)) - return False; - if(!samr_io_enc_hash("lm_oldhash", &q_u->lm_oldhash, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_CHGPASSWD_USER structure. -********************************************************************/ - -void init_samr_r_chgpasswd_user(SAMR_R_CHGPASSWD_USER * r_u, NTSTATUS status) -{ - DEBUG(5, ("init_r_chgpasswd_user\n")); - - r_u->status = status; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_chgpasswd_user(const char *desc, SAMR_R_CHGPASSWD_USER * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_chgpasswd_user"); - 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_unknown_2e(SAMR_Q_UNKNOWN_2E *q_u, - POLICY_HND *domain_pol, uint16 switch_value) -{ - DEBUG(5, ("init_samr_q_unknown_2e\n")); - - q_u->domain_pol = *domain_pol; - q_u->switch_value = switch_value; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_unknown_2e(const char *desc, SAMR_Q_UNKNOWN_2E *q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_unknown_2e"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_DOMAIN_INFO structure. -********************************************************************/ - -void init_samr_r_samr_unknown_2e(SAMR_R_UNKNOWN_2E * r_u, - uint16 switch_value, SAM_UNK_CTR * ctr, - NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_samr_unknown_2e\n")); - - r_u->ptr_0 = 0; - r_u->switch_value = 0; - r_u->status = status; /* return status */ - - if (NT_STATUS_IS_OK(status)) { - r_u->switch_value = switch_value; - r_u->ptr_0 = 1; - r_u->ctr = ctr; - } -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_samr_unknown_2e(const char *desc, SAMR_R_UNKNOWN_2E * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_0 ", ps, depth, &r_u->ptr_0)) - return False; - - if (r_u->ptr_0 != 0 && r_u->ctr != NULL) { - if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) - return False; - if(!prs_align(ps)) - return False; - - switch (r_u->switch_value) { - case 0x0c: - if(!sam_io_unk_info12("unk_inf12", &r_u->ctr->info.inf12, ps, depth)) - return False; - break; - case 0x07: - if(!sam_io_unk_info7("unk_inf7",&r_u->ctr->info.inf7, ps,depth)) - return False; - break; - case 0x06: - if(!sam_io_unk_info6("unk_inf6",&r_u->ctr->info.inf6, ps,depth)) - return False; - break; - case 0x05: - if(!sam_io_unk_info5("unk_inf5",&r_u->ctr->info.inf5, ps,depth)) - return False; - break; - case 0x03: - if(!sam_io_unk_info3("unk_inf3",&r_u->ctr->info.inf3, ps,depth)) - return False; - break; - case 0x02: - if(!sam_io_unk_info2("unk_inf2",&r_u->ctr->info.inf2, ps,depth)) - return False; - break; - case 0x01: - if(!sam_io_unk_info1("unk_inf1",&r_u->ctr->info.inf1, ps,depth)) - return False; - break; - default: - DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n", - r_u->switch_value)); - r_u->status = NT_STATUS_INVALID_INFO_CLASS; - 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_set_domain_info(SAMR_Q_SET_DOMAIN_INFO *q_u, - POLICY_HND *domain_pol, uint16 switch_value, SAM_UNK_CTR *ctr) -{ - DEBUG(5, ("init_samr_q_set_domain_info\n")); - - q_u->domain_pol = *domain_pol; - q_u->switch_value0 = switch_value; - - q_u->switch_value = switch_value; - q_u->ctr = ctr; - -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_q_set_domain_info(const char *desc, SAMR_Q_SET_DOMAIN_INFO *q_u, - prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_q_set_domain_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("domain_pol", &q_u->domain_pol, ps, depth)) - return False; - - if(!prs_uint16("switch_value0", ps, depth, &q_u->switch_value0)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - - if(!prs_align(ps)) - return False; - - if ((q_u->ctr = (SAM_UNK_CTR *)prs_alloc_mem(ps, sizeof(SAM_UNK_CTR))) == NULL) - return False; - - switch (q_u->switch_value) { - - case 0x0c: - if(!sam_io_unk_info12("unk_inf12", &q_u->ctr->info.inf12, ps, depth)) - return False; - break; - case 0x07: - if(!sam_io_unk_info7("unk_inf7",&q_u->ctr->info.inf7, ps,depth)) - return False; - break; - case 0x06: - if(!sam_io_unk_info6("unk_inf6",&q_u->ctr->info.inf6, ps,depth)) - return False; - break; - case 0x05: - if(!sam_io_unk_info5("unk_inf5",&q_u->ctr->info.inf5, ps,depth)) - return False; - break; - case 0x03: - if(!sam_io_unk_info3("unk_inf3",&q_u->ctr->info.inf3, ps,depth)) - return False; - break; - case 0x02: - if(!sam_io_unk_info2("unk_inf2",&q_u->ctr->info.inf2, ps,depth)) - return False; - break; - case 0x01: - if(!sam_io_unk_info1("unk_inf1",&q_u->ctr->info.inf1, ps,depth)) - return False; - break; - default: - DEBUG(0, ("samr_io_r_samr_unknown_2e: unknown switch level 0x%x\n", - q_u->switch_value)); - return False; - } - - return True; -} - -/******************************************************************* -inits a SAMR_R_QUERY_DOMAIN_INFO structure. -********************************************************************/ - -void init_samr_r_set_domain_info(SAMR_R_SET_DOMAIN_INFO * r_u, NTSTATUS status) -{ - DEBUG(5, ("init_samr_r_set_domain_info\n")); - - r_u->status = status; /* return status */ -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -BOOL samr_io_r_set_domain_info(const char *desc, SAMR_R_SET_DOMAIN_INFO * r_u, - prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "samr_io_r_samr_unknown_2e"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_ntstatus("status", ps, depth, &r_u->status)) - return False; - - return True; -} diff --git a/source4/rpc_parse/parse_sec.c b/source4/rpc_parse/parse_sec.c deleted file mode 100644 index dbd72e5250..0000000000 --- a/source4/rpc_parse/parse_sec.c +++ /dev/null @@ -1,1028 +0,0 @@ -/* - * Unix SMB/Netbios implementation. - * Version 1.9. - * RPC Pipe client / server routines - * Copyright (C) Andrew Tridgell 1992-1998, - * Copyright (C) Jeremy R. Allison 1995-1998 - * Copyright (C) Luke Kenneth Casson Leighton 1996-1998, - * Copyright (C) Paul Ashton 1997-1998. - * - * 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 - -/******************************************************************* - Sets up a SEC_ACCESS structure. -********************************************************************/ - -void init_sec_access(SEC_ACCESS *t, uint32 mask) -{ - t->mask = mask; -} - -/******************************************************************* - Reads or writes a SEC_ACCESS structure. -********************************************************************/ - -BOOL sec_io_access(const char *desc, SEC_ACCESS *t, prs_struct *ps, int depth) -{ - if (t == NULL) - return False; - - prs_debug(ps, depth, desc, "sec_io_access"); - depth++; - - if(!prs_uint32("mask", ps, depth, &(t->mask))) - return False; - - return True; -} - -/******************************************************************* - Check if ACE has OBJECT type. -********************************************************************/ - -BOOL sec_ace_object(uint8 type) -{ - if (type == SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT || - type == SEC_ACE_TYPE_ACCESS_DENIED_OBJECT || - type == SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT || - type == SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT) { - return True; - } - return False; -} - -/******************************************************************* - copy a SEC_ACE structure. -********************************************************************/ -void sec_ace_copy(SEC_ACE *ace_dest, SEC_ACE *ace_src) -{ - ace_dest->type = ace_src->type; - ace_dest->flags = ace_src->flags; - ace_dest->size = ace_src->size; - ace_dest->info.mask = ace_src->info.mask; - ace_dest->obj_flags = ace_src->obj_flags; - memcpy(&ace_dest->obj_guid, &ace_src->obj_guid, GUID_SIZE); - memcpy(&ace_dest->inh_guid, &ace_src->inh_guid, GUID_SIZE); - sid_copy(&ace_dest->trustee, &ace_src->trustee); -} - -/******************************************************************* - Sets up a SEC_ACE structure. -********************************************************************/ - -void init_sec_ace(SEC_ACE *t, DOM_SID *sid, uint8 type, SEC_ACCESS mask, uint8 flag) -{ - t->type = type; - t->flags = flag; - t->size = sid_size(sid) + 8; - t->info = mask; - - ZERO_STRUCTP(&t->trustee); - sid_copy(&t->trustee, sid); -} - -/******************************************************************* - Reads or writes a SEC_ACE structure. -********************************************************************/ - -BOOL sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth) -{ - uint32 old_offset; - uint32 offset_ace_size; - - if (psa == NULL) - return False; - - prs_debug(ps, depth, desc, "sec_io_ace"); - depth++; - - old_offset = prs_offset(ps); - - if(!prs_uint8("type ", ps, depth, &psa->type)) - return False; - - if(!prs_uint8("flags", ps, depth, &psa->flags)) - return False; - - if(!prs_uint16_pre("size ", ps, depth, &psa->size, &offset_ace_size)) - return False; - - if(!sec_io_access("info ", &psa->info, ps, depth)) - return False; - - /* check whether object access is present */ - if (!sec_ace_object(psa->type)) { - if (!smb_io_dom_sid("trustee ", &psa->trustee , ps, depth)) - return False; - } else { - if (!prs_uint32("obj_flags", ps, depth, &psa->obj_flags)) - return False; - - if (psa->obj_flags & SEC_ACE_OBJECT_PRESENT) - if (!prs_uint8s(False, "obj_guid", ps, depth, psa->obj_guid.info, GUID_SIZE)) - return False; - - if (psa->obj_flags & SEC_ACE_OBJECT_INHERITED_PRESENT) - if (!prs_uint8s(False, "inh_guid", ps, depth, psa->inh_guid.info, GUID_SIZE)) - return False; - - if(!smb_io_dom_sid("trustee ", &psa->trustee , ps, depth)) - return False; - } - - if(!prs_uint16_post("size ", ps, depth, &psa->size, offset_ace_size, old_offset)) - return False; - return True; -} - -/******************************************************************* - adds new SID with its permissions to ACE list -********************************************************************/ - -NTSTATUS sec_ace_add_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, unsigned *num, DOM_SID *sid, uint32 mask) -{ - int i = 0; - - if (!ctx || !new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER; - - *num += 1; - - if((new[0] = (SEC_ACE *) talloc_zero(ctx, (*num) * sizeof(SEC_ACE))) == 0) - return NT_STATUS_NO_MEMORY; - - for (i = 0; i < *num - 1; i ++) - sec_ace_copy(&(*new)[i], &old[i]); - - (*new)[i].type = 0; - (*new)[i].flags = 0; - (*new)[i].size = SEC_ACE_HEADER_SIZE + sid_size(sid); - (*new)[i].info.mask = mask; - sid_copy(&(*new)[i].trustee, sid); - return NT_STATUS_OK; -} - -/******************************************************************* - modify SID's permissions at ACL -********************************************************************/ - -NTSTATUS sec_ace_mod_sid(SEC_ACE *ace, size_t num, DOM_SID *sid, uint32 mask) -{ - int i = 0; - - if (!ace || !sid) return NT_STATUS_INVALID_PARAMETER; - - for (i = 0; i < num; i ++) { - if (sid_compare(&ace[i].trustee, sid) == 0) { - ace[i].info.mask = mask; - return NT_STATUS_OK; - } - } - return NT_STATUS_NOT_FOUND; -} - -/******************************************************************* - delete SID from ACL -********************************************************************/ - -NTSTATUS sec_ace_del_sid(TALLOC_CTX *ctx, SEC_ACE **new, SEC_ACE *old, size_t *num, DOM_SID *sid) -{ - int i = 0; - int n_del = 0; - - if (!ctx || !new || !old || !sid || !num) return NT_STATUS_INVALID_PARAMETER; - - if((new[0] = (SEC_ACE *) talloc_zero(ctx, *num * sizeof(SEC_ACE))) == 0) - return NT_STATUS_NO_MEMORY; - - for (i = 0; i < *num; i ++) { - if (sid_compare(&old[i].trustee, sid) != 0) - sec_ace_copy(&(*new)[i], &old[i]); - else - n_del ++; - } - if (n_del == 0) - return NT_STATUS_NOT_FOUND; - else { - *num -= n_del; - return NT_STATUS_OK; - } -} - -/******************************************************************* - Create a SEC_ACL structure. -********************************************************************/ - -SEC_ACL *make_sec_acl(TALLOC_CTX *ctx, uint16 revision, int num_aces, SEC_ACE *ace_list) -{ - SEC_ACL *dst; - int i; - - if((dst = (SEC_ACL *)talloc_zero(ctx,sizeof(SEC_ACL))) == NULL) - return NULL; - - dst->revision = revision; - dst->num_aces = num_aces; - dst->size = SEC_ACL_HEADER_SIZE; - - /* Now we need to return a non-NULL address for the ace list even - if the number of aces required is zero. This is because there - is a distinct difference between a NULL ace and an ace with zero - entries in it. This is achieved by checking that num_aces is a - positive number. */ - - if ((num_aces) && - ((dst->ace = (SEC_ACE *)talloc(ctx, sizeof(SEC_ACE) * num_aces)) - == NULL)) { - return NULL; - } - - for (i = 0; i < num_aces; i++) { - dst->ace[i] = ace_list[i]; /* Structure copy. */ - dst->size += ace_list[i].size; - } - - return dst; -} - -/******************************************************************* - Duplicate a SEC_ACL structure. -********************************************************************/ - -SEC_ACL *dup_sec_acl(TALLOC_CTX *ctx, SEC_ACL *src) -{ - if(src == NULL) - return NULL; - - return make_sec_acl(ctx, src->revision, src->num_aces, src->ace); -} - -/******************************************************************* - Reads or writes a SEC_ACL structure. - - First of the xx_io_xx functions that allocates its data structures - for you as it reads them. -********************************************************************/ - -BOOL sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth) -{ - int i; - uint32 old_offset; - uint32 offset_acl_size; - SEC_ACL *psa; - - /* - * Note that the size is always a multiple of 4 bytes due to the - * nature of the data structure. Therefore the prs_align() calls - * have been removed as they through us off when doing two-layer - * marshalling such as in the printing code (NEW_BUFFER). --jerry - */ - - if (ppsa == NULL) - return False; - - psa = *ppsa; - - if(UNMARSHALLING(ps) && psa == NULL) { - /* - * This is a read and we must allocate the stuct to read into. - */ - if((psa = (SEC_ACL *)prs_alloc_mem(ps, sizeof(SEC_ACL))) == NULL) - return False; - *ppsa = psa; - } - - prs_debug(ps, depth, desc, "sec_io_acl"); - depth++; - - old_offset = prs_offset(ps); - - if(!prs_uint16("revision", ps, depth, &psa->revision)) - return False; - - if(!prs_uint16_pre("size ", ps, depth, &psa->size, &offset_acl_size)) - return False; - - if(!prs_uint32("num_aces ", ps, depth, &psa->num_aces)) - return False; - - if (UNMARSHALLING(ps)) { - /* - * Even if the num_aces is zero, allocate memory as there's a difference - * between a non-present DACL (allow all access) and a DACL with no ACE's - * (allow no access). - */ - if((psa->ace = (SEC_ACE *)prs_alloc_mem(ps,sizeof(psa->ace[0]) * (psa->num_aces+1))) == NULL) - return False; - } - - for (i = 0; i < psa->num_aces; i++) { - fstring tmp; - slprintf(tmp, sizeof(tmp)-1, "ace_list[%02d]: ", i); - if(!sec_io_ace(tmp, &psa->ace[i], ps, depth)) - return False; - } - - if(!prs_uint16_post("size ", ps, depth, &psa->size, offset_acl_size, old_offset)) - return False; - - return True; -} - -/******************************************************************* - Works out the linearization size of a SEC_DESC. -********************************************************************/ - -size_t sec_desc_size(SEC_DESC *psd) -{ - size_t offset; - - if (!psd) return 0; - - offset = SEC_DESC_HEADER_SIZE; - - /* don't align */ - - if (psd->owner_sid != NULL) - offset += sid_size(psd->owner_sid); - - if (psd->grp_sid != NULL) - offset += sid_size(psd->grp_sid); - - if (psd->sacl != NULL) - offset += psd->sacl->size; - - if (psd->dacl != NULL) - offset += psd->dacl->size; - - return offset; -} - -/******************************************************************* - Compares two SEC_ACE structures -********************************************************************/ - -BOOL sec_ace_equal(SEC_ACE *s1, SEC_ACE *s2) -{ - /* Trivial case */ - - if (!s1 && !s2) return True; - - /* Check top level stuff */ - - if (s1->type != s2->type || s1->flags != s2->flags || - s1->info.mask != s2->info.mask) { - return False; - } - - /* Check SID */ - - if (!sid_equal(&s1->trustee, &s2->trustee)) { - return False; - } - - return True; -} - -/******************************************************************* - Compares two SEC_ACL structures -********************************************************************/ - -BOOL sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2) -{ - int i, j; - - /* Trivial cases */ - - if (!s1 && !s2) return True; - if (!s1 || !s2) return False; - - /* Check top level stuff */ - - if (s1->revision != s2->revision) { - DEBUG(10, ("sec_acl_equal(): revision differs (%d != %d)\n", - s1->revision, s2->revision)); - return False; - } - - if (s1->num_aces != s2->num_aces) { - DEBUG(10, ("sec_acl_equal(): num_aces differs (%d != %d)\n", - s1->revision, s2->revision)); - return False; - } - - /* The ACEs could be in any order so check each ACE in s1 against - each ACE in s2. */ - - for (i = 0; i < s1->num_aces; i++) { - BOOL found = False; - - for (j = 0; j < s2->num_aces; j++) { - if (sec_ace_equal(&s1->ace[i], &s2->ace[j])) { - found = True; - break; - } - } - - if (!found) return False; - } - - return True; -} - -/******************************************************************* - Compares two SEC_DESC structures -********************************************************************/ - -BOOL sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2) -{ - /* Trivial case */ - - if (!s1 && !s2) { - goto done; - } - - /* Check top level stuff */ - - if (s1->revision != s2->revision) { - DEBUG(10, ("sec_desc_equal(): revision differs (%d != %d)\n", - s1->revision, s2->revision)); - return False; - } - - if (s1->type!= s2->type) { - DEBUG(10, ("sec_desc_equal(): type differs (%d != %d)\n", - s1->type, s2->type)); - return False; - } - - /* Check owner and group */ - - if (!sid_equal(s1->owner_sid, s2->owner_sid)) { - fstring str1, str2; - - sid_to_string(str1, s1->owner_sid); - sid_to_string(str2, s2->owner_sid); - - DEBUG(10, ("sec_desc_equal(): owner differs (%s != %s)\n", - str1, str2)); - return False; - } - - if (!sid_equal(s1->grp_sid, s2->grp_sid)) { - fstring str1, str2; - - sid_to_string(str1, s1->grp_sid); - sid_to_string(str2, s2->grp_sid); - - DEBUG(10, ("sec_desc_equal(): group differs (%s != %s)\n", - str1, str2)); - return False; - } - - /* Check ACLs present in one but not the other */ - - if ((s1->dacl && !s2->dacl) || (!s1->dacl && s2->dacl) || - (s1->sacl && !s2->sacl) || (!s1->sacl && s2->sacl)) { - DEBUG(10, ("sec_desc_equal(): dacl or sacl not present\n")); - return False; - } - - /* Sigh - we have to do it the hard way by iterating over all - the ACEs in the ACLs */ - - if (!sec_acl_equal(s1->dacl, s2->dacl) || - !sec_acl_equal(s1->sacl, s2->sacl)) { - DEBUG(10, ("sec_desc_equal(): dacl/sacl list not equal\n")); - return False; - } - - done: - DEBUG(10, ("sec_desc_equal(): secdescs are identical\n")); - return True; -} - -/******************************************************************* - Merge part of security descriptor old_sec in to the empty sections of - security descriptor new_sec. -********************************************************************/ - -SEC_DESC_BUF *sec_desc_merge(TALLOC_CTX *ctx, SEC_DESC_BUF *new_sdb, SEC_DESC_BUF *old_sdb) -{ - DOM_SID *owner_sid, *group_sid; - SEC_DESC_BUF *return_sdb; - SEC_ACL *dacl, *sacl; - SEC_DESC *psd = NULL; - uint16 secdesc_type; - size_t secdesc_size; - - /* Copy over owner and group sids. There seems to be no flag for - this so just check the pointer values. */ - - owner_sid = new_sdb->sec->owner_sid ? new_sdb->sec->owner_sid : - old_sdb->sec->owner_sid; - - group_sid = new_sdb->sec->grp_sid ? new_sdb->sec->grp_sid : - old_sdb->sec->grp_sid; - - secdesc_type = new_sdb->sec->type; - - /* Ignore changes to the system ACL. This has the effect of making - changes through the security tab audit button not sticking. - Perhaps in future Samba could implement these settings somehow. */ - - sacl = NULL; - secdesc_type &= ~SEC_DESC_SACL_PRESENT; - - /* Copy across discretionary ACL */ - - if (secdesc_type & SEC_DESC_DACL_PRESENT) { - dacl = new_sdb->sec->dacl; - } else { - dacl = old_sdb->sec->dacl; - } - - /* Create new security descriptor from bits */ - - psd = make_sec_desc(ctx, new_sdb->sec->revision, - owner_sid, group_sid, sacl, dacl, &secdesc_size); - - return_sdb = make_sec_desc_buf(ctx, secdesc_size, psd); - - return(return_sdb); -} - -/******************************************************************* - Tallocs a duplicate SID. -********************************************************************/ - -static DOM_SID *sid_dup_talloc(TALLOC_CTX *ctx, DOM_SID *src) -{ - DOM_SID *dst; - - if(!src) - return NULL; - - if((dst = talloc_zero(ctx, sizeof(DOM_SID))) != NULL) { - sid_copy( dst, src); - } - - return dst; -} - -/******************************************************************* - Creates a SEC_DESC structure -********************************************************************/ - -SEC_DESC *make_sec_desc(TALLOC_CTX *ctx, uint16 revision, - DOM_SID *owner_sid, DOM_SID *grp_sid, - SEC_ACL *sacl, SEC_ACL *dacl, size_t *sd_size) -{ - SEC_DESC *dst; - uint32 offset = 0; - uint32 offset_sid = SEC_DESC_HEADER_SIZE; - uint32 offset_acl = 0; - - *sd_size = 0; - - if(( dst = (SEC_DESC *)talloc_zero(ctx, sizeof(SEC_DESC))) == NULL) - return NULL; - - dst->revision = revision; - dst->type = SEC_DESC_SELF_RELATIVE; - - if (sacl) dst->type |= SEC_DESC_SACL_PRESENT; - if (dacl) dst->type |= SEC_DESC_DACL_PRESENT; - - dst->off_owner_sid = 0; - dst->off_grp_sid = 0; - dst->off_sacl = 0; - dst->off_dacl = 0; - - if(owner_sid && ((dst->owner_sid = sid_dup_talloc(ctx,owner_sid)) == NULL)) - goto error_exit; - - if(grp_sid && ((dst->grp_sid = sid_dup_talloc(ctx,grp_sid)) == NULL)) - goto error_exit; - - if(sacl && ((dst->sacl = dup_sec_acl(ctx, sacl)) == NULL)) - goto error_exit; - - if(dacl && ((dst->dacl = dup_sec_acl(ctx, dacl)) == NULL)) - goto error_exit; - - offset = 0; - - /* - * Work out the linearization sizes. - */ - if (dst->owner_sid != NULL) { - - if (offset == 0) - offset = SEC_DESC_HEADER_SIZE; - - offset += sid_size(dst->owner_sid); - } - - if (dst->grp_sid != NULL) { - - if (offset == 0) - offset = SEC_DESC_HEADER_SIZE; - - offset += sid_size(dst->grp_sid); - } - - if (dst->sacl != NULL) { - - offset_acl = SEC_DESC_HEADER_SIZE; - - dst->off_sacl = offset_acl; - offset_acl += dst->sacl->size; - offset += dst->sacl->size; - offset_sid += dst->sacl->size; - } - - if (dst->dacl != NULL) { - - if (offset_acl == 0) - offset_acl = SEC_DESC_HEADER_SIZE; - - dst->off_dacl = offset_acl; - offset_acl += dst->dacl->size; - offset += dst->dacl->size; - offset_sid += dst->dacl->size; - } - - *sd_size = (size_t)((offset == 0) ? SEC_DESC_HEADER_SIZE : offset); - - if (dst->owner_sid != NULL) - dst->off_owner_sid = offset_sid; - - /* sid_size() returns 0 if the sid is NULL so this is ok */ - - if (dst->grp_sid != NULL) - dst->off_grp_sid = offset_sid + sid_size(dst->owner_sid); - - return dst; - -error_exit: - - *sd_size = 0; - return NULL; -} - -/******************************************************************* - Duplicate a SEC_DESC structure. -********************************************************************/ - -SEC_DESC *dup_sec_desc( TALLOC_CTX *ctx, SEC_DESC *src) -{ - size_t dummy; - - if(src == NULL) - return NULL; - - return make_sec_desc( ctx, src->revision, - src->owner_sid, src->grp_sid, src->sacl, - src->dacl, &dummy); -} - -/******************************************************************* - Creates a SEC_DESC structure with typical defaults. -********************************************************************/ - -SEC_DESC *make_standard_sec_desc(TALLOC_CTX *ctx, DOM_SID *owner_sid, DOM_SID *grp_sid, - SEC_ACL *dacl, size_t *sd_size) -{ - return make_sec_desc(ctx, SEC_DESC_REVISION, - owner_sid, grp_sid, NULL, dacl, sd_size); -} - -/******************************************************************* - Reads or writes a SEC_DESC structure. - If reading and the *ppsd = NULL, allocates the structure. -********************************************************************/ - -BOOL sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth) -{ - uint32 old_offset; - uint32 max_offset = 0; /* after we're done, move offset to end */ - uint32 tmp_offset = 0; - - SEC_DESC *psd; - - if (ppsd == NULL) - return False; - - psd = *ppsd; - - if (psd == NULL) { - if(UNMARSHALLING(ps)) { - if((psd = (SEC_DESC *)prs_alloc_mem(ps,sizeof(SEC_DESC))) == NULL) - return False; - *ppsd = psd; - } else { - /* Marshalling - just ignore. */ - return True; - } - } - - prs_debug(ps, depth, desc, "sec_io_desc"); - depth++; - -#if 0 - /* - * if alignment is needed, should be done by the the - * caller. Not here. This caused me problems when marshalling - * printer info into a buffer. --jerry - */ - if(!prs_align(ps)) - return False; -#endif - - /* start of security descriptor stored for back-calc offset purposes */ - old_offset = prs_offset(ps); - - if(!prs_uint16("revision ", ps, depth, &psd->revision)) - return False; - - if(!prs_uint16("type ", ps, depth, &psd->type)) - return False; - - if(!prs_uint32("off_owner_sid", ps, depth, &psd->off_owner_sid)) - return False; - - if(!prs_uint32("off_grp_sid ", ps, depth, &psd->off_grp_sid)) - return False; - - if(!prs_uint32("off_sacl ", ps, depth, &psd->off_sacl)) - return False; - - if(!prs_uint32("off_dacl ", ps, depth, &psd->off_dacl)) - return False; - - max_offset = MAX(max_offset, prs_offset(ps)); - - if (psd->off_owner_sid != 0) { - - tmp_offset = prs_offset(ps); - if(!prs_set_offset(ps, old_offset + psd->off_owner_sid)) - return False; - - if (UNMARSHALLING(ps)) { - /* reading */ - if((psd->owner_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->owner_sid))) == NULL) - return False; - } - - if(!smb_io_dom_sid("owner_sid ", psd->owner_sid , ps, depth)) - return False; - - max_offset = MAX(max_offset, prs_offset(ps)); - - if (!prs_set_offset(ps,tmp_offset)) - return False; - } - - if (psd->off_grp_sid != 0) { - - tmp_offset = prs_offset(ps); - if(!prs_set_offset(ps, old_offset + psd->off_grp_sid)) - return False; - - if (UNMARSHALLING(ps)) { - /* reading */ - if((psd->grp_sid = (DOM_SID *)prs_alloc_mem(ps,sizeof(*psd->grp_sid))) == NULL) - return False; - } - - if(!smb_io_dom_sid("grp_sid", psd->grp_sid, ps, depth)) - return False; - - max_offset = MAX(max_offset, prs_offset(ps)); - - if (!prs_set_offset(ps,tmp_offset)) - return False; - } - - if ((psd->type & SEC_DESC_SACL_PRESENT) && psd->off_sacl) { - tmp_offset = prs_offset(ps); - if(!prs_set_offset(ps, old_offset + psd->off_sacl)) - return False; - if(!sec_io_acl("sacl", &psd->sacl, ps, depth)) - return False; - max_offset = MAX(max_offset, prs_offset(ps)); - if (!prs_set_offset(ps,tmp_offset)) - return False; - } - - - if ((psd->type & SEC_DESC_DACL_PRESENT) && psd->off_dacl != 0) { - tmp_offset = prs_offset(ps); - if(!prs_set_offset(ps, old_offset + psd->off_dacl)) - return False; - if(!sec_io_acl("dacl", &psd->dacl, ps, depth)) - return False; - max_offset = MAX(max_offset, prs_offset(ps)); - if (!prs_set_offset(ps,tmp_offset)) - return False; - } - - if(!prs_set_offset(ps, max_offset)) - return False; - return True; -} - -/******************************************************************* - Creates a SEC_DESC_BUF structure. -********************************************************************/ - -SEC_DESC_BUF *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, SEC_DESC *sec_desc) -{ - SEC_DESC_BUF *dst; - - if((dst = (SEC_DESC_BUF *)talloc_zero(ctx, sizeof(SEC_DESC_BUF))) == NULL) - return NULL; - - /* max buffer size (allocated size) */ - dst->max_len = (uint32)len; - dst->len = (uint32)len; - - if(sec_desc && ((dst->sec = dup_sec_desc(ctx, sec_desc)) == NULL)) { - return NULL; - } - - dst->ptr = 0x1; - - return dst; -} - -/******************************************************************* - Duplicates a SEC_DESC_BUF structure. -********************************************************************/ - -SEC_DESC_BUF *dup_sec_desc_buf(TALLOC_CTX *ctx, SEC_DESC_BUF *src) -{ - if(src == NULL) - return NULL; - - return make_sec_desc_buf( ctx, src->len, src->sec); -} - -/******************************************************************* - Reads or writes a SEC_DESC_BUF structure. -********************************************************************/ - -BOOL sec_io_desc_buf(const char *desc, SEC_DESC_BUF **ppsdb, prs_struct *ps, int depth) -{ - uint32 off_len; - uint32 off_max_len; - uint32 old_offset; - uint32 size; - SEC_DESC_BUF *psdb; - - if (ppsdb == NULL) - return False; - - psdb = *ppsdb; - - if (UNMARSHALLING(ps) && psdb == NULL) { - if((psdb = (SEC_DESC_BUF *)prs_alloc_mem(ps,sizeof(SEC_DESC_BUF))) == NULL) - return False; - *ppsdb = psdb; - } - - prs_debug(ps, depth, desc, "sec_io_desc_buf"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32_pre("max_len", ps, depth, &psdb->max_len, &off_max_len)) - return False; - - if(!prs_uint32 ("ptr ", ps, depth, &psdb->ptr)) - return False; - - if(!prs_uint32_pre("len ", ps, depth, &psdb->len, &off_len)) - return False; - - old_offset = prs_offset(ps); - - /* reading, length is non-zero; writing, descriptor is non-NULL */ - if ((UNMARSHALLING(ps) && psdb->len != 0) || (MARSHALLING(ps) && psdb->sec != NULL)) { - if(!sec_io_desc("sec ", &psdb->sec, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - size = prs_offset(ps) - old_offset; - if(!prs_uint32_post("max_len", ps, depth, &psdb->max_len, off_max_len, size == 0 ? psdb->max_len : size)) - return False; - - if(!prs_uint32_post("len ", ps, depth, &psdb->len, off_len, size)) - return False; - - return True; -} - -/******************************************************************* - adds new SID with its permissions to SEC_DESC -********************************************************************/ - -NTSTATUS sec_desc_add_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, uint32 mask, size_t *sd_size) -{ - SEC_DESC *sd = 0; - SEC_ACL *dacl = 0; - SEC_ACE *ace = 0; - NTSTATUS status; - - *sd_size = 0; - - if (!ctx || !psd || !sid || !sd_size) return NT_STATUS_INVALID_PARAMETER; - - status = sec_ace_add_sid(ctx, &ace, psd[0]->dacl->ace, &psd[0]->dacl->num_aces, sid, mask); - - if (!NT_STATUS_IS_OK(status)) - return status; - - if (!(dacl = make_sec_acl(ctx, psd[0]->dacl->revision, psd[0]->dacl->num_aces, ace))) - return NT_STATUS_UNSUCCESSFUL; - - if (!(sd = make_sec_desc(ctx, psd[0]->revision, psd[0]->owner_sid, - psd[0]->grp_sid, psd[0]->sacl, dacl, sd_size))) - return NT_STATUS_UNSUCCESSFUL; - - *psd = sd; - sd = 0; - return NT_STATUS_OK; -} - -/******************************************************************* - modify SID's permissions at SEC_DESC -********************************************************************/ - -NTSTATUS sec_desc_mod_sid(SEC_DESC *sd, DOM_SID *sid, uint32 mask) -{ - NTSTATUS status; - - if (!sd || !sid) return NT_STATUS_INVALID_PARAMETER; - - status = sec_ace_mod_sid(sd->dacl->ace, sd->dacl->num_aces, sid, mask); - - if (!NT_STATUS_IS_OK(status)) - return status; - - return NT_STATUS_OK; -} - -/******************************************************************* - delete SID from SEC_DESC -********************************************************************/ - -NTSTATUS sec_desc_del_sid(TALLOC_CTX *ctx, SEC_DESC **psd, DOM_SID *sid, size_t *sd_size) -{ - SEC_DESC *sd = 0; - SEC_ACL *dacl = 0; - SEC_ACE *ace = 0; - NTSTATUS status; - - *sd_size = 0; - - if (!ctx || !psd[0] || !sid || !sd_size) return NT_STATUS_INVALID_PARAMETER; - - status = sec_ace_del_sid(ctx, &ace, psd[0]->dacl->ace, &psd[0]->dacl->num_aces, sid); - - if (!NT_STATUS_IS_OK(status)) - return status; - - if (!(dacl = make_sec_acl(ctx, psd[0]->dacl->revision, psd[0]->dacl->num_aces, ace))) - return NT_STATUS_UNSUCCESSFUL; - - if (!(sd = make_sec_desc(ctx, psd[0]->revision, psd[0]->owner_sid, - psd[0]->grp_sid, psd[0]->sacl, dacl, sd_size))) - return NT_STATUS_UNSUCCESSFUL; - - *psd = sd; - sd = 0; - return NT_STATUS_OK; -} diff --git a/source4/rpc_parse/parse_spoolss.c b/source4/rpc_parse/parse_spoolss.c deleted file mode 100644 index 47737908f0..0000000000 --- a/source4/rpc_parse/parse_spoolss.c +++ /dev/null @@ -1,7751 +0,0 @@ -/* - * 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) Jean François Micouleau 1998-2000, - * Copyright (C) Gerald Carter 2000-2002, - * Copyright (C) Tim Potter 2001-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 - -/******************************************************************* -return the length of a UNISTR string. -********************************************************************/ - -static uint32 str_len_uni(UNISTR *source) -{ - uint32 i=0; - - if (!source->buffer) - return 0; - - while (source->buffer[i]) - i++; - - return i; -} - -/******************************************************************* -This should be moved in a more generic lib. -********************************************************************/ - -BOOL spoolss_io_system_time(const char *desc, prs_struct *ps, int depth, SYSTEMTIME *systime) -{ - if(!prs_uint16("year", ps, depth, &systime->year)) - return False; - if(!prs_uint16("month", ps, depth, &systime->month)) - return False; - if(!prs_uint16("dayofweek", ps, depth, &systime->dayofweek)) - return False; - if(!prs_uint16("day", ps, depth, &systime->day)) - return False; - if(!prs_uint16("hour", ps, depth, &systime->hour)) - return False; - if(!prs_uint16("minute", ps, depth, &systime->minute)) - return False; - if(!prs_uint16("second", ps, depth, &systime->second)) - return False; - if(!prs_uint16("milliseconds", ps, depth, &systime->milliseconds)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime) -{ - systime->year=unixtime->tm_year+1900; - systime->month=unixtime->tm_mon+1; - systime->dayofweek=unixtime->tm_wday; - systime->day=unixtime->tm_mday; - systime->hour=unixtime->tm_hour; - systime->minute=unixtime->tm_min; - systime->second=unixtime->tm_sec; - systime->milliseconds=0; - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO structure. -********************************************************************/ - -static BOOL smb_io_doc_info_1(const char *desc, DOC_INFO_1 *info_1, prs_struct *ps, int depth) -{ - if (info_1 == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("p_docname", ps, depth, &info_1->p_docname)) - return False; - if(!prs_uint32("p_outputfile", ps, depth, &info_1->p_outputfile)) - return False; - if(!prs_uint32("p_datatype", ps, depth, &info_1->p_datatype)) - return False; - - if(!smb_io_unistr2("", &info_1->docname, info_1->p_docname, ps, depth)) - return False; - if(!smb_io_unistr2("", &info_1->outputfile, info_1->p_outputfile, ps, depth)) - return False; - if(!smb_io_unistr2("", &info_1->datatype, info_1->p_datatype, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO structure. -********************************************************************/ - -static BOOL smb_io_doc_info(const char *desc, DOC_INFO *info, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0; - - if (info == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &info->switch_value)) - return False; - - if(!prs_uint32("doc_info_X ptr", ps, depth, &useless_ptr)) - return False; - - switch (info->switch_value) - { - case 1: - if(!smb_io_doc_info_1("",&info->doc_info_1, ps, depth)) - return False; - break; - case 2: - /* - this is just a placeholder - - MSDN July 1998 says doc_info_2 is only on - Windows 95, and as Win95 doesn't do RPC to print - this case is nearly impossible - - Maybe one day with Windows for dishwasher 2037 ... - - */ - /* smb_io_doc_info_2("",&info->doc_info_2, ps, depth); */ - break; - default: - DEBUG(0,("Something is obviously wrong somewhere !\n")); - break; - } - - return True; -} - -/******************************************************************* -reads or writes an DOC_INFO_CONTAINER structure. -********************************************************************/ - -static BOOL smb_io_doc_info_container(const char *desc, DOC_INFO_CONTAINER *cont, prs_struct *ps, int depth) -{ - if (cont == NULL) return False; - - prs_debug(ps, depth, desc, "smb_io_doc_info_container"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &cont->level)) - return False; - - if(!smb_io_doc_info("",&cont->docinfo, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION TYPE structure. -********************************************************************/ - -/* NOTIFY_OPTION_TYPE and NOTIFY_OPTION_TYPE_DATA are really one - structure. The _TYPE structure is really the deferred referrants (i.e - the notify fields array) of the _TYPE structure. -tpot */ - -static BOOL smb_io_notify_option_type(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_notify_option_type"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!prs_uint16("type", ps, depth, &type->type)) - return False; - if(!prs_uint16("reserved0", ps, depth, &type->reserved0)) - return False; - if(!prs_uint32("reserved1", ps, depth, &type->reserved1)) - return False; - if(!prs_uint32("reserved2", ps, depth, &type->reserved2)) - return False; - if(!prs_uint32("count", ps, depth, &type->count)) - return False; - if(!prs_uint32("fields_ptr", ps, depth, &type->fields_ptr)) - return False; - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION TYPE DATA. -********************************************************************/ - -static BOOL smb_io_notify_option_type_data(const char *desc, SPOOL_NOTIFY_OPTION_TYPE *type, prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "smb_io_notify_option_type_data"); - depth++; - - /* if there are no fields just return */ - if (type->fields_ptr==0) - return True; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count2", ps, depth, &type->count2)) - return False; - - if (type->count2 != type->count) - DEBUG(4,("What a mess, count was %x now is %x !\n", type->count, type->count2)); - - /* parse the option type data */ - for(i=0;i<type->count2;i++) - if(!prs_uint16("fields",ps,depth,&type->fields[i])) - return False; - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION structure. -********************************************************************/ - -static BOOL smb_io_notify_option_type_ctr(const char *desc, SPOOL_NOTIFY_OPTION_TYPE_CTR *ctr , prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "smb_io_notify_option_type_ctr"); - depth++; - - if(!prs_uint32("count", ps, depth, &ctr->count)) - return False; - - /* reading */ - if (UNMARSHALLING(ps)) - if((ctr->type=(SPOOL_NOTIFY_OPTION_TYPE *)prs_alloc_mem(ps,ctr->count*sizeof(SPOOL_NOTIFY_OPTION_TYPE))) == NULL) - return False; - - /* the option type struct */ - for(i=0;i<ctr->count;i++) - if(!smb_io_notify_option_type("", &ctr->type[i] , ps, depth)) - return False; - - /* the type associated with the option type struct */ - for(i=0;i<ctr->count;i++) - if(!smb_io_notify_option_type_data("", &ctr->type[i] , ps, depth)) - return False; - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY OPTION structure. -********************************************************************/ - -static BOOL smb_io_notify_option(const char *desc, SPOOL_NOTIFY_OPTION *option, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_notify_option"); - depth++; - - if(!prs_uint32("version", ps, depth, &option->version)) - return False; - if(!prs_uint32("flags", ps, depth, &option->flags)) - return False; - if(!prs_uint32("count", ps, depth, &option->count)) - return False; - if(!prs_uint32("option_type_ptr", ps, depth, &option->option_type_ptr)) - return False; - - /* marshalling or unmarshalling, that would work */ - if (option->option_type_ptr!=0) { - if(!smb_io_notify_option_type_ctr("", &option->ctr ,ps, depth)) - return False; - } - else { - option->ctr.type=NULL; - option->ctr.count=0; - } - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY INFO DATA structure. -********************************************************************/ - -static BOOL smb_io_notify_info_data(const char *desc,SPOOL_NOTIFY_INFO_DATA *data, prs_struct *ps, int depth) -{ - uint32 useless_ptr=0x0FF0ADDE; - - prs_debug(ps, depth, desc, "smb_io_notify_info_data"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint16("type", ps, depth, &data->type)) - return False; - if(!prs_uint16("field", ps, depth, &data->field)) - return False; - - if(!prs_uint32("how many words", ps, depth, &data->size)) - return False; - if(!prs_uint32("id", ps, depth, &data->id)) - return False; - if(!prs_uint32("how many words", ps, depth, &data->size)) - return False; - - switch (data->enc_type) { - - /* One and two value data has two uint32 values */ - - case NOTIFY_ONE_VALUE: - case NOTIFY_TWO_VALUE: - - if(!prs_uint32("value[0]", ps, depth, &data->notify_data.value[0])) - return False; - if(!prs_uint32("value[1]", ps, depth, &data->notify_data.value[1])) - return False; - break; - - /* Pointers and strings have a string length and a - pointer. For a string the length is expressed as - the number of uint16 characters plus a trailing - \0\0. */ - - case NOTIFY_POINTER: - - if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length )) - return False; - if(!prs_uint32("pointer", ps, depth, &useless_ptr)) - return False; - - break; - - case NOTIFY_STRING: - - if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length)) - return False; - - if(!prs_uint32("pointer", ps, depth, &useless_ptr)) - return False; - - break; - - case NOTIFY_SECDESC: - if( !prs_uint32( "sd size", ps, depth, &data->notify_data.sd.size ) ) - return False; - if( !prs_uint32( "pointer", ps, depth, &useless_ptr ) ) - return False; - - break; - - default: - DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data\n", - data->enc_type)); - break; - } - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY INFO DATA structure. -********************************************************************/ - -BOOL smb_io_notify_info_data_strings(const char *desc,SPOOL_NOTIFY_INFO_DATA *data, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "smb_io_notify_info_data_strings"); - depth++; - - if(!prs_align(ps)) - return False; - - switch(data->enc_type) { - - /* No data for values */ - - case NOTIFY_ONE_VALUE: - case NOTIFY_TWO_VALUE: - - break; - - /* Strings start with a length in uint16s */ - - case NOTIFY_STRING: - - if (UNMARSHALLING(ps)) { - data->notify_data.data.string = - (uint16 *)prs_alloc_mem(ps, data->notify_data.data.length); - - if (!data->notify_data.data.string) - return False; - } - - if (MARSHALLING(ps)) - data->notify_data.data.length /= 2; - - if(!prs_uint32("string length", ps, depth, &data->notify_data.data.length)) - return False; - - if (!prs_uint16uni(True, "string", ps, depth, data->notify_data.data.string, - data->notify_data.data.length)) - return False; - - if (MARSHALLING(ps)) - data->notify_data.data.length *= 2; - - break; - - case NOTIFY_POINTER: - - if (UNMARSHALLING(ps)) { - data->notify_data.data.string = - (uint16 *)prs_alloc_mem(ps, data->notify_data.data.length); - - if (!data->notify_data.data.string) - return False; - } - - if(!prs_uint8s(True,"buffer",ps,depth,(uint8*)data->notify_data.data.string,data->notify_data.data.length)) - return False; - - break; - - case NOTIFY_SECDESC: - if( !prs_uint32("secdesc size ", ps, depth, &data->notify_data.sd.size ) ) - return False; - if ( !sec_io_desc( "sec_desc", &data->notify_data.sd.desc, ps, depth ) ) - return False; - break; - - default: - DEBUG(3, ("invalid enc_type %d for smb_io_notify_info_data_strings\n", - data->enc_type)); - break; - } - -#if 0 - if (isvalue==False) { - - /* length of string in unicode include \0 */ - x=data->notify_data.data.length+1; - - if (data->field != 16) - if(!prs_uint32("string length", ps, depth, &x )) - return False; - - if (MARSHALLING(ps)) { - /* These are already in little endian format. Don't byte swap. */ - if (x == 1) { - - /* No memory allocated for this string - therefore following the data.string - pointer is a bad idea. Use a pointer to - the uint32 length union member to - provide a source for a unicode NULL */ - - if(!prs_uint8s(True,"string",ps,depth, (uint8 *)&data->notify_data.data.length,x*2)) - return False; - } else { - - if (data->field == 16) - x /= 2; - - if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x)) - return False; - } - } else { - - /* Tallocate memory for string */ - - data->notify_data.data.string = (uint16 *)prs_alloc_mem(ps, x * 2); - if (!data->notify_data.data.string) - return False; - - if(!prs_uint16uni(True,"string",ps,depth,data->notify_data.data.string,x)) - return False; - } - } - -#endif - -#if 0 /* JERRY */ - /* Win2k does not seem to put this parse align here */ - if(!prs_align(ps)) - return False; -#endif - - return True; -} - -/******************************************************************* -reads or writes an NOTIFY INFO structure. -********************************************************************/ - -static BOOL smb_io_notify_info(const char *desc, SPOOL_NOTIFY_INFO *info, prs_struct *ps, int depth) -{ - int i; - - prs_debug(ps, depth, desc, "smb_io_notify_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("count", ps, depth, &info->count)) - return False; - if(!prs_uint32("version", ps, depth, &info->version)) - return False; - if(!prs_uint32("flags", ps, depth, &info->flags)) - return False; - if(!prs_uint32("count", ps, depth, &info->count)) - return False; - - for (i=0;i<info->count;i++) { - if(!smb_io_notify_info_data(desc, &info->data[i], ps, depth)) - return False; - } - - /* now do the strings at the end of the stream */ - for (i=0;i<info->count;i++) { - if(!smb_io_notify_info_data_strings(desc, &info->data[i], ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -********************************************************************/ - -static BOOL spool_io_user_level_1(const char *desc, SPOOL_USER_1 *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - /* reading */ - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(q_u); - - if (!prs_align(ps)) - return False; - if (!prs_uint32("size", ps, depth, &q_u->size)) - return False; - if (!prs_uint32("client_name_ptr", ps, depth, &q_u->client_name_ptr)) - return False; - if (!prs_uint32("user_name_ptr", ps, depth, &q_u->user_name_ptr)) - return False; - if (!prs_uint32("build", ps, depth, &q_u->build)) - return False; - if (!prs_uint32("major", ps, depth, &q_u->major)) - return False; - if (!prs_uint32("minor", ps, depth, &q_u->minor)) - return False; - if (!prs_uint32("processor", ps, depth, &q_u->processor)) - return False; - - if (!smb_io_unistr2("", &q_u->client_name, q_u->client_name_ptr, ps, depth)) - return False; - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("", &q_u->user_name, q_u->user_name_ptr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -static BOOL spool_io_user_level(const char *desc, SPOOL_USER_CTR *q_u, prs_struct *ps, int depth) -{ - if (q_u==NULL) - return False; - - prs_debug(ps, depth, desc, "spool_io_user_level"); - depth++; - - if (!prs_align(ps)) - return False; - - /* From looking at many captures in ethereal, it looks like - the level and ptr fields should be transposed. -tpot */ - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - if (!prs_uint32("ptr", ps, depth, &q_u->ptr)) - return False; - - switch (q_u->level) { - case 1: - if (!spool_io_user_level_1("", &q_u->user1, ps, depth)) - return False; - break; - default: - return False; - } - - return True; -} - -/******************************************************************* - * read or write a DEVICEMODE struct. - * on reading allocate memory for the private member - ********************************************************************/ - -#define DM_NUM_OPTIONAL_FIELDS 8 - -BOOL spoolss_io_devmode(const char *desc, prs_struct *ps, int depth, DEVICEMODE *devmode) -{ - uint32 available_space; /* size of the device mode left to parse */ - /* only important on unmarshalling */ - int i = 0; - - struct optional_fields { - fstring name; - uint32* field; - } opt_fields[DM_NUM_OPTIONAL_FIELDS] = { - { "icmmethod", NULL }, - { "icmintent", NULL }, - { "mediatype", NULL }, - { "dithertype", NULL }, - { "reserved1", NULL }, - { "reserved2", NULL }, - { "panningwidth", NULL }, - { "panningheight", NULL } - }; - - /* assign at run time to keep non-gcc compilers happy */ - - opt_fields[0].field = &devmode->icmmethod; - opt_fields[1].field = &devmode->icmintent; - opt_fields[2].field = &devmode->mediatype; - opt_fields[3].field = &devmode->dithertype; - opt_fields[4].field = &devmode->reserved1; - opt_fields[5].field = &devmode->reserved2; - opt_fields[6].field = &devmode->panningwidth; - opt_fields[7].field = &devmode->panningheight; - - - prs_debug(ps, depth, desc, "spoolss_io_devmode"); - depth++; - - if (UNMARSHALLING(ps)) { - devmode->devicename.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) ); - if (devmode->devicename.buffer == NULL) - return False; - } - - if (!prs_uint16uni(True,"devicename", ps, depth, devmode->devicename.buffer, 32)) - return False; - - if (!prs_uint16("specversion", ps, depth, &devmode->specversion)) - return False; - - /* Sanity Check - look for unknown specversions, but don't fail if we see one. - Let the size determine that */ - - switch (devmode->specversion) { - /* list of observed spec version's */ - case 0x0320: - case 0x0400: - case 0x0401: - case 0x040d: - break; - - default: - DEBUG(0,("spoolss_io_devmode: Unknown specversion in devicemode [0x%x]\n", - devmode->specversion)); - DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n")); - break; - } - - - if (!prs_uint16("driverversion", ps, depth, &devmode->driverversion)) - return False; - if (!prs_uint16("size", ps, depth, &devmode->size)) - return False; - if (!prs_uint16("driverextra", ps, depth, &devmode->driverextra)) - return False; - if (!prs_uint32("fields", ps, depth, &devmode->fields)) - return False; - if (!prs_uint16("orientation", ps, depth, &devmode->orientation)) - return False; - if (!prs_uint16("papersize", ps, depth, &devmode->papersize)) - return False; - if (!prs_uint16("paperlength", ps, depth, &devmode->paperlength)) - return False; - if (!prs_uint16("paperwidth", ps, depth, &devmode->paperwidth)) - return False; - if (!prs_uint16("scale", ps, depth, &devmode->scale)) - return False; - if (!prs_uint16("copies", ps, depth, &devmode->copies)) - return False; - if (!prs_uint16("defaultsource", ps, depth, &devmode->defaultsource)) - return False; - if (!prs_uint16("printquality", ps, depth, &devmode->printquality)) - return False; - if (!prs_uint16("color", ps, depth, &devmode->color)) - return False; - if (!prs_uint16("duplex", ps, depth, &devmode->duplex)) - return False; - if (!prs_uint16("yresolution", ps, depth, &devmode->yresolution)) - return False; - if (!prs_uint16("ttoption", ps, depth, &devmode->ttoption)) - return False; - if (!prs_uint16("collate", ps, depth, &devmode->collate)) - return False; - - if (UNMARSHALLING(ps)) { - devmode->formname.buffer = (uint16 *)prs_alloc_mem(ps, 32 * sizeof(uint16) ); - if (devmode->formname.buffer == NULL) - return False; - } - - if (!prs_uint16uni(True, "formname", ps, depth, devmode->formname.buffer, 32)) - return False; - if (!prs_uint16("logpixels", ps, depth, &devmode->logpixels)) - return False; - if (!prs_uint32("bitsperpel", ps, depth, &devmode->bitsperpel)) - return False; - if (!prs_uint32("pelswidth", ps, depth, &devmode->pelswidth)) - return False; - if (!prs_uint32("pelsheight", ps, depth, &devmode->pelsheight)) - return False; - if (!prs_uint32("displayflags", ps, depth, &devmode->displayflags)) - return False; - if (!prs_uint32("displayfrequency", ps, depth, &devmode->displayfrequency)) - return False; - /* - * every device mode I've ever seen on the wire at least has up - * to the displayfrequency field. --jerry (05-09-2002) - */ - - /* add uint32's + uint16's + two UNICODE strings */ - - available_space = devmode->size - (sizeof(uint32)*6 + sizeof(uint16)*18 + sizeof(uint16)*64); - - /* Sanity check - we only have uint32's left tp parse */ - - if ( available_space && ((available_space % sizeof(uint32)) != 0) ) { - DEBUG(0,("spoolss_io_devmode: available_space [%d] no in multiple of 4 bytes (size = %d)!\n", - available_space, devmode->size)); - DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n")); - return False; - } - - /* - * Conditional parsing. Assume that the DeviceMode has been - * zero'd by the caller. - */ - - while ((available_space > 0) && (i < DM_NUM_OPTIONAL_FIELDS)) - { - DEBUG(10, ("spoolss_io_devmode: [%d] bytes left to parse in devmode\n", available_space)); - if (!prs_uint32(opt_fields[i].name, ps, depth, opt_fields[i].field)) - return False; - available_space -= sizeof(uint32); - i++; - } - - /* Sanity Check - we should no available space at this point unless - MS changes the device mode structure */ - - if (available_space) { - DEBUG(0,("spoolss_io_devmode: I've parsed all I know and there is still stuff left|\n")); - DEBUG(0,("spoolss_io_devmode: available_space = [%d], devmode_size = [%d]!\n", - available_space, devmode->size)); - DEBUG(0,("spoolss_io_devmode: please report to samba-technical@samba.org!\n")); - return False; - } - - - if (devmode->driverextra!=0) { - if (UNMARSHALLING(ps)) { - devmode->private=(uint8 *)prs_alloc_mem(ps, devmode->driverextra*sizeof(uint8)); - if(devmode->private == NULL) - return False; - DEBUG(7,("spoolss_io_devmode: allocated memory [%d] for private\n",devmode->driverextra)); - } - - DEBUG(7,("spoolss_io_devmode: parsing [%d] bytes of private\n",devmode->driverextra)); - if (!prs_uint8s(False, "private", ps, depth, - devmode->private, devmode->driverextra)) - return False; - } - - return True; -} - -/******************************************************************* - Read or write a DEVICEMODE container -********************************************************************/ - -static BOOL spoolss_io_devmode_cont(const char *desc, DEVMODE_CTR *dm_c, prs_struct *ps, int depth) -{ - if (dm_c==NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_devmode_cont"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("size", ps, depth, &dm_c->size)) - return False; - - if (!prs_uint32("devmode_ptr", ps, depth, &dm_c->devmode_ptr)) - return False; - - if (dm_c->size==0 || dm_c->devmode_ptr==0) { - if (UNMARSHALLING(ps)) - /* if while reading there is no DEVMODE ... */ - dm_c->devmode=NULL; - return True; - } - - /* so we have a DEVICEMODE to follow */ - if (UNMARSHALLING(ps)) { - DEBUG(9,("Allocating memory for spoolss_io_devmode\n")); - dm_c->devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE)); - if(dm_c->devmode == NULL) - return False; - } - - /* this is bad code, shouldn't be there */ - if (!prs_uint32("size", ps, depth, &dm_c->size)) - return False; - - if (!spoolss_io_devmode(desc, ps, depth, dm_c->devmode)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -static BOOL spoolss_io_printer_default(const char *desc, PRINTER_DEFAULT *pd, prs_struct *ps, int depth) -{ - if (pd==NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_printer_default"); - depth++; - - if (!prs_uint32("datatype_ptr", ps, depth, &pd->datatype_ptr)) - return False; - - if (!smb_io_unistr2("datatype", &pd->datatype, pd->datatype_ptr, ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_devmode_cont("", &pd->devmode_cont, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("access_required", ps, depth, &pd->access_required)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, - const fstring printername, - const fstring datatype, - uint32 access_required, - const fstring clientname, - const fstring user_name) -{ - DEBUG(5,("make_spoolss_q_open_printer_ex\n")); - q_u->printername_ptr = (printername!=NULL)?1:0; - init_unistr2(&q_u->printername, printername, strlen(printername)+1); - - q_u->printer_default.datatype_ptr = 0; -/* - q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0; - init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype)); -*/ - q_u->printer_default.devmode_cont.size=0; - q_u->printer_default.devmode_cont.devmode_ptr=0; - q_u->printer_default.devmode_cont.devmode=NULL; - q_u->printer_default.access_required=access_required; - q_u->user_switch=1; - q_u->user_ctr.level=1; - q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.size=strlen(clientname)+strlen(user_name)+10; - q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; - q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; - q_u->user_ctr.user1.build=1381; - q_u->user_ctr.user1.major=2; - q_u->user_ctr.user1.minor=0; - q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_addprinterex( - TALLOC_CTX *mem_ctx, - SPOOL_Q_ADDPRINTEREX *q_u, - const char *srv_name, - const char* clientname, - const char* user_name, - uint32 level, - PRINTER_INFO_CTR *ctr) -{ - DEBUG(5,("make_spoolss_q_addprinterex\n")); - - if (!ctr) return False; - - ZERO_STRUCTP(q_u); - - q_u->server_name_ptr = (srv_name!=NULL)?1:0; - init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)); - - q_u->level = level; - - q_u->info.level = level; - q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0; - switch (level) { - case 2: - /* init q_u->info.info2 from *info */ - if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) { - DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n")); - return False; - } - break; - default : - break; - } - - q_u->user_switch=1; - - q_u->user_ctr.level=1; - q_u->user_ctr.ptr=1; - q_u->user_ctr.user1.client_name_ptr = (clientname!=NULL)?1:0; - q_u->user_ctr.user1.user_name_ptr = (user_name!=NULL)?1:0; - q_u->user_ctr.user1.build=1381; - q_u->user_ctr.user1.major=2; - q_u->user_ctr.user1.minor=0; - q_u->user_ctr.user1.processor=0; - init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1); - init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1); - q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len + - q_u->user_ctr.user1.client_name.uni_str_len + 2; - - return True; -} - -/******************************************************************* -create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct -*******************************************************************/ - -BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2, - PRINTER_INFO_2 *info) -{ - - SPOOL_PRINTER_INFO_LEVEL_2 *inf; - - /* allocate the necessary memory */ - if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_2*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_2)))) { - DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n")); - return False; - } - - inf->servername_ptr = (info->servername.buffer!=NULL)?1:0; - inf->printername_ptr = (info->printername.buffer!=NULL)?1:0; - inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0; - inf->portname_ptr = (info->portname.buffer!=NULL)?1:0; - inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0; - inf->comment_ptr = (info->comment.buffer!=NULL)?1:0; - inf->location_ptr = (info->location.buffer!=NULL)?1:0; - inf->devmode_ptr = (info->devmode!=NULL)?1:0; - inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0; - inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0; - inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0; - inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0; - inf->secdesc_ptr = (info->secdesc!=NULL)?1:0; - inf->attributes = info->attributes; - inf->priority = info->priority; - inf->default_priority = info->defaultpriority; - inf->starttime = info->starttime; - inf->untiltime = info->untiltime; - inf->cjobs = info->cjobs; - inf->averageppm = info->averageppm; - init_unistr2_from_unistr(&inf->servername, &info->servername); - init_unistr2_from_unistr(&inf->printername, &info->printername); - init_unistr2_from_unistr(&inf->sharename, &info->sharename); - init_unistr2_from_unistr(&inf->portname, &info->portname); - init_unistr2_from_unistr(&inf->drivername, &info->drivername); - init_unistr2_from_unistr(&inf->comment, &info->comment); - init_unistr2_from_unistr(&inf->location, &info->location); - init_unistr2_from_unistr(&inf->sepfile, &info->sepfile); - init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor); - init_unistr2_from_unistr(&inf->datatype, &info->datatype); - init_unistr2_from_unistr(&inf->parameters, &info->parameters); - init_unistr2_from_unistr(&inf->datatype, &info->datatype); - - *spool_info2 = inf; - - return True; -} - - -/******************************************************************* - * read a structure. - * called from spoolss_q_open_printer_ex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_open_printer(const char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_open_printer"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_open_printer_ex (srv_spoolss.c) - * called from spoolss_open_printer_ex (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_open_printer(const char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_open_printer"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth)) - return False; - - if (!prs_werror("status code", ps, depth, &(r_u->status))) - return False; - - return True; -} - - -/******************************************************************* - * read a structure. - * called from spoolss_q_open_printer_ex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_open_printer_ex(const char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("printername_ptr", ps, depth, &q_u->printername_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->printername, q_u->printername_ptr, ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth)) - return False; - - if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch)) - return False; - if (!spool_io_user_level("", &q_u->user_ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_open_printer_ex (srv_spoolss.c) - * called from spoolss_open_printer_ex (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_open_printer_ex(const char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth)) - return False; - - if (!prs_werror("status code", ps, depth, &(r_u->status))) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ -BOOL make_spoolss_q_deleteprinterdriver( - TALLOC_CTX *mem_ctx, - SPOOL_Q_DELETEPRINTERDRIVER *q_u, - const char *server, - const char* arch, - const char* driver -) -{ - DEBUG(5,("make_spoolss_q_deleteprinterdriver\n")); - - q_u->server_ptr = (server!=NULL)?1:0; - - /* these must be NULL terminated or else NT4 will - complain about invalid parameters --jerry */ - init_unistr2(&q_u->server, server, strlen(server)+1); - init_unistr2(&q_u->arch, arch, strlen(arch)+1); - init_unistr2(&q_u->driver, driver, strlen(driver)+1); - - - return True; -} - - -/******************************************************************* - * make a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, - const POLICY_HND *handle, - const char *valuename, uint32 size) -{ - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_q_getprinterdata\n")); - - q_u->handle = *handle; - init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1); - q_u->size = size; - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u, - const POLICY_HND *handle, - const char *keyname, - const char *valuename, uint32 size) -{ - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_q_getprinterdataex\n")); - - q_u->handle = *handle; - init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1); - init_unistr2(&q_u->keyname, keyname, strlen(keyname) + 1); - q_u->size = size; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_getprinterdata (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!prs_uint32("size", ps, depth, &q_u->size)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_deleteprinterdata (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinterdata(const char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_deleteprinterdata (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_deleteprinterdata(const char *desc, SPOOL_R_DELETEPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdata"); - depth++; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_deleteprinterdataex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinterdataex(const char *desc, SPOOL_Q_DELETEPRINTERDATAEX *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdataex"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - - if (!smb_io_unistr2("keyname ", &q_u->keyname, True, ps, depth)) - return False; - if (!smb_io_unistr2("valuename", &q_u->valuename, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_deleteprinterdataex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_deleteprinterdataex(const char *desc, SPOOL_R_DELETEPRINTERDATAEX *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdataex"); - depth++; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_getprinterdata (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_getprinterdata(const char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdata"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("type", ps, depth, &r_u->type)) - return False; - if (!prs_uint32("size", ps, depth, &r_u->size)) - return False; - - if (UNMARSHALLING(ps) && r_u->size) { - r_u->data = prs_alloc_mem(ps, r_u->size); - if(!r_u->data) - return False; - } - - if (!prs_uint8s( False, "data", ps, depth, r_u->data, r_u->size )) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * make a structure. - ********************************************************************/ - -BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd) -{ - if (q_u == NULL) return False; - - DEBUG(5,("make_spoolss_q_closeprinter\n")); - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - return True; -} - -/******************************************************************* - * read a structure. - * called from static spoolss_q_abortprinter (srv_spoolss.c) - * called from spoolss_abortprinter (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_abortprinter(const char *desc, SPOOL_Q_ABORTPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_abortprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_abortprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_abortprinter(const char *desc, SPOOL_R_ABORTPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_abortprinter"); - depth++; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from static spoolss_q_deleteprinter (srv_spoolss.c) - * called from spoolss_deleteprinter (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinter(const char *desc, SPOOL_Q_DELETEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_deleteprinter (srv_spoolss.c) - * called from spoolss_deleteprinter (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_deleteprinter(const char *desc, SPOOL_R_DELETEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth)) - return False; - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - -/******************************************************************* - * read a structure. - * called from api_spoolss_deleteprinterdriver (srv_spoolss.c) - * called from spoolss_deleteprinterdriver (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinterdriver(const char *desc, SPOOL_Q_DELETEPRINTERDRIVER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriver"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr)) - return False; - if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth)) - return False; - if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth)) - return False; - - - return True; -} - - -/******************************************************************* - * write a structure. - ********************************************************************/ -BOOL spoolss_io_r_deleteprinterdriver(const char *desc, SPOOL_R_DELETEPRINTERDRIVER *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriver"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - -/******************************************************************* - * read a structure. - * called from api_spoolss_deleteprinterdriver (srv_spoolss.c) - * called from spoolss_deleteprinterdriver (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinterdriverex(const char *desc, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdriverex"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr)) - return False; - if(!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("arch", &q_u->arch, True, ps, depth)) - return False; - if(!smb_io_unistr2("driver", &q_u->driver, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("delete_flags ", ps, depth, &q_u->delete_flags)) - return False; - if(!prs_uint32("version ", ps, depth, &q_u->version)) - return False; - - - return True; -} - - -/******************************************************************* - * write a structure. - ********************************************************************/ -BOOL spoolss_io_r_deleteprinterdriverex(const char *desc, SPOOL_R_DELETEPRINTERDRIVEREX *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterdriverex"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - - -/******************************************************************* - * read a structure. - * called from static spoolss_q_closeprinter (srv_spoolss.c) - * called from spoolss_closeprinter (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_closeprinter(const char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_closeprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from static spoolss_r_closeprinter (srv_spoolss.c) - * called from spoolss_closeprinter (cli_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_closeprinter(const char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_closeprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth)) - return False; - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_startdocprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_startdocprinter(const char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_startdocprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - if(!smb_io_doc_info_container("",&q_u->doc_info_container, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_startdocprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_startdocprinter(const char *desc, SPOOL_R_STARTDOCPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_startdocprinter"); - depth++; - if(!prs_uint32("jobid", ps, depth, &r_u->jobid)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_enddocprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_enddocprinter(const char *desc, SPOOL_Q_ENDDOCPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_enddocprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_enddocprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_enddocprinter(const char *desc, SPOOL_R_ENDDOCPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enddocprinter"); - depth++; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_startpageprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_startpageprinter(const char *desc, SPOOL_Q_STARTPAGEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_startpageprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_startpageprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_startpageprinter(const char *desc, SPOOL_R_STARTPAGEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_startpageprinter"); - depth++; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_endpageprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_endpageprinter(const char *desc, SPOOL_Q_ENDPAGEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_endpageprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_endpageprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_endpageprinter(const char *desc, SPOOL_R_ENDPAGEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_endpageprinter"); - depth++; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_writeprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_writeprinter(const char *desc, SPOOL_Q_WRITEPRINTER *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_writeprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if(!prs_uint32("buffer_size", ps, depth, &q_u->buffer_size)) - return False; - - if (q_u->buffer_size!=0) - { - if (UNMARSHALLING(ps)) - q_u->buffer=(uint8 *)prs_alloc_mem(ps,q_u->buffer_size*sizeof(uint8)); - if(q_u->buffer == NULL) - return False; - if(!prs_uint8s(True, "buffer", ps, depth, q_u->buffer, q_u->buffer_size)) - return False; - } - if(!prs_align(ps)) - return False; - if(!prs_uint32("buffer_size2", ps, depth, &q_u->buffer_size2)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_writeprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_writeprinter(const char *desc, SPOOL_R_WRITEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_writeprinter"); - depth++; - if(!prs_uint32("buffer_written", ps, depth, &r_u->buffer_written)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_rffpcnex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_rffpcnex(const char *desc, SPOOL_Q_RFFPCNEX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_rffpcnex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("flags", ps, depth, &q_u->flags)) - return False; - if(!prs_uint32("options", ps, depth, &q_u->options)) - return False; - if(!prs_uint32("localmachine_ptr", ps, depth, &q_u->localmachine_ptr)) - return False; - if(!smb_io_unistr2("localmachine", &q_u->localmachine, q_u->localmachine_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("printerlocal", ps, depth, &q_u->printerlocal)) - return False; - - if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr)) - return False; - - if (q_u->option_ptr!=0) { - - if (UNMARSHALLING(ps)) - if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL) - return False; - - if(!smb_io_notify_option("notify option", q_u->option, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_rffpcnex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_rffpcnex(const char *desc, SPOOL_R_RFFPCNEX *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_rffpcnex"); - depth++; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_rfnpcnex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_rfnpcnex(const char *desc, SPOOL_Q_RFNPCNEX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_rfnpcnex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - if(!prs_uint32("change", ps, depth, &q_u->change)) - return False; - - if(!prs_uint32("option_ptr", ps, depth, &q_u->option_ptr)) - return False; - - if (q_u->option_ptr!=0) { - - if (UNMARSHALLING(ps)) - if((q_u->option=(SPOOL_NOTIFY_OPTION *)prs_alloc_mem(ps,sizeof(SPOOL_NOTIFY_OPTION))) == NULL) - return False; - - if(!smb_io_notify_option("notify option", q_u->option, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_rfnpcnex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_rfnpcnex(const char *desc, SPOOL_R_RFNPCNEX *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_rfnpcnex"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("info_ptr", ps, depth, &r_u->info_ptr)) - return False; - - if(!smb_io_notify_info("notify info", &r_u->info ,ps,depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * return the length of a uint16 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_uint16(uint16 *value) -{ - return (sizeof(*value)); -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_uint32(uint32 *value) -{ - return (sizeof(*value)); -} - -/******************************************************************* - * return the length of a NTTIME (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_nttime(NTTIME *value) -{ - return (sizeof(*value)); -} - -/******************************************************************* - * return the length of a UNICODE string in number of char, includes: - * - the leading zero - * - the relative pointer size - ********************************************************************/ - -static uint32 size_of_relative_string(UNISTR *string) -{ - uint32 size=0; - - size=str_len_uni(string); /* the string length */ - size=size+1; /* add the trailing zero */ - size=size*2; /* convert in char */ - size=size+4; /* add the size of the ptr */ - -#if 0 /* JERRY */ - /* - * Do not include alignment as Win2k does not align relative - * strings within a buffer --jerry - */ - /* Ensure size is 4 byte multiple (prs_align is being called...). */ - /* size += ((4 - (size & 3)) & 3); */ -#endif - - return size; -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_device_mode(DEVICEMODE *devmode) -{ - if (devmode==NULL) - return (4); - else - return (4+devmode->size+devmode->driverextra); -} - -/******************************************************************* - * return the length of a uint32 (obvious, but the code is clean) - ********************************************************************/ - -static uint32 size_of_systemtime(SYSTEMTIME *systime) -{ - if (systime==NULL) - return (4); - else - return (sizeof(SYSTEMTIME) +4); -} - -/******************************************************************* - * write a UNICODE string and its relative pointer. - * used by all the RPC structs passing a buffer - * - * As I'm a nice guy, I'm forcing myself to explain this code. - * MS did a good job in the overall spoolss code except in some - * functions where they are passing the API buffer directly in the - * RPC request/reply. That's to maintain compatiility at the API level. - * They could have done it the good way the first time. - * - * So what happen is: the strings are written at the buffer's end, - * in the reverse order of the original structure. Some pointers to - * the strings are also in the buffer. Those are relative to the - * buffer's start. - * - * If you don't understand or want to change that function, - * first get in touch with me: jfm@samba.org - * - ********************************************************************/ - -static BOOL smb_io_relstr(const char *desc, NEW_BUFFER *buffer, int depth, UNISTR *string) -{ - prs_struct *ps=&buffer->prs; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - buffer->string_at_end -= (size_of_relative_string(string) - 4); - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; -#if 0 /* JERRY */ - /* - * Win2k does not align strings in a buffer - * Tested against WinNT 4.0 SP 6a & 2k SP2 --jerry - */ - if (!prs_align(ps)) - return False; -#endif - buffer->string_at_end = prs_offset(ps); - - /* write the string */ - if (!smb_io_unistr(desc, string, ps, depth)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } - else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &(buffer->string_at_end))) - return False; - - if (buffer->string_at_end == 0) - return True; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end+buffer->struct_start)) - return False; - - /* read the string */ - if (!smb_io_unistr(desc, string, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - * write a array of UNICODE strings and its relative pointer. - * used by 2 RPC structs - ********************************************************************/ - -static BOOL smb_io_relarraystr(const char *desc, NEW_BUFFER *buffer, int depth, uint16 **string) -{ - UNISTR chaine; - - prs_struct *ps=&buffer->prs; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - uint16 *p; - uint16 *q; - uint16 zero=0; - p=*string; - q=*string; - - /* first write the last 0 */ - buffer->string_at_end -= 2; - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - - if(!prs_uint16("leading zero", ps, depth, &zero)) - return False; - - while (p && (*p!=0)) { - while (*q!=0) - q++; - - /* Yes this should be malloc not talloc. Don't change. */ - - chaine.buffer = malloc((q-p+1)*sizeof(uint16)); - if (chaine.buffer == NULL) - return False; - - memcpy(chaine.buffer, p, (q-p+1)*sizeof(uint16)); - - buffer->string_at_end -= (q-p+1)*sizeof(uint16); - - if(!prs_set_offset(ps, buffer->string_at_end)) { - SAFE_FREE(chaine.buffer); - return False; - } - - /* write the string */ - if (!smb_io_unistr(desc, &chaine, ps, depth)) { - SAFE_FREE(chaine.buffer); - return False; - } - q++; - p=q; - - SAFE_FREE(chaine.buffer); - } - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - - } else { - - /* UNMARSHALLING */ - - uint32 old_offset; - uint16 *chaine2=NULL; - int l_chaine=0; - int l_chaine2=0; - size_t realloc_size = 0; - - *string=NULL; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - do { - if (!smb_io_unistr(desc, &chaine, ps, depth)) - return False; - - l_chaine=str_len_uni(&chaine); - - /* we're going to add two more bytes here in case this - is the last string in the array and we need to add - an extra NULL for termination */ - if (l_chaine > 0) - { - uint16 *tc2; - - realloc_size = (l_chaine2+l_chaine+2)*sizeof(uint16); - - /* Yes this should be realloc - it's freed below. JRA */ - - if((tc2=(uint16 *)Realloc(chaine2, realloc_size)) == NULL) { - SAFE_FREE(chaine2); - return False; - } - else chaine2 = tc2; - memcpy(chaine2+l_chaine2, chaine.buffer, (l_chaine+1)*sizeof(uint16)); - l_chaine2+=l_chaine+1; - } - - } while(l_chaine!=0); - - /* the end should be bould NULL terminated so add - the second one here */ - if (chaine2) - { - chaine2[l_chaine2] = '\0'; - *string=(uint16 *)talloc_memdup(prs_get_mem_context(ps),chaine2,realloc_size); - SAFE_FREE(chaine2); - } - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - Parse a DEVMODE structure and its relative pointer. -********************************************************************/ - -static BOOL smb_io_relsecdesc(const char *desc, NEW_BUFFER *buffer, int depth, SEC_DESC **secdesc) -{ - prs_struct *ps= &buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_relsecdesc"); - depth++; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - if (! *secdesc) { - relative_offset = 0; - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - return True; - } - - if (*secdesc != NULL) { - buffer->string_at_end -= sec_desc_size(*secdesc); - - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - /* write the secdesc */ - if (!sec_io_desc(desc, secdesc, ps, depth)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - } - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - /* read the sd */ - if (!sec_io_desc(desc, secdesc, ps, depth)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - Parse a DEVMODE structure and its relative pointer. -********************************************************************/ - -static BOOL smb_io_reldevmode(const char *desc, NEW_BUFFER *buffer, int depth, DEVICEMODE **devmode) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_reldevmode"); - depth++; - - if (MARSHALLING(ps)) { - uint32 struct_offset = prs_offset(ps); - uint32 relative_offset; - - if (*devmode == NULL) { - relative_offset=0; - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - DEBUG(8, ("boing, the devmode was NULL\n")); - - return True; - } - - buffer->string_at_end -= ((*devmode)->size + (*devmode)->driverextra); - - if(!prs_set_offset(ps, buffer->string_at_end)) - return False; - - /* write the DEVMODE */ - if (!spoolss_io_devmode(desc, ps, depth, *devmode)) - return False; - - if(!prs_set_offset(ps, struct_offset)) - return False; - - relative_offset=buffer->string_at_end - buffer->struct_start; - /* write its offset */ - if (!prs_uint32("offset", ps, depth, &relative_offset)) - return False; - } - else { - uint32 old_offset; - - /* read the offset */ - if (!prs_uint32("offset", ps, depth, &buffer->string_at_end)) - return False; - if (buffer->string_at_end == 0) { - *devmode = NULL; - return True; - } - - old_offset = prs_offset(ps); - if(!prs_set_offset(ps, buffer->string_at_end + buffer->struct_start)) - return False; - - /* read the string */ - if((*devmode=(DEVICEMODE *)prs_alloc_mem(ps,sizeof(DEVICEMODE))) == NULL) - return False; - if (!spoolss_io_devmode(desc, ps, depth, *devmode)) - return False; - - if(!prs_set_offset(ps, old_offset)) - return False; - } - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_0 structure. -********************************************************************/ - -BOOL smb_io_printer_info_0(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_0 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_0"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("servername", buffer, depth, &info->servername)) - return False; - - if(!prs_uint32("cjobs", ps, depth, &info->cjobs)) - return False; - if(!prs_uint32("total_jobs", ps, depth, &info->total_jobs)) - return False; - if(!prs_uint32("total_bytes", ps, depth, &info->total_bytes)) - return False; - - if(!prs_uint16("year", ps, depth, &info->year)) - return False; - if(!prs_uint16("month", ps, depth, &info->month)) - return False; - if(!prs_uint16("dayofweek", ps, depth, &info->dayofweek)) - return False; - if(!prs_uint16("day", ps, depth, &info->day)) - return False; - if(!prs_uint16("hour", ps, depth, &info->hour)) - return False; - if(!prs_uint16("minute", ps, depth, &info->minute)) - return False; - if(!prs_uint16("second", ps, depth, &info->second)) - return False; - if(!prs_uint16("milliseconds", ps, depth, &info->milliseconds)) - return False; - - if(!prs_uint32("global_counter", ps, depth, &info->global_counter)) - return False; - if(!prs_uint32("total_pages", ps, depth, &info->total_pages)) - return False; - - if(!prs_uint16("major_version", ps, depth, &info->major_version)) - return False; - if(!prs_uint16("build_version", ps, depth, &info->build_version)) - return False; - if(!prs_uint32("unknown7", ps, depth, &info->unknown7)) - return False; - if(!prs_uint32("unknown8", ps, depth, &info->unknown8)) - return False; - if(!prs_uint32("unknown9", ps, depth, &info->unknown9)) - return False; - if(!prs_uint32("session_counter", ps, depth, &info->session_counter)) - return False; - if(!prs_uint32("unknown11", ps, depth, &info->unknown11)) - return False; - if(!prs_uint32("printer_errors", ps, depth, &info->printer_errors)) - return False; - if(!prs_uint32("unknown13", ps, depth, &info->unknown13)) - return False; - if(!prs_uint32("unknown14", ps, depth, &info->unknown14)) - return False; - if(!prs_uint32("unknown15", ps, depth, &info->unknown15)) - return False; - if(!prs_uint32("unknown16", ps, depth, &info->unknown16)) - return False; - if(!prs_uint32("change_id", ps, depth, &info->change_id)) - return False; - if(!prs_uint32("unknown18", ps, depth, &info->unknown18)) - return False; - if(!prs_uint32("status" , ps, depth, &info->status)) - return False; - if(!prs_uint32("unknown20", ps, depth, &info->unknown20)) - return False; - if(!prs_uint32("c_setprinter", ps, depth, &info->c_setprinter)) - return False; - if(!prs_uint16("unknown22", ps, depth, &info->unknown22)) - return False; - if(!prs_uint16("unknown23", ps, depth, &info->unknown23)) - return False; - if(!prs_uint16("unknown24", ps, depth, &info->unknown24)) - return False; - if(!prs_uint16("unknown25", ps, depth, &info->unknown25)) - return False; - if(!prs_uint16("unknown26", ps, depth, &info->unknown26)) - return False; - if(!prs_uint16("unknown27", ps, depth, &info->unknown27)) - return False; - if(!prs_uint16("unknown28", ps, depth, &info->unknown28)) - return False; - if(!prs_uint16("unknown29", ps, depth, &info->unknown29)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_1 structure. -********************************************************************/ - -BOOL smb_io_printer_info_1(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("flags", ps, depth, &info->flags)) - return False; - if (!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("comment", buffer, depth, &info->comment)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_2 structure. -********************************************************************/ - -BOOL smb_io_printer_info_2(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - uint32 dm_offset, sd_offset, current_offset; - uint32 dummy_value = 0, has_secdesc = 0; - - prs_debug(ps, depth, desc, "smb_io_printer_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("servername", buffer, depth, &info->servername)) - return False; - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("sharename", buffer, depth, &info->sharename)) - return False; - if (!smb_io_relstr("portname", buffer, depth, &info->portname)) - return False; - if (!smb_io_relstr("drivername", buffer, depth, &info->drivername)) - return False; - if (!smb_io_relstr("comment", buffer, depth, &info->comment)) - return False; - if (!smb_io_relstr("location", buffer, depth, &info->location)) - return False; - - /* save current offset and wind forwared by a uint32 */ - dm_offset = prs_offset(ps); - if (!prs_uint32("devmode", ps, depth, &dummy_value)) - return False; - - if (!smb_io_relstr("sepfile", buffer, depth, &info->sepfile)) - return False; - if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor)) - return False; - if (!smb_io_relstr("datatype", buffer, depth, &info->datatype)) - return False; - if (!smb_io_relstr("parameters", buffer, depth, &info->parameters)) - return False; - - /* save current offset for the sec_desc */ - sd_offset = prs_offset(ps); - if (!prs_uint32("sec_desc", ps, depth, &has_secdesc)) - return False; - - - /* save current location so we can pick back up here */ - current_offset = prs_offset(ps); - - /* parse the devmode */ - if (!prs_set_offset(ps, dm_offset)) - return False; - if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode)) - return False; - - /* parse the sec_desc */ - if (has_secdesc) { - if (!prs_set_offset(ps, sd_offset)) - return False; - if (!smb_io_relsecdesc("secdesc", buffer, depth, &info->secdesc)) - return False; - } - - /* pick up where we left off */ - if (!prs_set_offset(ps, current_offset)) - return False; - - if (!prs_uint32("attributes", ps, depth, &info->attributes)) - return False; - if (!prs_uint32("priority", ps, depth, &info->priority)) - return False; - if (!prs_uint32("defpriority", ps, depth, &info->defaultpriority)) - return False; - if (!prs_uint32("starttime", ps, depth, &info->starttime)) - return False; - if (!prs_uint32("untiltime", ps, depth, &info->untiltime)) - return False; - if (!prs_uint32("status", ps, depth, &info->status)) - return False; - if (!prs_uint32("jobs", ps, depth, &info->cjobs)) - return False; - if (!prs_uint32("averageppm", ps, depth, &info->averageppm)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_3 structure. -********************************************************************/ - -BOOL smb_io_printer_info_3(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_3 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_3"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("flags", ps, depth, &info->flags)) - return False; - if (!sec_io_desc("sec_desc", &info->secdesc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_4 structure. -********************************************************************/ - -BOOL smb_io_printer_info_4(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_4 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_4"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("servername", buffer, depth, &info->servername)) - return False; - if (!prs_uint32("attributes", ps, depth, &info->attributes)) - return False; - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_5 structure. -********************************************************************/ - -BOOL smb_io_printer_info_5(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_5 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_5"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("portname", buffer, depth, &info->portname)) - return False; - if (!prs_uint32("attributes", ps, depth, &info->attributes)) - return False; - if (!prs_uint32("device_not_selected_timeout", ps, depth, &info->device_not_selected_timeout)) - return False; - if (!prs_uint32("transmission_retry_timeout", ps, depth, &info->transmission_retry_timeout)) - return False; - return True; -} - -/******************************************************************* - Parse a PRINTER_INFO_7 structure. -********************************************************************/ - -BOOL smb_io_printer_info_7(const char *desc, NEW_BUFFER *buffer, PRINTER_INFO_7 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_info_7"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("guid", buffer, depth, &info->guid)) - return False; - if (!prs_uint32("action", ps, depth, &info->action)) - return False; - return True; -} - -/******************************************************************* - Parse a PORT_INFO_1 structure. -********************************************************************/ - -BOOL smb_io_port_info_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - - return True; -} - -/******************************************************************* - Parse a PORT_INFO_2 structure. -********************************************************************/ - -BOOL smb_io_port_info_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - if (!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name)) - return False; - if (!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if (!prs_uint32("port_type", ps, depth, &info->port_type)) - return False; - if (!prs_uint32("reserved", ps, depth, &info->reserved)) - return False; - - return True; -} - -/******************************************************************* - Parse a DRIVER_INFO_1 structure. -********************************************************************/ - -BOOL smb_io_printer_driver_info_1(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* - Parse a DRIVER_INFO_2 structure. -********************************************************************/ - -BOOL smb_io_printer_driver_info_2(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("version", ps, depth, &info->version)) - return False; - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("architecture", buffer, depth, &info->architecture)) - return False; - if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath)) - return False; - if (!smb_io_relstr("datafile", buffer, depth, &info->datafile)) - return False; - if (!smb_io_relstr("configfile", buffer, depth, &info->configfile)) - return False; - - return True; -} - -/******************************************************************* - Parse a DRIVER_INFO_3 structure. -********************************************************************/ - -BOOL smb_io_printer_driver_info_3(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_3 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_3"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("version", ps, depth, &info->version)) - return False; - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("architecture", buffer, depth, &info->architecture)) - return False; - if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath)) - return False; - if (!smb_io_relstr("datafile", buffer, depth, &info->datafile)) - return False; - if (!smb_io_relstr("configfile", buffer, depth, &info->configfile)) - return False; - if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile)) - return False; - - if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles)) - return False; - - if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname)) - return False; - if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype)) - return False; - - return True; -} - -/******************************************************************* - Parse a DRIVER_INFO_6 structure. -********************************************************************/ - -BOOL smb_io_printer_driver_info_6(const char *desc, NEW_BUFFER *buffer, DRIVER_INFO_6 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printer_driver_info_6"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("version", ps, depth, &info->version)) - return False; - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("architecture", buffer, depth, &info->architecture)) - return False; - if (!smb_io_relstr("driverpath", buffer, depth, &info->driverpath)) - return False; - if (!smb_io_relstr("datafile", buffer, depth, &info->datafile)) - return False; - if (!smb_io_relstr("configfile", buffer, depth, &info->configfile)) - return False; - if (!smb_io_relstr("helpfile", buffer, depth, &info->helpfile)) - return False; - - if (!smb_io_relarraystr("dependentfiles", buffer, depth, &info->dependentfiles)) - return False; - - if (!smb_io_relstr("monitorname", buffer, depth, &info->monitorname)) - return False; - if (!smb_io_relstr("defaultdatatype", buffer, depth, &info->defaultdatatype)) - return False; - - if (!smb_io_relarraystr("previousdrivernames", buffer, depth, &info->previousdrivernames)) - return False; - - if (!prs_uint32("date.low", ps, depth, &info->driver_date.low)) - return False; - if (!prs_uint32("date.high", ps, depth, &info->driver_date.high)) - return False; - - if (!prs_uint32("padding", ps, depth, &info->padding)) - return False; - - if (!prs_uint32("driver_version_low", ps, depth, &info->driver_version_low)) - return False; - - if (!prs_uint32("driver_version_high", ps, depth, &info->driver_version_high)) - return False; - - if (!smb_io_relstr("mfgname", buffer, depth, &info->mfgname)) - return False; - if (!smb_io_relstr("oem_url", buffer, depth, &info->oem_url)) - return False; - if (!smb_io_relstr("hardware_id", buffer, depth, &info->hardware_id)) - return False; - if (!smb_io_relstr("provider", buffer, depth, &info->provider)) - return False; - - return True; -} - -/******************************************************************* - Parse a JOB_INFO_1 structure. -********************************************************************/ - -BOOL smb_io_job_info_1(const char *desc, NEW_BUFFER *buffer, JOB_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_job_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("jobid", ps, depth, &info->jobid)) - return False; - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("machinename", buffer, depth, &info->machinename)) - return False; - if (!smb_io_relstr("username", buffer, depth, &info->username)) - return False; - if (!smb_io_relstr("document", buffer, depth, &info->document)) - return False; - if (!smb_io_relstr("datatype", buffer, depth, &info->datatype)) - return False; - if (!smb_io_relstr("text_status", buffer, depth, &info->text_status)) - return False; - if (!prs_uint32("status", ps, depth, &info->status)) - return False; - if (!prs_uint32("priority", ps, depth, &info->priority)) - return False; - if (!prs_uint32("position", ps, depth, &info->position)) - return False; - if (!prs_uint32("totalpages", ps, depth, &info->totalpages)) - return False; - if (!prs_uint32("pagesprinted", ps, depth, &info->pagesprinted)) - return False; - if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted)) - return False; - - return True; -} - -/******************************************************************* - Parse a JOB_INFO_2 structure. -********************************************************************/ - -BOOL smb_io_job_info_2(const char *desc, NEW_BUFFER *buffer, JOB_INFO_2 *info, int depth) -{ - uint32 pipo=0; - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_job_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("jobid",ps, depth, &info->jobid)) - return False; - if (!smb_io_relstr("printername", buffer, depth, &info->printername)) - return False; - if (!smb_io_relstr("machinename", buffer, depth, &info->machinename)) - return False; - if (!smb_io_relstr("username", buffer, depth, &info->username)) - return False; - if (!smb_io_relstr("document", buffer, depth, &info->document)) - return False; - if (!smb_io_relstr("notifyname", buffer, depth, &info->notifyname)) - return False; - if (!smb_io_relstr("datatype", buffer, depth, &info->datatype)) - return False; - - if (!smb_io_relstr("printprocessor", buffer, depth, &info->printprocessor)) - return False; - if (!smb_io_relstr("parameters", buffer, depth, &info->parameters)) - return False; - if (!smb_io_relstr("drivername", buffer, depth, &info->drivername)) - return False; - if (!smb_io_reldevmode("devmode", buffer, depth, &info->devmode)) - return False; - if (!smb_io_relstr("text_status", buffer, depth, &info->text_status)) - return False; - -/* SEC_DESC sec_desc;*/ - if (!prs_uint32("Hack! sec desc", ps, depth, &pipo)) - return False; - - if (!prs_uint32("status",ps, depth, &info->status)) - return False; - if (!prs_uint32("priority",ps, depth, &info->priority)) - return False; - if (!prs_uint32("position",ps, depth, &info->position)) - return False; - if (!prs_uint32("starttime",ps, depth, &info->starttime)) - return False; - if (!prs_uint32("untiltime",ps, depth, &info->untiltime)) - return False; - if (!prs_uint32("totalpages",ps, depth, &info->totalpages)) - return False; - if (!prs_uint32("size",ps, depth, &info->size)) - return False; - if (!spoolss_io_system_time("submitted", ps, depth, &info->submitted) ) - return False; - if (!prs_uint32("timeelapsed",ps, depth, &info->timeelapsed)) - return False; - if (!prs_uint32("pagesprinted",ps, depth, &info->pagesprinted)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL smb_io_form_1(const char *desc, NEW_BUFFER *buffer, FORM_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_form_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!prs_uint32("flag", ps, depth, &info->flag)) - return False; - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - if (!prs_uint32("width", ps, depth, &info->width)) - return False; - if (!prs_uint32("length", ps, depth, &info->length)) - return False; - if (!prs_uint32("left", ps, depth, &info->left)) - return False; - if (!prs_uint32("top", ps, depth, &info->top)) - return False; - if (!prs_uint32("right", ps, depth, &info->right)) - return False; - if (!prs_uint32("bottom", ps, depth, &info->bottom)) - return False; - - return True; -} - -/******************************************************************* - Read/write a BUFFER struct. -********************************************************************/ - -static BOOL spoolss_io_buffer(const char *desc, prs_struct *ps, int depth, NEW_BUFFER **pp_buffer) -{ - NEW_BUFFER *buffer = *pp_buffer; - - prs_debug(ps, depth, desc, "spoolss_io_buffer"); - depth++; - - if (UNMARSHALLING(ps)) - buffer = *pp_buffer = (NEW_BUFFER *)prs_alloc_mem(ps, sizeof(NEW_BUFFER)); - - if (buffer == NULL) - return False; - - if (!prs_uint32("ptr", ps, depth, &buffer->ptr)) - return False; - - /* reading */ - if (UNMARSHALLING(ps)) { - buffer->size=0; - buffer->string_at_end=0; - - if (buffer->ptr==0) { - /* - * JRA. I'm not sure if the data in here is in big-endian format if - * the client is big-endian. Leave as default (little endian) for now. - */ - - if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL)) - return False; - return True; - } - - if (!prs_uint32("size", ps, depth, &buffer->size)) - return False; - - /* - * JRA. I'm not sure if the data in here is in big-endian format if - * the client is big-endian. Leave as default (little endian) for now. - */ - - if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL)) - return False; - - if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size)) - return False; - - if (!prs_set_offset(&buffer->prs, 0)) - return False; - - if (!prs_set_offset(ps, buffer->size+prs_offset(ps))) - return False; - - buffer->string_at_end=buffer->size; - - return True; - } - else { - BOOL ret = False; - - /* writing */ - if (buffer->ptr==0) { - /* We have finished with the data in buffer->prs - free it. */ - prs_mem_free(&buffer->prs); - return True; - } - - if (!prs_uint32("size", ps, depth, &buffer->size)) - goto out; - - if (!prs_append_some_prs_data(ps, &buffer->prs, 0, buffer->size)) - goto out; - - ret = True; - out: - - /* We have finished with the data in buffer->prs - free it. */ - prs_mem_free(&buffer->prs); - - return ret; - } -} - -/******************************************************************* - move a BUFFER from the query to the reply. - As the data pointers in NEW_BUFFER are malloc'ed, not talloc'ed, - this is ok. This is an OPTIMIZATION and is not strictly neccessary. - Clears the memory to zero also. -********************************************************************/ - -void spoolss_move_buffer(NEW_BUFFER *src, NEW_BUFFER **dest) -{ - prs_switch_type(&src->prs, MARSHALL); - if(!prs_set_offset(&src->prs, 0)) - return; - prs_force_dynamic(&src->prs); - prs_mem_clear(&src->prs); - *dest=src; -} - -/******************************************************************* - Get the size of a BUFFER struct. -********************************************************************/ - -uint32 new_get_buffer_size(NEW_BUFFER *buffer) -{ - return (buffer->size); -} - -/******************************************************************* - Parse a DRIVER_DIRECTORY_1 structure. -********************************************************************/ - -BOOL smb_io_driverdir_1(const char *desc, NEW_BUFFER *buffer, DRIVER_DIRECTORY_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_driverdir_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_unistr(desc, &info->name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a PORT_INFO_1 structure. -********************************************************************/ - -BOOL smb_io_port_1(const char *desc, NEW_BUFFER *buffer, PORT_INFO_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if(!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - - return True; -} - -/******************************************************************* - Parse a PORT_INFO_2 structure. -********************************************************************/ - -BOOL smb_io_port_2(const char *desc, NEW_BUFFER *buffer, PORT_INFO_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_port_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if(!smb_io_relstr("port_name", buffer, depth, &info->port_name)) - return False; - if(!smb_io_relstr("monitor_name", buffer, depth, &info->monitor_name)) - return False; - if(!smb_io_relstr("description", buffer, depth, &info->description)) - return False; - if(!prs_uint32("port_type", ps, depth, &info->port_type)) - return False; - if(!prs_uint32("reserved", ps, depth, &info->reserved)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL smb_io_printprocessor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printprocessor_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL smb_io_printprocdatatype_info_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCDATATYPE_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printprocdatatype_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL smb_io_printmonitor_info_1(const char *desc, NEW_BUFFER *buffer, PRINTMONITOR_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printmonitor_info_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL smb_io_printmonitor_info_2(const char *desc, NEW_BUFFER *buffer, PRINTMONITOR_2 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printmonitor_info_2"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_relstr("name", buffer, depth, &info->name)) - return False; - if (!smb_io_relstr("environment", buffer, depth, &info->environment)) - return False; - if (!smb_io_relstr("dll_name", buffer, depth, &info->dll_name)) - return False; - - return True; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_0(PRINTER_INFO_0 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->servername ); - - size+=size_of_uint32( &info->cjobs); - size+=size_of_uint32( &info->total_jobs); - size+=size_of_uint32( &info->total_bytes); - - size+=size_of_uint16( &info->year); - size+=size_of_uint16( &info->month); - size+=size_of_uint16( &info->dayofweek); - size+=size_of_uint16( &info->day); - size+=size_of_uint16( &info->hour); - size+=size_of_uint16( &info->minute); - size+=size_of_uint16( &info->second); - size+=size_of_uint16( &info->milliseconds); - - size+=size_of_uint32( &info->global_counter); - size+=size_of_uint32( &info->total_pages); - - size+=size_of_uint16( &info->major_version); - size+=size_of_uint16( &info->build_version); - - size+=size_of_uint32( &info->unknown7); - size+=size_of_uint32( &info->unknown8); - size+=size_of_uint32( &info->unknown9); - size+=size_of_uint32( &info->session_counter); - size+=size_of_uint32( &info->unknown11); - size+=size_of_uint32( &info->printer_errors); - size+=size_of_uint32( &info->unknown13); - size+=size_of_uint32( &info->unknown14); - size+=size_of_uint32( &info->unknown15); - size+=size_of_uint32( &info->unknown16); - size+=size_of_uint32( &info->change_id); - size+=size_of_uint32( &info->unknown18); - size+=size_of_uint32( &info->status); - size+=size_of_uint32( &info->unknown20); - size+=size_of_uint32( &info->c_setprinter); - - size+=size_of_uint16( &info->unknown22); - size+=size_of_uint16( &info->unknown23); - size+=size_of_uint16( &info->unknown24); - size+=size_of_uint16( &info->unknown25); - size+=size_of_uint16( &info->unknown26); - size+=size_of_uint16( &info->unknown27); - size+=size_of_uint16( &info->unknown28); - size+=size_of_uint16( &info->unknown29); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_1(PRINTER_INFO_1 *info) -{ - int size=0; - - size+=size_of_uint32( &info->flags ); - size+=size_of_relative_string( &info->description ); - size+=size_of_relative_string( &info->name ); - size+=size_of_relative_string( &info->comment ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_2(PRINTER_INFO_2 *info) -{ - uint32 size=0; - - size += 4; - - size += sec_desc_size( info->secdesc ); - - size+=size_of_device_mode( info->devmode ); - - size+=size_of_relative_string( &info->servername ); - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->sharename ); - size+=size_of_relative_string( &info->portname ); - size+=size_of_relative_string( &info->drivername ); - size+=size_of_relative_string( &info->comment ); - size+=size_of_relative_string( &info->location ); - - size+=size_of_relative_string( &info->sepfile ); - size+=size_of_relative_string( &info->printprocessor ); - size+=size_of_relative_string( &info->datatype ); - size+=size_of_relative_string( &info->parameters ); - - size+=size_of_uint32( &info->attributes ); - size+=size_of_uint32( &info->priority ); - size+=size_of_uint32( &info->defaultpriority ); - size+=size_of_uint32( &info->starttime ); - size+=size_of_uint32( &info->untiltime ); - size+=size_of_uint32( &info->status ); - size+=size_of_uint32( &info->cjobs ); - size+=size_of_uint32( &info->averageppm ); - - /* - * add any adjustments for alignment. This is - * not optimal since we could be calling this - * function from a loop (e.g. enumprinters), but - * it is easier to maintain the calculation here and - * not place the burden on the caller to remember. --jerry - */ - if ((size % 4) != 0) - size += 4 - (size % 4); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_4(PRINTER_INFO_4 *info) -{ - uint32 size=0; - - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->servername ); - - size+=size_of_uint32( &info->attributes ); - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_5(PRINTER_INFO_5 *info) -{ - uint32 size=0; - - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->portname ); - - size+=size_of_uint32( &info->attributes ); - size+=size_of_uint32( &info->device_not_selected_timeout ); - size+=size_of_uint32( &info->transmission_retry_timeout ); - return size; -} - - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_3(PRINTER_INFO_3 *info) -{ - /* The 4 is for the self relative pointer.. */ - /* JRA !!!! TESTME - WHAT ABOUT prs_align.... !!! */ - return 4 + (uint32)sec_desc_size( info->secdesc ); -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_info_7(PRINTER_INFO_7 *info) -{ - uint32 size=0; - - size+=size_of_relative_string( &info->guid ); - size+=size_of_uint32( &info->action ); - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_driver_info_1(DRIVER_INFO_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_driver_info_2(DRIVER_INFO_2 *info) -{ - int size=0; - size+=size_of_uint32( &info->version ); - size+=size_of_relative_string( &info->name ); - size+=size_of_relative_string( &info->architecture ); - size+=size_of_relative_string( &info->driverpath ); - size+=size_of_relative_string( &info->datafile ); - size+=size_of_relative_string( &info->configfile ); - - return size; -} - -/******************************************************************* -return the size required by a string array. -********************************************************************/ - -uint32 spoolss_size_string_array(uint16 *string) -{ - uint32 i = 0; - - if (string) { - for (i=0; (string[i]!=0x0000) || (string[i+1]!=0x0000); i++); - } - i=i+2; /* to count all chars including the leading zero */ - i=2*i; /* because we need the value in bytes */ - i=i+4; /* the offset pointer size */ - - return i; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_driver_info_3(DRIVER_INFO_3 *info) -{ - int size=0; - - size+=size_of_uint32( &info->version ); - size+=size_of_relative_string( &info->name ); - size+=size_of_relative_string( &info->architecture ); - size+=size_of_relative_string( &info->driverpath ); - size+=size_of_relative_string( &info->datafile ); - size+=size_of_relative_string( &info->configfile ); - size+=size_of_relative_string( &info->helpfile ); - size+=size_of_relative_string( &info->monitorname ); - size+=size_of_relative_string( &info->defaultdatatype ); - - size+=spoolss_size_string_array(info->dependentfiles); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printer_driver_info_6(DRIVER_INFO_6 *info) -{ - uint32 size=0; - - size+=size_of_uint32( &info->version ); - size+=size_of_relative_string( &info->name ); - size+=size_of_relative_string( &info->architecture ); - size+=size_of_relative_string( &info->driverpath ); - size+=size_of_relative_string( &info->datafile ); - size+=size_of_relative_string( &info->configfile ); - size+=size_of_relative_string( &info->helpfile ); - - size+=spoolss_size_string_array(info->dependentfiles); - - size+=size_of_relative_string( &info->monitorname ); - size+=size_of_relative_string( &info->defaultdatatype ); - - size+=spoolss_size_string_array(info->previousdrivernames); - - size+=size_of_nttime(&info->driver_date); - size+=size_of_uint32( &info->padding ); - size+=size_of_uint32( &info->driver_version_low ); - size+=size_of_uint32( &info->driver_version_high ); - size+=size_of_relative_string( &info->mfgname ); - size+=size_of_relative_string( &info->oem_url ); - size+=size_of_relative_string( &info->hardware_id ); - size+=size_of_relative_string( &info->provider ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_job_info_1(JOB_INFO_1 *info) -{ - int size=0; - size+=size_of_uint32( &info->jobid ); - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->machinename ); - size+=size_of_relative_string( &info->username ); - size+=size_of_relative_string( &info->document ); - size+=size_of_relative_string( &info->datatype ); - size+=size_of_relative_string( &info->text_status ); - size+=size_of_uint32( &info->status ); - size+=size_of_uint32( &info->priority ); - size+=size_of_uint32( &info->position ); - size+=size_of_uint32( &info->totalpages ); - size+=size_of_uint32( &info->pagesprinted ); - size+=size_of_systemtime( &info->submitted ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_job_info_2(JOB_INFO_2 *info) -{ - int size=0; - - size+=4; /* size of sec desc ptr */ - - size+=size_of_uint32( &info->jobid ); - size+=size_of_relative_string( &info->printername ); - size+=size_of_relative_string( &info->machinename ); - size+=size_of_relative_string( &info->username ); - size+=size_of_relative_string( &info->document ); - size+=size_of_relative_string( &info->notifyname ); - size+=size_of_relative_string( &info->datatype ); - size+=size_of_relative_string( &info->printprocessor ); - size+=size_of_relative_string( &info->parameters ); - size+=size_of_relative_string( &info->drivername ); - size+=size_of_device_mode( info->devmode ); - size+=size_of_relative_string( &info->text_status ); -/* SEC_DESC sec_desc;*/ - size+=size_of_uint32( &info->status ); - size+=size_of_uint32( &info->priority ); - size+=size_of_uint32( &info->position ); - size+=size_of_uint32( &info->starttime ); - size+=size_of_uint32( &info->untiltime ); - size+=size_of_uint32( &info->totalpages ); - size+=size_of_uint32( &info->size ); - size+=size_of_systemtime( &info->submitted ); - size+=size_of_uint32( &info->timeelapsed ); - size+=size_of_uint32( &info->pagesprinted ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_form_1(FORM_1 *info) -{ - int size=0; - - size+=size_of_uint32( &info->flag ); - size+=size_of_relative_string( &info->name ); - size+=size_of_uint32( &info->width ); - size+=size_of_uint32( &info->length ); - size+=size_of_uint32( &info->left ); - size+=size_of_uint32( &info->top ); - size+=size_of_uint32( &info->right ); - size+=size_of_uint32( &info->bottom ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_port_info_1(PORT_INFO_1 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->port_name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_driverdir_info_1(DRIVER_DIRECTORY_1 *info) -{ - int size=0; - - size=str_len_uni(&info->name); /* the string length */ - size=size+1; /* add the leading zero */ - size=size*2; /* convert in char */ - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printprocessordirectory_info_1(PRINTPROCESSOR_DIRECTORY_1 *info) -{ - int size=0; - - size=str_len_uni(&info->name); /* the string length */ - size=size+1; /* add the leading zero */ - size=size*2; /* convert in char */ - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_port_info_2(PORT_INFO_2 *info) -{ - int size=0; - - size+=size_of_relative_string( &info->port_name ); - size+=size_of_relative_string( &info->monitor_name ); - size+=size_of_relative_string( &info->description ); - - size+=size_of_uint32( &info->port_type ); - size+=size_of_uint32( &info->reserved ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printprocessor_info_1(PRINTPROCESSOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printprocdatatype_info_1(PRINTPROCDATATYPE_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ -uint32 spoolss_size_printer_enum_values(PRINTER_ENUM_VALUES *p) -{ - uint32 size = 0; - - if (!p) - return 0; - - /* uint32(offset) + uint32(length) + length) */ - size += (size_of_uint32(&p->value_len)*2) + p->value_len; - size += (size_of_uint32(&p->data_len)*2) + p->data_len + (p->data_len%2) ; - - size += size_of_uint32(&p->type); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printmonitor_info_1(PRINTMONITOR_1 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name ); - - return size; -} - -/******************************************************************* -return the size required by a struct in the stream -********************************************************************/ - -uint32 spoolss_size_printmonitor_info_2(PRINTMONITOR_2 *info) -{ - int size=0; - size+=size_of_relative_string( &info->name); - size+=size_of_relative_string( &info->environment); - size+=size_of_relative_string( &info->dll_name); - - return size; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getprinterdriver2(SPOOL_Q_GETPRINTERDRIVER2 *q_u, - const POLICY_HND *hnd, - const fstring architecture, - uint32 level, uint32 clientmajor, uint32 clientminor, - NEW_BUFFER *buffer, uint32 offered) -{ - if (q_u == NULL) - return False; - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - init_buf_unistr2(&q_u->architecture, &q_u->architecture_ptr, architecture); - - q_u->level=level; - q_u->clientmajorversion=clientmajor; - q_u->clientminorversion=clientminor; - - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinterdriver2 (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_getprinterdriver2(const char *desc, SPOOL_Q_GETPRINTERDRIVER2 *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriver2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("architecture_ptr", ps, depth, &q_u->architecture_ptr)) - return False; - if(!smb_io_unistr2("architecture", &q_u->architecture, q_u->architecture_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - if(!prs_uint32("clientmajorversion", ps, depth, &q_u->clientmajorversion)) - return False; - if(!prs_uint32("clientminorversion", ps, depth, &q_u->clientminorversion)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinterdriver2 (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_getprinterdriver2(const char *desc, SPOOL_R_GETPRINTERDRIVER2 *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriver2"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - if (!prs_uint32("servermajorversion", ps, depth, &r_u->servermajorversion)) - return False; - if (!prs_uint32("serverminorversion", ps, depth, &r_u->serverminorversion)) - return False; - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_enumprinters( - SPOOL_Q_ENUMPRINTERS *q_u, - uint32 flags, - char *servername, - uint32 level, - NEW_BUFFER *buffer, - uint32 offered -) -{ - q_u->flags=flags; - - q_u->servername_ptr = (servername != NULL) ? 1 : 0; - init_buf_unistr2(&q_u->servername, &q_u->servername_ptr, servername); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_enumports(SPOOL_Q_ENUMPORTS *q_u, - fstring servername, uint32 level, - NEW_BUFFER *buffer, uint32 offered) -{ - q_u->name_ptr = (servername != NULL) ? 1 : 0; - init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_enumprinters (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_enumprinters(const char *desc, SPOOL_Q_ENUMPRINTERS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinters"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("flags", ps, depth, &q_u->flags)) - return False; - if (!prs_uint32("servername_ptr", ps, depth, &q_u->servername_ptr)) - return False; - - if (!smb_io_unistr2("", &q_u->servername, q_u->servername_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_ENUMPRINTERS structure. - ********************************************************************/ - -BOOL spoolss_io_r_enumprinters(const char *desc, SPOOL_R_ENUMPRINTERS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinters"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_enum_printers (srv_spoolss.c) - * - ********************************************************************/ - -BOOL spoolss_io_r_getprinter(const char *desc, SPOOL_R_GETPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_getprinter (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_getprinter(const char *desc, SPOOL_Q_GETPRINTER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_getprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getprinter( - TALLOC_CTX *mem_ctx, - SPOOL_Q_GETPRINTER *q_u, - const POLICY_HND *hnd, - uint32 level, - NEW_BUFFER *buffer, - uint32 offered -) -{ - if (q_u == NULL) - { - return False; - } - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ -BOOL make_spoolss_q_setprinter(TALLOC_CTX *mem_ctx, SPOOL_Q_SETPRINTER *q_u, - const POLICY_HND *hnd, uint32 level, PRINTER_INFO_CTR *info, - uint32 command) -{ - SEC_DESC *secdesc; - DEVICEMODE *devmode; - - if (q_u == NULL) - return False; - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - q_u->level = level; - q_u->info.level = level; - q_u->info.info_ptr = (info != NULL) ? 1 : 0; - switch (level) { - - /* There's no such thing as a setprinter level 1 */ - - case 2: - secdesc = info->printers_2->secdesc; - devmode = info->printers_2->devmode; - - make_spoolss_printer_info_2 (mem_ctx, &q_u->info.info_2, info->printers_2); -#if 1 /* JERRY TEST */ - q_u->secdesc_ctr = (SEC_DESC_BUF*)malloc(sizeof(SEC_DESC_BUF)); - if (!q_u->secdesc_ctr) - return False; - q_u->secdesc_ctr->ptr = (secdesc != NULL) ? 1: 0; - q_u->secdesc_ctr->max_len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0; - q_u->secdesc_ctr->len = (secdesc) ? sizeof(SEC_DESC) + (2*sizeof(uint32)) : 0; - q_u->secdesc_ctr->sec = secdesc; - - q_u->devmode_ctr.devmode_ptr = (devmode != NULL) ? 1 : 0; - q_u->devmode_ctr.size = (devmode != NULL) ? sizeof(DEVICEMODE) + (3*sizeof(uint32)) : 0; - q_u->devmode_ctr.devmode = devmode; -#else - q_u->secdesc_ctr = NULL; - - q_u->devmode_ctr.devmode_ptr = 0; - q_u->devmode_ctr.size = 0; - q_u->devmode_ctr.devmode = NULL; -#endif - break; - default: - DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level)); - break; - } - - - q_u->command = command; - - return True; -} - - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_setprinter(const char *desc, SPOOL_R_SETPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Marshall/unmarshall a SPOOL_Q_SETPRINTER struct. -********************************************************************/ - -BOOL spoolss_io_q_setprinter(const char *desc, SPOOL_Q_SETPRINTER *q_u, prs_struct *ps, int depth) -{ - uint32 ptr_sec_desc = 0; - - prs_debug(ps, depth, desc, "spoolss_io_q_setprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle", &q_u->handle ,ps, depth)) - return False; - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spool_io_printer_info_level("", &q_u->info, ps, depth)) - return False; - - if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - switch (q_u->level) - { - case 2: - { - ptr_sec_desc = q_u->info.info_2->secdesc_ptr; - break; - } - case 3: - { - ptr_sec_desc = q_u->info.info_3->secdesc_ptr; - break; - } - } - if (ptr_sec_desc) - { - if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth)) - return False; - } else { - uint32 dummy = 0; - - /* Parse a NULL security descriptor. This should really - happen inside the sec_io_desc_buf() function. */ - - prs_debug(ps, depth, "", "sec_io_desc_buf"); - if (!prs_uint32("size", ps, depth + 1, &dummy)) - return False; - if (!prs_uint32("ptr", ps, depth + 1, &dummy)) return - False; - } - - if(!prs_uint32("command", ps, depth, &q_u->command)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_fcpn(const char *desc, SPOOL_R_FCPN *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_fcpn"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_fcpn(const char *desc, SPOOL_Q_FCPN *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_fcpn"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addjob(const char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - if(!prs_align(ps)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_addjob(const char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumjobs(const char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumjobs"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd, - uint32 firstjob, - uint32 numofjobs, - uint32 level, - NEW_BUFFER *buffer, - uint32 offered) -{ - if (q_u == NULL) - { - return False; - } - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - q_u->firstjob = firstjob; - q_u->numofjobs = numofjobs; - q_u->level = level; - q_u->buffer= buffer; - q_u->offered = offered; - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumjobs(const char *desc, SPOOL_Q_ENUMJOBS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumjobs"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!smb_io_pol_hnd("printer handle",&q_u->handle, ps, depth)) - return False; - - if (!prs_uint32("firstjob", ps, depth, &q_u->firstjob)) - return False; - if (!prs_uint32("numofjobs", ps, depth, &q_u->numofjobs)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_schedulejob(const char *desc, SPOOL_R_SCHEDULEJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_schedulejob"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_schedulejob(const char *desc, SPOOL_Q_SCHEDULEJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_schedulejob"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if(!prs_uint32("jobid", ps, depth, &q_u->jobid)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_setjob(const char *desc, SPOOL_R_SETJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setjob"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_setjob(const char *desc, SPOOL_Q_SETJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setjob"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if(!prs_uint32("jobid", ps, depth, &q_u->jobid)) - return False; - /* - * level is usually 0. If (level!=0) then I'm in trouble ! - * I will try to generate setjob command with level!=0, one day. - */ - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - if(!prs_uint32("command", ps, depth, &q_u->command)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_ENUMPRINTERDRIVERS structure. -********************************************************************/ - -BOOL spoolss_io_r_enumprinterdrivers(const char *desc, SPOOL_R_ENUMPRINTERDRIVERS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdrivers"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_enumprinterdrivers(SPOOL_Q_ENUMPRINTERDRIVERS *q_u, - const char *name, - const char *environment, - uint32 level, - NEW_BUFFER *buffer, uint32 offered) -{ - init_buf_unistr2(&q_u->name, &q_u->name_ptr, name); - init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, environment); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_ENUMPRINTERDRIVERS structure. -********************************************************************/ - -BOOL spoolss_io_q_enumprinterdrivers(const char *desc, SPOOL_Q_ENUMPRINTERDRIVERS *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdrivers"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->name, q_u->name_ptr,ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("environment_ptr", ps, depth, &q_u->environment_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumforms(const char *desc, SPOOL_Q_ENUMFORMS *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_enumforms"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumforms(const char *desc, SPOOL_R_ENUMFORMS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumforms"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("numofforms", ps, depth, &r_u->numofforms)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_getform(const char *desc, SPOOL_Q_GETFORM *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_getform"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if (!smb_io_unistr2("", &q_u->formname,True,ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_getform(const char *desc, SPOOL_R_GETFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getform"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("size of buffer needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_ENUMPORTS structure. -********************************************************************/ - -BOOL spoolss_io_r_enumports(const char *desc, SPOOL_R_ENUMPORTS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumports"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumports(const char *desc, SPOOL_Q_ENUMPORTS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->name,True,ps,depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_PRINTER_INFO_LEVEL_1 structure. -********************************************************************/ - -BOOL spool_io_printer_info_level_1(const char *desc, SPOOL_PRINTER_INFO_LEVEL_1 *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_info_level_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags", ps, depth, &il->flags)) - return False; - if(!prs_uint32("description_ptr", ps, depth, &il->description_ptr)) - return False; - if(!prs_uint32("name_ptr", ps, depth, &il->name_ptr)) - return False; - if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr)) - return False; - - if(!smb_io_unistr2("description", &il->description, il->description_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_PRINTER_INFO_LEVEL_3 structure. -********************************************************************/ - -BOOL spool_io_printer_info_level_3(const char *desc, SPOOL_PRINTER_INFO_LEVEL_3 *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_info_level_3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_PRINTER_INFO_LEVEL_2 structure. -********************************************************************/ - -BOOL spool_io_printer_info_level_2(const char *desc, SPOOL_PRINTER_INFO_LEVEL_2 *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_info_level_2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("servername_ptr", ps, depth, &il->servername_ptr)) - return False; - if(!prs_uint32("printername_ptr", ps, depth, &il->printername_ptr)) - return False; - if(!prs_uint32("sharename_ptr", ps, depth, &il->sharename_ptr)) - return False; - if(!prs_uint32("portname_ptr", ps, depth, &il->portname_ptr)) - return False; - - if(!prs_uint32("drivername_ptr", ps, depth, &il->drivername_ptr)) - return False; - if(!prs_uint32("comment_ptr", ps, depth, &il->comment_ptr)) - return False; - if(!prs_uint32("location_ptr", ps, depth, &il->location_ptr)) - return False; - if(!prs_uint32("devmode_ptr", ps, depth, &il->devmode_ptr)) - return False; - if(!prs_uint32("sepfile_ptr", ps, depth, &il->sepfile_ptr)) - return False; - if(!prs_uint32("printprocessor_ptr", ps, depth, &il->printprocessor_ptr)) - return False; - if(!prs_uint32("datatype_ptr", ps, depth, &il->datatype_ptr)) - return False; - if(!prs_uint32("parameters_ptr", ps, depth, &il->parameters_ptr)) - return False; - if(!prs_uint32("secdesc_ptr", ps, depth, &il->secdesc_ptr)) - return False; - - if(!prs_uint32("attributes", ps, depth, &il->attributes)) - return False; - if(!prs_uint32("priority", ps, depth, &il->priority)) - return False; - if(!prs_uint32("default_priority", ps, depth, &il->default_priority)) - return False; - if(!prs_uint32("starttime", ps, depth, &il->starttime)) - return False; - if(!prs_uint32("untiltime", ps, depth, &il->untiltime)) - return False; - if(!prs_uint32("status", ps, depth, &il->status)) - return False; - if(!prs_uint32("cjobs", ps, depth, &il->cjobs)) - return False; - if(!prs_uint32("averageppm", ps, depth, &il->averageppm)) - return False; - - if(!smb_io_unistr2("servername", &il->servername, il->servername_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("printername", &il->printername, il->printername_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("sharename", &il->sharename, il->sharename_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("portname", &il->portname, il->portname_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("drivername", &il->drivername, il->drivername_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("comment", &il->comment, il->comment_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("location", &il->location, il->location_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("sepfile", &il->sepfile, il->sepfile_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("printprocessor", &il->printprocessor, il->printprocessor_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("datatype", &il->datatype, il->datatype_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("parameters", &il->parameters, il->parameters_ptr, ps, depth)) - return False; - - return True; -} - -BOOL spool_io_printer_info_level_7(const char *desc, SPOOL_PRINTER_INFO_LEVEL_7 *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_info_level_7"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("guid_ptr", ps, depth, &il->guid_ptr)) - return False; - if(!prs_uint32("action", ps, depth, &il->action)) - return False; - - if(!smb_io_unistr2("servername", &il->guid, il->guid_ptr, ps, depth)) - return False; - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spool_io_printer_info_level(const char *desc, SPOOL_PRINTER_INFO_LEVEL *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_info_level"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("level", ps, depth, &il->level)) - return False; - if(!prs_uint32("info_ptr", ps, depth, &il->info_ptr)) - return False; - - /* if no struct inside just return */ - if (il->info_ptr==0) { - if (UNMARSHALLING(ps)) { - il->info_1=NULL; - il->info_2=NULL; - } - return True; - } - - switch (il->level) { - /* - * level 0 is used by setprinter when managing the queue - * (hold, stop, start a queue) - */ - case 0: - break; - /* DOCUMENT ME!!! What is level 1 used for? */ - case 1: - { - if (UNMARSHALLING(ps)) { - if ((il->info_1=(SPOOL_PRINTER_INFO_LEVEL_1 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_1))) == NULL) - return False; - } - if (!spool_io_printer_info_level_1("", il->info_1, ps, depth)) - return False; - break; - } - /* - * level 2 is used by addprinter - * and by setprinter when updating printer's info - */ - case 2: - if (UNMARSHALLING(ps)) { - if ((il->info_2=(SPOOL_PRINTER_INFO_LEVEL_2 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_2))) == NULL) - return False; - } - if (!spool_io_printer_info_level_2("", il->info_2, ps, depth)) - return False; - break; - /* DOCUMENT ME!!! What is level 3 used for? */ - case 3: - { - if (UNMARSHALLING(ps)) { - if ((il->info_3=(SPOOL_PRINTER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_3))) == NULL) - return False; - } - if (!spool_io_printer_info_level_3("", il->info_3, ps, depth)) - return False; - break; - } - case 7: - if (UNMARSHALLING(ps)) - if ((il->info_7=(SPOOL_PRINTER_INFO_LEVEL_7 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_INFO_LEVEL_7))) == NULL) - return False; - if (!spool_io_printer_info_level_7("", il->info_7, ps, depth)) - return False; - break; - } - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_addprinterex(const char *desc, SPOOL_Q_ADDPRINTEREX *q_u, prs_struct *ps, int depth) -{ - uint32 ptr_sec_desc = 0; - - prs_debug(ps, depth, desc, "spoolss_io_q_addprinterex"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("", ps, depth, &q_u->server_name_ptr)) - return False; - if(!smb_io_unistr2("", &q_u->server_name, q_u->server_name_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_u->level)) - return False; - - if(!spool_io_printer_info_level("", &q_u->info, ps, depth)) - return False; - - if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - switch (q_u->level) { - case 2: - ptr_sec_desc = q_u->info.info_2->secdesc_ptr; - break; - case 3: - ptr_sec_desc = q_u->info.info_3->secdesc_ptr; - break; - } - if (ptr_sec_desc) { - if (!sec_io_desc_buf(desc, &q_u->secdesc_ctr, ps, depth)) - return False; - } else { - uint32 dummy; - - /* Parse a NULL security descriptor. This should really - happen inside the sec_io_desc_buf() function. */ - - prs_debug(ps, depth, "", "sec_io_desc_buf"); - if (!prs_uint32("size", ps, depth + 1, &dummy)) - return False; - if (!prs_uint32("ptr", ps, depth + 1, &dummy)) - return False; - } - - if(!prs_uint32("user_switch", ps, depth, &q_u->user_switch)) - return False; - if(!spool_io_user_level("", &q_u->user_ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addprinterex(const char *desc, SPOOL_R_ADDPRINTEREX *r_u, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addprinterex"); - depth++; - - if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spool_io_printer_driver_info_level_3(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **q_u, - prs_struct *ps, int depth) -{ - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *il; - - prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_3"); - depth++; - - /* reading */ - if (UNMARSHALLING(ps)) { - il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)); - if(il == NULL) - return False; - *q_u=il; - } - else { - il=*q_u; - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("cversion", ps, depth, &il->cversion)) - return False; - if(!prs_uint32("name", ps, depth, &il->name_ptr)) - return False; - if(!prs_uint32("environment", ps, depth, &il->environment_ptr)) - return False; - if(!prs_uint32("driverpath", ps, depth, &il->driverpath_ptr)) - return False; - if(!prs_uint32("datafile", ps, depth, &il->datafile_ptr)) - return False; - if(!prs_uint32("configfile", ps, depth, &il->configfile_ptr)) - return False; - if(!prs_uint32("helpfile", ps, depth, &il->helpfile_ptr)) - return False; - if(!prs_uint32("monitorname", ps, depth, &il->monitorname_ptr)) - return False; - if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr)) - return False; - if(!prs_uint32("dependentfilessize", ps, depth, &il->dependentfilessize)) - return False; - if(!prs_uint32("dependentfiles", ps, depth, &il->dependentfiles_ptr)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth)) - return False; - if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if (il->dependentfiles_ptr) - smb_io_buffer5("", &il->dependentfiles, ps, depth); - - return True; -} - -/******************************************************************* -parse a SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 structure -********************************************************************/ - -BOOL spool_io_printer_driver_info_level_6(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 **q_u, - prs_struct *ps, int depth) -{ - SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *il; - - prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level_6"); - depth++; - - /* reading */ - if (UNMARSHALLING(ps)) { - il=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *)prs_alloc_mem(ps,sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6)); - if(il == NULL) - return False; - *q_u=il; - } - else { - il=*q_u; - } - - if(!prs_align(ps)) - return False; - - /* - * I know this seems weird, but I have no other explanation. - * This is observed behavior on both NT4 and 2K servers. - * --jerry - */ - - if (!prs_align_uint64(ps)) - return False; - - /* parse the main elements the packet */ - - if(!prs_uint32("cversion ", ps, depth, &il->version)) - return False; - if(!prs_uint32("name ", ps, depth, &il->name_ptr)) - return False; - if(!prs_uint32("environment ", ps, depth, &il->environment_ptr)) - return False; - if(!prs_uint32("driverpath ", ps, depth, &il->driverpath_ptr)) - return False; - if(!prs_uint32("datafile ", ps, depth, &il->datafile_ptr)) - return False; - if(!prs_uint32("configfile ", ps, depth, &il->configfile_ptr)) - return False; - if(!prs_uint32("helpfile ", ps, depth, &il->helpfile_ptr)) - return False; - if(!prs_uint32("monitorname ", ps, depth, &il->monitorname_ptr)) - return False; - if(!prs_uint32("defaultdatatype", ps, depth, &il->defaultdatatype_ptr)) - return False; - if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_len)) - return False; - if(!prs_uint32("dependentfiles ", ps, depth, &il->dependentfiles_ptr)) - return False; - if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_len)) - return False; - if(!prs_uint32("previousnames ", ps, depth, &il->previousnames_ptr)) - return False; - if(!smb_io_time("driverdate ", &il->driverdate, ps, depth)) - return False; - if(!prs_uint32("dummy4 ", ps, depth, &il->dummy4)) - return False; - if(!prs_uint64("driverversion ", ps, depth, &il->driverversion)) - return False; - if(!prs_uint32("mfgname ", ps, depth, &il->mfgname_ptr)) - return False; - if(!prs_uint32("oemurl ", ps, depth, &il->oemurl_ptr)) - return False; - if(!prs_uint32("hardwareid ", ps, depth, &il->hardwareid_ptr)) - return False; - if(!prs_uint32("provider ", ps, depth, &il->provider_ptr)) - return False; - - /* parse the structures in the packet */ - - if(!smb_io_unistr2("name", &il->name, il->name_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("environment", &il->environment, il->environment_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("driverpath", &il->driverpath, il->driverpath_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("datafile", &il->datafile, il->datafile_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("configfile", &il->configfile, il->configfile_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("helpfile", &il->helpfile, il->helpfile_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("monitorname", &il->monitorname, il->monitorname_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("defaultdatatype", &il->defaultdatatype, il->defaultdatatype_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if (il->dependentfiles_ptr) { - if(!smb_io_buffer5("dependentfiles", &il->dependentfiles, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - if (il->previousnames_ptr) { - if(!smb_io_buffer5("previousnames", &il->previousnames, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - } - if(!smb_io_unistr2("mfgname", &il->mfgname, il->mfgname_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("oemurl", &il->oemurl, il->oemurl_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("hardwareid", &il->hardwareid, il->hardwareid_ptr, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("provider", &il->provider, il->provider_ptr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - convert a buffer of UNICODE strings null terminated - the buffer is terminated by a NULL - - convert to an dos codepage array (null terminated) - - dynamically allocate memory - -********************************************************************/ -static BOOL uniarray_2_dosarray(BUFFER5 *buf5, fstring **ar) -{ - fstring f, *tar; - int n = 0; - char *src; - - if (buf5==NULL) - return False; - - src = (char *)buf5->buffer; - *ar = NULL; - - while (src < ((char *)buf5->buffer) + buf5->buf_len*2) { - rpcstr_pull(f, src, sizeof(f)-1, -1, STR_TERMINATE); - src = skip_unibuf(src, 2*buf5->buf_len - PTR_DIFF(src,buf5->buffer)); - tar = (fstring *)Realloc(*ar, sizeof(fstring)*(n+2)); - if (!tar) - return False; - else - *ar = tar; - fstrcpy((*ar)[n], f); - n++; - } - fstrcpy((*ar)[n], ""); - - return True; -} - - - - -/******************************************************************* - read a UNICODE array with null terminated strings - and null terminated array - and size of array at beginning -********************************************************************/ - -BOOL smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int depth) -{ - if (buffer==NULL) return False; - - buffer->undoc=0; - buffer->uni_str_len=buffer->uni_max_len; - - if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len)) - return False; - - if(!prs_unistr2(True, "buffer ", ps, depth, buffer)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spool_io_printer_driver_info_level(const char *desc, SPOOL_PRINTER_DRIVER_INFO_LEVEL *il, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spool_io_printer_driver_info_level"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("level", ps, depth, &il->level)) - return False; - if(!prs_uint32("ptr", ps, depth, &il->ptr)) - return False; - - if (il->ptr==0) - return True; - - switch (il->level) { - case 3: - if(!spool_io_printer_driver_info_level_3("", &il->info_3, ps, depth)) - return False; - break; - case 6: - if(!spool_io_printer_driver_info_level_6("", &il->info_6, ps, depth)) - return False; - break; - default: - return False; - } - - return True; -} - -/******************************************************************* - init a SPOOL_Q_ADDPRINTERDRIVER struct - ******************************************************************/ - -BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx, - SPOOL_Q_ADDPRINTERDRIVER *q_u, const char* srv_name, - uint32 level, PRINTER_DRIVER_CTR *info) -{ - DEBUG(5,("make_spoolss_q_addprinterdriver\n")); - - q_u->server_name_ptr = (srv_name!=NULL)?1:0; - init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1); - - q_u->level = level; - - q_u->info.level = level; - q_u->info.ptr = (info!=NULL)?1:0; - switch (level) - { - /* info level 3 is supported by Windows 95/98, WinNT and Win2k */ - case 3 : - make_spoolss_driver_info_3(mem_ctx, &q_u->info.info_3, info->info3); - break; - - default: - DEBUG(0,("make_spoolss_q_addprinterdriver: Unknown info level [%d]\n", level)); - break; - } - - return True; -} - -BOOL make_spoolss_driver_info_3(TALLOC_CTX *mem_ctx, - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 **spool_drv_info, - DRIVER_INFO_3 *info3) -{ - uint32 len = 0; - uint16 *ptr = info3->dependentfiles; - BOOL done = False; - BOOL null_char = False; - SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *inf; - - if (!(inf=(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3*)talloc_zero(mem_ctx, sizeof(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3)))) - return False; - - inf->cversion = info3->version; - inf->name_ptr = (info3->name.buffer!=NULL)?1:0; - inf->environment_ptr = (info3->architecture.buffer!=NULL)?1:0; - inf->driverpath_ptr = (info3->driverpath.buffer!=NULL)?1:0; - inf->datafile_ptr = (info3->datafile.buffer!=NULL)?1:0; - inf->configfile_ptr = (info3->configfile.buffer!=NULL)?1:0; - inf->helpfile_ptr = (info3->helpfile.buffer!=NULL)?1:0; - inf->monitorname_ptr = (info3->monitorname.buffer!=NULL)?1:0; - inf->defaultdatatype_ptr = (info3->defaultdatatype.buffer!=NULL)?1:0; - - init_unistr2_from_unistr(&inf->name, &info3->name); - init_unistr2_from_unistr(&inf->environment, &info3->architecture); - init_unistr2_from_unistr(&inf->driverpath, &info3->driverpath); - init_unistr2_from_unistr(&inf->datafile, &info3->datafile); - init_unistr2_from_unistr(&inf->configfile, &info3->configfile); - init_unistr2_from_unistr(&inf->helpfile, &info3->helpfile); - init_unistr2_from_unistr(&inf->monitorname, &info3->monitorname); - init_unistr2_from_unistr(&inf->defaultdatatype, &info3->defaultdatatype); - - while (!done) - { - switch (*ptr) - { - case 0: - /* the null_char BOOL is used to help locate - two '\0's back to back */ - if (null_char) - done = True; - else - null_char = True; - break; - - default: - null_char = False; - ;; - break; - } - len++; - ptr++; - } - inf->dependentfiles_ptr = (info3->dependentfiles != NULL) ? 1 : 0; - inf->dependentfilessize = len; - if(!make_spoolss_buffer5(mem_ctx, &inf->dependentfiles, len, info3->dependentfiles)) - { - SAFE_FREE(inf); - return False; - } - - *spool_drv_info = inf; - - return True; -} - -/******************************************************************* - make a BUFFER5 struct from a uint16* - ******************************************************************/ -BOOL make_spoolss_buffer5(TALLOC_CTX *mem_ctx, BUFFER5 *buf5, uint32 len, uint16 *src) -{ - - buf5->buf_len = len; - if((buf5->buffer=(uint16*)talloc_memdup(mem_ctx, src, sizeof(uint16)*len)) == NULL) - { - DEBUG(0,("make_spoolss_buffer5: Unable to malloc memory for buffer!\n")); - return False; - } - - return True; -} - -/******************************************************************* - fill in the prs_struct for a ADDPRINTERDRIVER request PDU - ********************************************************************/ - -BOOL spoolss_io_q_addprinterdriver(const char *desc, SPOOL_Q_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriver"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr)) - return False; - if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("info_level", ps, depth, &q_u->level)) - return False; - - if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addprinterdriver(const char *desc, SPOOL_R_ADDPRINTERDRIVER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriver"); - depth++; - - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - -/******************************************************************* - fill in the prs_struct for a ADDPRINTERDRIVER request PDU - ********************************************************************/ - -BOOL spoolss_io_q_addprinterdriverex(const char *desc, SPOOL_Q_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_addprinterdriverex"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("server_name_ptr", ps, depth, &q_u->server_name_ptr)) - return False; - if(!smb_io_unistr2("server_name", &q_u->server_name, q_u->server_name_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("info_level", ps, depth, &q_u->level)) - return False; - - if(!spool_io_printer_driver_info_level("", &q_u->info, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("copy flags", ps, depth, &q_u->copy_flags)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addprinterdriverex(const char *desc, SPOOL_R_ADDPRINTERDRIVEREX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addprinterdriverex"); - depth++; - - if(!prs_werror("status", ps, depth, &q_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL uni_2_asc_printer_driver_3(SPOOL_PRINTER_DRIVER_INFO_LEVEL_3 *uni, - NT_PRINTER_DRIVER_INFO_LEVEL_3 **asc) -{ - NT_PRINTER_DRIVER_INFO_LEVEL_3 *d; - - DEBUG(7,("uni_2_asc_printer_driver_3: Converting from UNICODE to ASCII\n")); - - if (*asc==NULL) - { - *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_3 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_3)); - if(*asc == NULL) - return False; - ZERO_STRUCTP(*asc); - } - - d=*asc; - - d->cversion=uni->cversion; - - unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1); - unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1); - unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1); - unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1); - unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1); - unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1); - unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1); - unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1); - - DEBUGADD(8,( "version: %d\n", d->cversion)); - DEBUGADD(8,( "name: %s\n", d->name)); - DEBUGADD(8,( "environment: %s\n", d->environment)); - DEBUGADD(8,( "driverpath: %s\n", d->driverpath)); - DEBUGADD(8,( "datafile: %s\n", d->datafile)); - DEBUGADD(8,( "configfile: %s\n", d->configfile)); - DEBUGADD(8,( "helpfile: %s\n", d->helpfile)); - DEBUGADD(8,( "monitorname: %s\n", d->monitorname)); - DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype)); - - if (uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles )) - return True; - - SAFE_FREE(*asc); - return False; -} - -/******************************************************************* -********************************************************************/ -BOOL uni_2_asc_printer_driver_6(SPOOL_PRINTER_DRIVER_INFO_LEVEL_6 *uni, - NT_PRINTER_DRIVER_INFO_LEVEL_6 **asc) -{ - NT_PRINTER_DRIVER_INFO_LEVEL_6 *d; - - DEBUG(7,("uni_2_asc_printer_driver_6: Converting from UNICODE to ASCII\n")); - - if (*asc==NULL) - { - *asc=(NT_PRINTER_DRIVER_INFO_LEVEL_6 *)malloc(sizeof(NT_PRINTER_DRIVER_INFO_LEVEL_6)); - if(*asc == NULL) - return False; - ZERO_STRUCTP(*asc); - } - - d=*asc; - - d->version=uni->version; - - unistr2_to_ascii(d->name, &uni->name, sizeof(d->name)-1); - unistr2_to_ascii(d->environment, &uni->environment, sizeof(d->environment)-1); - unistr2_to_ascii(d->driverpath, &uni->driverpath, sizeof(d->driverpath)-1); - unistr2_to_ascii(d->datafile, &uni->datafile, sizeof(d->datafile)-1); - unistr2_to_ascii(d->configfile, &uni->configfile, sizeof(d->configfile)-1); - unistr2_to_ascii(d->helpfile, &uni->helpfile, sizeof(d->helpfile)-1); - unistr2_to_ascii(d->monitorname, &uni->monitorname, sizeof(d->monitorname)-1); - unistr2_to_ascii(d->defaultdatatype, &uni->defaultdatatype, sizeof(d->defaultdatatype)-1); - - DEBUGADD(8,( "version: %d\n", d->version)); - DEBUGADD(8,( "name: %s\n", d->name)); - DEBUGADD(8,( "environment: %s\n", d->environment)); - DEBUGADD(8,( "driverpath: %s\n", d->driverpath)); - DEBUGADD(8,( "datafile: %s\n", d->datafile)); - DEBUGADD(8,( "configfile: %s\n", d->configfile)); - DEBUGADD(8,( "helpfile: %s\n", d->helpfile)); - DEBUGADD(8,( "monitorname: %s\n", d->monitorname)); - DEBUGADD(8,( "defaultdatatype: %s\n", d->defaultdatatype)); - - if (!uniarray_2_dosarray(&uni->dependentfiles, &d->dependentfiles )) - goto error; - if (!uniarray_2_dosarray(&uni->previousnames, &d->previousnames )) - goto error; - - return True; - -error: - SAFE_FREE(*asc); - return False; -} - -BOOL uni_2_asc_printer_info_2(const SPOOL_PRINTER_INFO_LEVEL_2 *uni, - NT_PRINTER_INFO_LEVEL_2 **asc) -{ - NT_PRINTER_INFO_LEVEL_2 *d; - time_t time_unix; - - DEBUG(7,("Converting from UNICODE to ASCII\n")); - time_unix=time(NULL); - - if (*asc==NULL) { - DEBUGADD(8,("allocating memory\n")); - - *asc=(NT_PRINTER_INFO_LEVEL_2 *)malloc(sizeof(NT_PRINTER_INFO_LEVEL_2)); - if(*asc == NULL) - return False; - ZERO_STRUCTP(*asc); - - /* we allocate memory iff called from - * addprinter(ex) so we can do one time stuff here. - */ - (*asc)->setuptime=time_unix; - - } - DEBUGADD(8,("start converting\n")); - - d=*asc; - - d->attributes=uni->attributes; - d->priority=uni->priority; - d->default_priority=uni->default_priority; - d->starttime=uni->starttime; - d->untiltime=uni->untiltime; - d->status=uni->status; - d->cjobs=uni->cjobs; - - unistr2_to_ascii(d->servername, &uni->servername, sizeof(d->servername)-1); - unistr2_to_ascii(d->printername, &uni->printername, sizeof(d->printername)-1); - unistr2_to_ascii(d->sharename, &uni->sharename, sizeof(d->sharename)-1); - unistr2_to_ascii(d->portname, &uni->portname, sizeof(d->portname)-1); - unistr2_to_ascii(d->drivername, &uni->drivername, sizeof(d->drivername)-1); - unistr2_to_ascii(d->comment, &uni->comment, sizeof(d->comment)-1); - unistr2_to_ascii(d->location, &uni->location, sizeof(d->location)-1); - unistr2_to_ascii(d->sepfile, &uni->sepfile, sizeof(d->sepfile)-1); - unistr2_to_ascii(d->printprocessor, &uni->printprocessor, sizeof(d->printprocessor)-1); - unistr2_to_ascii(d->datatype, &uni->datatype, sizeof(d->datatype)-1); - unistr2_to_ascii(d->parameters, &uni->parameters, sizeof(d->parameters)-1); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getprinterdriverdir(SPOOL_Q_GETPRINTERDRIVERDIR *q_u, - fstring servername, fstring env_name, uint32 level, - NEW_BUFFER *buffer, uint32 offered) -{ - init_buf_unistr2(&q_u->name, &q_u->name_ptr, servername); - init_buf_unistr2(&q_u->environment, &q_u->environment_ptr, env_name); - - q_u->level=level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_GETPRINTERDRIVERDIR structure. -********************************************************************/ - -BOOL spoolss_io_q_getprinterdriverdir(const char *desc, SPOOL_Q_GETPRINTERDRIVERDIR *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdriverdir"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if(!smb_io_unistr2("", &q_u->name, q_u->name_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("", ps, depth, &q_u->environment_ptr)) - return False; - if(!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_GETPRINTERDRIVERDIR structure. -********************************************************************/ - -BOOL spoolss_io_r_getprinterdriverdir(const char *desc, SPOOL_R_GETPRINTERDRIVERDIR *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdriverdir"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumprintprocessors(const char *desc, SPOOL_R_ENUMPRINTPROCESSORS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocessors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumprintprocessors(const char *desc, SPOOL_Q_ENUMPRINTPROCESSORS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocessors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("", ps, depth, &q_u->environment_ptr)) - return False; - if (!smb_io_unistr2("", &q_u->environment, q_u->environment_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_addprintprocessor(const char *desc, SPOOL_Q_ADDPRINTPROCESSOR *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_addprintprocessor"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("server_ptr", ps, depth, &q_u->server_ptr)) - return False; - if (!smb_io_unistr2("server", &q_u->server, q_u->server_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("environment", &q_u->environment, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("path", &q_u->path, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addprintprocessor(const char *desc, SPOOL_R_ADDPRINTPROCESSOR *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addprintproicessor"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumprintprocdatatypes(const char *desc, SPOOL_R_ENUMPRINTPROCDATATYPES *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintprocdatatypes"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumprintprocdatatypes(const char *desc, SPOOL_Q_ENUMPRINTPROCDATATYPES *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintprocdatatypes"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("processor_ptr", ps, depth, &q_u->processor_ptr)) - return False; - if (!smb_io_unistr2("processor", &q_u->processor, q_u->processor_ptr, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("buffer", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_ENUMPRINTMONITORS structure. -********************************************************************/ - -BOOL spoolss_io_q_enumprintmonitors(const char *desc, SPOOL_Q_ENUMPRINTMONITORS *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprintmonitors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("name_ptr", ps, depth, &q_u->name_ptr)) - return False; - if (!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumprintmonitors(const char *desc, SPOOL_R_ENUMPRINTMONITORS *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprintmonitors"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_enumprinterdata(const char *desc, SPOOL_R_ENUMPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdata"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("valuesize", ps, depth, &r_u->valuesize)) - return False; - - if (UNMARSHALLING(ps) && r_u->valuesize) { - r_u->value = (uint16 *)prs_alloc_mem(ps, r_u->valuesize * 2); - if (!r_u->value) { - DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata value\n")); - return False; - } - } - - if(!prs_uint16uni(False, "value", ps, depth, r_u->value, r_u->valuesize )) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("realvaluesize", ps, depth, &r_u->realvaluesize)) - return False; - - if(!prs_uint32("type", ps, depth, &r_u->type)) - return False; - - if(!prs_uint32("datasize", ps, depth, &r_u->datasize)) - return False; - - if (UNMARSHALLING(ps) && r_u->datasize) { - r_u->data = (uint8 *)prs_alloc_mem(ps, r_u->datasize); - if (!r_u->data) { - DEBUG(0, ("spoolss_io_r_enumprinterdata: out of memory for printerdata data\n")); - return False; - } - } - - if(!prs_uint8s(False, "data", ps, depth, r_u->data, r_u->datasize)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("realdatasize", ps, depth, &r_u->realdatasize)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_enumprinterdata(const char *desc, SPOOL_Q_ENUMPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdata"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if(!prs_uint32("index", ps, depth, &q_u->index)) - return False; - if(!prs_uint32("valuesize", ps, depth, &q_u->valuesize)) - return False; - if(!prs_uint32("datasize", ps, depth, &q_u->datasize)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL make_spoolss_q_enumprinterdata(SPOOL_Q_ENUMPRINTERDATA *q_u, - const POLICY_HND *hnd, - uint32 idx, uint32 valuelen, uint32 datalen) -{ - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - q_u->index=idx; - q_u->valuesize=valuelen; - q_u->datasize=datalen; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u, - const POLICY_HND *hnd, const char *key, - uint32 size) -{ - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - init_unistr2(&q_u->key, key, strlen(key)+1); - q_u->size = size; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND *hnd, - char* value, uint32 data_type, char* data, uint32 data_size) -{ - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - q_u->type = data_type; - init_unistr2(&q_u->value, value, strlen(value)+1); - - q_u->max_len = q_u->real_len = data_size; - q_u->data = data; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX *q_u, const POLICY_HND *hnd, - char *key, char* value, uint32 data_type, char* data, - uint32 data_size) -{ - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - q_u->type = data_type; - init_unistr2(&q_u->value, value, strlen(value)+1); - init_unistr2(&q_u->key, key, strlen(key)+1); - - q_u->max_len = q_u->real_len = data_size; - q_u->data = data; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_setprinterdata(const char *desc, SPOOL_Q_SETPRINTERDATA *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdata"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->value, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_u->type)) - return False; - - if(!prs_uint32("max_len", ps, depth, &q_u->max_len)) - return False; - - switch (q_u->type) - { - case REG_SZ: - case REG_BINARY: - case REG_DWORD: - case REG_MULTI_SZ: - if (q_u->max_len) { - if (UNMARSHALLING(ps)) - q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8)); - if(q_u->data == NULL) - return False; - if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len)) - return False; - } - if(!prs_align(ps)) - return False; - break; - } - - if(!prs_uint32("real_len", ps, depth, &q_u->real_len)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_setprinterdata(const char *desc, SPOOL_R_SETPRINTERDATA *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdata"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_q_resetprinter(const char *desc, SPOOL_Q_RESETPRINTER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_resetprinter"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - - if (!prs_uint32("datatype_ptr", ps, depth, &q_u->datatype_ptr)) - return False; - - if (q_u->datatype_ptr) { - if (!smb_io_unistr2("datatype", &q_u->datatype, q_u->datatype_ptr?True:False, ps, depth)) - return False; - } - - if (!spoolss_io_devmode_cont(desc, &q_u->devmode_ctr, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* -********************************************************************/ -BOOL spoolss_io_r_resetprinter(const char *desc, SPOOL_R_RESETPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_resetprinter"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -static BOOL spoolss_io_addform(const char *desc, FORM *f, uint32 ptr, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_addform"); - depth++; - if(!prs_align(ps)) - return False; - - if (ptr!=0) - { - if(!prs_uint32("flags", ps, depth, &f->flags)) - return False; - if(!prs_uint32("name_ptr", ps, depth, &f->name_ptr)) - return False; - if(!prs_uint32("size_x", ps, depth, &f->size_x)) - return False; - if(!prs_uint32("size_y", ps, depth, &f->size_y)) - return False; - if(!prs_uint32("left", ps, depth, &f->left)) - return False; - if(!prs_uint32("top", ps, depth, &f->top)) - return False; - if(!prs_uint32("right", ps, depth, &f->right)) - return False; - if(!prs_uint32("bottom", ps, depth, &f->bottom)) - return False; - - if(!smb_io_unistr2("", &f->name, f->name_ptr, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_deleteform(const char *desc, SPOOL_Q_DELETEFORM *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_deleteform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!smb_io_unistr2("form name", &q_u->name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_deleteform(const char *desc, SPOOL_R_DELETEFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_deleteform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_addform(const char *desc, SPOOL_Q_ADDFORM *q_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=1; - prs_debug(ps, depth, desc, "spoolss_io_q_addform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - if(!prs_uint32("level2", ps, depth, &q_u->level2)) - return False; - - if (q_u->level==1) - { - if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr)) - return False; - if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_addform(const char *desc, SPOOL_R_ADDFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_addform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_q_setform(const char *desc, SPOOL_Q_SETFORM *q_u, prs_struct *ps, int depth) -{ - uint32 useless_ptr=1; - prs_debug(ps, depth, desc, "spoolss_io_q_setform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - if(!prs_uint32("level2", ps, depth, &q_u->level2)) - return False; - - if (q_u->level==1) - { - if(!prs_uint32("useless_ptr", ps, depth, &useless_ptr)) - return False; - if(!spoolss_io_addform("", &q_u->form, useless_ptr, ps, depth)) - return False; - } - - return True; -} - -/******************************************************************* -********************************************************************/ - -BOOL spoolss_io_r_setform(const char *desc, SPOOL_R_SETFORM *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setform"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_GETJOB structure. -********************************************************************/ - -BOOL spoolss_io_r_getjob(const char *desc, SPOOL_R_GETJOB *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getjob"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_GETJOB structure. -********************************************************************/ - -BOOL spoolss_io_q_getjob(const char *desc, SPOOL_Q_GETJOB *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, ""); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if(!prs_uint32("jobid", ps, depth, &q_u->jobid)) - return False; - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -void free_devmode(DEVICEMODE *devmode) -{ - if (devmode!=NULL) { - SAFE_FREE(devmode->private); - SAFE_FREE(devmode); - } -} - -void free_printer_info_1(PRINTER_INFO_1 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_2(PRINTER_INFO_2 *printer) -{ - if (printer!=NULL) { - free_devmode(printer->devmode); - printer->devmode = NULL; - SAFE_FREE(printer); - } -} - -void free_printer_info_3(PRINTER_INFO_3 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_4(PRINTER_INFO_4 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_5(PRINTER_INFO_5 *printer) -{ - SAFE_FREE(printer); -} - -void free_printer_info_7(PRINTER_INFO_7 *printer) -{ - SAFE_FREE(printer); -} - -void free_job_info_2(JOB_INFO_2 *job) -{ - if (job!=NULL) - free_devmode(job->devmode); -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u, - const fstring string, uint32 printer, uint32 type) -{ - if (q_u == NULL) - return False; - - init_unistr2(&q_u->string, string, strlen(string)+1); - - q_u->printer=printer; - q_u->type=type; - - q_u->unknown0=0x0; - q_u->unknown1=0x0; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_REPLYOPENPRINTER structure. -********************************************************************/ - -BOOL spoolss_io_q_replyopenprinter(const char *desc, SPOOL_Q_REPLYOPENPRINTER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_replyopenprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_u->string, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("printer", ps, depth, &q_u->printer)) - return False; - if(!prs_uint32("type", ps, depth, &q_u->type)) - return False; - - if(!prs_uint32("unknown0", ps, depth, &q_u->unknown0)) - return False; - if(!prs_uint32("unknown1", ps, depth, &q_u->unknown1)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_REPLYOPENPRINTER structure. -********************************************************************/ - -BOOL spoolss_io_r_replyopenprinter(const char *desc, SPOOL_R_REPLYOPENPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_replyopenprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ -BOOL make_spoolss_q_routerreplyprinter(SPOOL_Q_ROUTERREPLYPRINTER *q_u, POLICY_HND *hnd, - uint32 condition, uint32 change_id) -{ - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - q_u->condition = condition; - q_u->change_id = change_id; - - /* magic values */ - q_u->unknown1 = 0x1; - memset(q_u->unknown2, 0x0, 5); - q_u->unknown2[0] = 0x1; - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_ROUTERREPLYPRINTER structure. -********************************************************************/ -BOOL spoolss_io_q_routerreplyprinter (const char *desc, SPOOL_Q_ROUTERREPLYPRINTER *q_u, prs_struct *ps, int depth) -{ - - prs_debug(ps, depth, desc, "spoolss_io_q_routerreplyprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - if (!prs_uint32("condition", ps, depth, &q_u->condition)) - return False; - - if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1)) - return False; - - if (!prs_uint32("change_id", ps, depth, &q_u->change_id)) - return False; - - if (!prs_uint8s(False, "private", ps, depth, q_u->unknown2, 5)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_ROUTERREPLYPRINTER structure. -********************************************************************/ -BOOL spoolss_io_r_routerreplyprinter (const char *desc, SPOOL_R_ROUTERREPLYPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_routerreplyprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_reply_closeprinter(SPOOL_Q_REPLYCLOSEPRINTER *q_u, POLICY_HND *hnd) -{ - if (q_u == NULL) - return False; - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_REPLYCLOSEPRINTER structure. -********************************************************************/ - -BOOL spoolss_io_q_replycloseprinter(const char *desc, SPOOL_Q_REPLYCLOSEPRINTER *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_replycloseprinter"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_REPLYCLOSEPRINTER structure. -********************************************************************/ - -BOOL spoolss_io_r_replycloseprinter(const char *desc, SPOOL_R_REPLYCLOSEPRINTER *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_replycloseprinter"); - depth++; - - if (!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&r_u->handle,ps,depth)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -#if 0 /* JERRY - not currently used but could be :-) */ - -/******************************************************************* - Deep copy a SPOOL_NOTIFY_INFO_DATA structure - ******************************************************************/ -static BOOL copy_spool_notify_info_data(SPOOL_NOTIFY_INFO_DATA *dst, - SPOOL_NOTIFY_INFO_DATA *src, int n) -{ - int i; - - memcpy(dst, src, sizeof(SPOOL_NOTIFY_INFO_DATA)*n); - - for (i=0; i<n; i++) { - int len; - uint16 *s = NULL; - - if (src->size != POINTER) - continue; - len = src->notify_data.data.length; - s = malloc(sizeof(uint16)*len); - if (s == NULL) { - DEBUG(0,("copy_spool_notify_info_data: malloc() failed!\n")); - return False; - } - - memcpy(s, src->notify_data.data.string, len*2); - dst->notify_data.data.string = s; - } - - return True; -} - -/******************************************************************* - Deep copy a SPOOL_NOTIFY_INFO structure - ******************************************************************/ -static BOOL copy_spool_notify_info(SPOOL_NOTIFY_INFO *dst, SPOOL_NOTIFY_INFO *src) -{ - if (!dst) { - DEBUG(0,("copy_spool_notify_info: NULL destination pointer!\n")); - return False; - } - - dst->version = src->version; - dst->flags = src->flags; - dst->count = src->count; - - if (dst->count) - { - dst->data = malloc(dst->count * sizeof(SPOOL_NOTIFY_INFO_DATA)); - - DEBUG(10,("copy_spool_notify_info: allocating space for [%d] PRINTER_NOTIFY_INFO_DATA entries\n", - dst->count)); - - if (dst->data == NULL) { - DEBUG(0,("copy_spool_notify_info: malloc() failed for [%d] entries!\n", - dst->count)); - return False; - } - - return (copy_spool_notify_info_data(dst->data, src->data, src->count)); - } - - return True; -} -#endif /* JERRY */ - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_reply_rrpcn(SPOOL_Q_REPLY_RRPCN *q_u, POLICY_HND *hnd, - uint32 change_low, uint32 change_high, - SPOOL_NOTIFY_INFO *info) -{ - if (q_u == NULL) - return False; - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - - q_u->change_low=change_low; - q_u->change_high=change_high; - - q_u->unknown0=0x0; - q_u->unknown1=0x0; - - q_u->info_ptr=0x0FF0ADDE; - - q_u->info.version=2; - - if (info->count) { - DEBUG(10,("make_spoolss_q_reply_rrpcn: [%d] PRINTER_NOTIFY_INFO_DATA\n", - info->count)); - q_u->info.version = info->version; - q_u->info.flags = info->flags; - q_u->info.count = info->count; - /* pointer field - be careful! */ - q_u->info.data = info->data; - } - else { - q_u->info.flags=PRINTER_NOTIFY_INFO_DISCARDED; - q_u->info.count=0; - } - - return True; -} - -/******************************************************************* - Parse a SPOOL_Q_REPLY_RRPCN structure. -********************************************************************/ - -BOOL spoolss_io_q_reply_rrpcn(const char *desc, SPOOL_Q_REPLY_RRPCN *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_reply_rrpcn"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - - if (!prs_uint32("change_low", ps, depth, &q_u->change_low)) - return False; - - if (!prs_uint32("change_high", ps, depth, &q_u->change_high)) - return False; - - if (!prs_uint32("unknown0", ps, depth, &q_u->unknown0)) - return False; - - if (!prs_uint32("unknown1", ps, depth, &q_u->unknown1)) - return False; - - if (!prs_uint32("info_ptr", ps, depth, &q_u->info_ptr)) - return False; - - if(q_u->info_ptr!=0) - if(!smb_io_notify_info(desc, &q_u->info, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Parse a SPOOL_R_REPLY_RRPCN structure. -********************************************************************/ - -BOOL spoolss_io_r_reply_rrpcn(const char *desc, SPOOL_R_REPLY_RRPCN *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_reply_rrpcn"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("unknown0", ps, depth, &r_u->unknown0)) - return False; - - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - * called from spoolss_q_getprinterdataex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_q_getprinterdataex(const char *desc, SPOOL_Q_GETPRINTERDATAEX *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdataex"); - depth++; - - if (!prs_align(ps)) - return False; - if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("keyname", &q_u->keyname,True,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth)) - return False; - if (!prs_align(ps)) - return False; - if (!prs_uint32("size", ps, depth, &q_u->size)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - * called from spoolss_r_getprinterdataex (srv_spoolss.c) - ********************************************************************/ - -BOOL spoolss_io_r_getprinterdataex(const char *desc, SPOOL_R_GETPRINTERDATAEX *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "spoolss_io_r_getprinterdataex"); - depth++; - - if (!prs_align(ps)) - return False; - if (!prs_uint32("type", ps, depth, &r_u->type)) - return False; - if (!prs_uint32("size", ps, depth, &r_u->size)) - return False; - - if (UNMARSHALLING(ps) && r_u->size) { - r_u->data = prs_alloc_mem(ps, r_u->size); - if(!r_u->data) - return False; - } - - if (!prs_uint8s(False,"data", ps, depth, r_u->data, r_u->size)) - return False; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - if (!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - ********************************************************************/ - -BOOL spoolss_io_q_setprinterdataex(const char *desc, SPOOL_Q_SETPRINTERDATAEX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_setprinterdataex"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - if(!smb_io_unistr2("", &q_u->key, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_u->value, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_u->type)) - return False; - - if(!prs_uint32("max_len", ps, depth, &q_u->max_len)) - return False; - - switch (q_u->type) - { - case 0x1: - case 0x3: - case 0x4: - case 0x7: - if (q_u->max_len) { - if (UNMARSHALLING(ps)) - q_u->data=(uint8 *)prs_alloc_mem(ps, q_u->max_len * sizeof(uint8)); - if(q_u->data == NULL) - return False; - if(!prs_uint8s(False,"data", ps, depth, q_u->data, q_u->max_len)) - return False; - } - if(!prs_align(ps)) - return False; - break; - } - - if(!prs_uint32("real_len", ps, depth, &q_u->real_len)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -BOOL spoolss_io_r_setprinterdataex(const char *desc, SPOOL_R_SETPRINTERDATAEX *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_setprinterdataex"); - depth++; - - if(!prs_align(ps)) - return False; - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - ********************************************************************/ -BOOL make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u, - POLICY_HND *hnd, const char *key, - uint32 size) -{ - DEBUG(5,("make_spoolss_q_enumprinterkey\n")); - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - init_unistr2(&q_u->key, key, strlen(key)+1); - q_u->size = size; - - return True; -} - -/******************************************************************* - * read a structure. - ********************************************************************/ - -BOOL spoolss_io_q_enumprinterkey(const char *desc, SPOOL_Q_ENUMPRINTERKEY *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterkey"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_u->key, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("size", ps, depth, &q_u->size)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -BOOL spoolss_io_r_enumprinterkey(const char *desc, SPOOL_R_ENUMPRINTERKEY *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterkey"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!smb_io_buffer5("", &r_u->keys, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -/******************************************************************* - * read a structure. - ********************************************************************/ - -BOOL make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY *q_u, - POLICY_HND *hnd, char *keyname) -{ - DEBUG(5,("make_spoolss_q_deleteprinterkey\n")); - - memcpy(&q_u->handle, hnd, sizeof(q_u->handle)); - init_unistr2(&q_u->keyname, keyname, strlen(keyname)+1); - - return True; -} - -/******************************************************************* - * read a structure. - ********************************************************************/ - -BOOL spoolss_io_q_deleteprinterkey(const char *desc, SPOOL_Q_DELETEPRINTERKEY *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterkey"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_u->keyname, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -BOOL spoolss_io_r_deleteprinterkey(const char *desc, SPOOL_R_DELETEPRINTERKEY *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_deleteprinterkey"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - - -/******************************************************************* - * read a structure. - ********************************************************************/ - -BOOL spoolss_io_q_enumprinterdataex(const char *desc, SPOOL_Q_ENUMPRINTERDATAEX *q_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_q_enumprinterdataex"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_pol_hnd("printer handle", &q_u->handle, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_u->key, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("size", ps, depth, &q_u->size)) - return False; - - return True; -} - -/******************************************************************* -********************************************************************/ - -static BOOL spoolss_io_printer_enum_values_ctr(const char *desc, prs_struct *ps, - PRINTER_ENUM_VALUES_CTR *ctr, int depth) -{ - int i; - uint32 valuename_offset, - data_offset, - current_offset; - const uint32 basic_unit = 20; /* size of static portion of enum_values */ - - prs_debug(ps, depth, desc, "spoolss_io_printer_enum_values_ctr"); - depth++; - - /* - * offset data begins at 20 bytes per structure * size_of_array. - * Don't forget the uint32 at the beginning - * */ - - current_offset = basic_unit * ctr->size_of_array; - - /* first loop to write basic enum_value information */ - - if (UNMARSHALLING(ps)) { - ctr->values = (PRINTER_ENUM_VALUES *)prs_alloc_mem( - ps, ctr->size_of_array * sizeof(PRINTER_ENUM_VALUES)); - if (!ctr->values) - return False; - } - - for (i=0; i<ctr->size_of_array; i++) { - valuename_offset = current_offset; - if (!prs_uint32("valuename_offset", ps, depth, &valuename_offset)) - return False; - - if (!prs_uint32("value_len", ps, depth, &ctr->values[i].value_len)) - return False; - - if (!prs_uint32("type", ps, depth, &ctr->values[i].type)) - return False; - - data_offset = ctr->values[i].value_len + valuename_offset; - - if (!prs_uint32("data_offset", ps, depth, &data_offset)) - return False; - - if (!prs_uint32("data_len", ps, depth, &ctr->values[i].data_len)) - return False; - - current_offset = data_offset + ctr->values[i].data_len - basic_unit; - /* account for 2 byte alignment */ - current_offset += (current_offset % 2); - } - - /* - * loop #2 for writing the dynamically size objects; pay - * attention to 2-byte alignment here.... - */ - - for (i=0; i<ctr->size_of_array; i++) { - - if (!prs_unistr("valuename", ps, depth, &ctr->values[i].valuename)) - return False; - - if (UNMARSHALLING(ps)) { - ctr->values[i].data = (uint8 *)prs_alloc_mem( - ps, ctr->values[i].data_len); - if (!ctr->values[i].data) - return False; - } - - if (!prs_uint8s(False, "data", ps, depth, ctr->values[i].data, ctr->values[i].data_len)) - return False; - - if ( !prs_align_uint16(ps) ) - return False; - } - - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -BOOL spoolss_io_r_enumprinterdataex(const char *desc, SPOOL_R_ENUMPRINTERDATAEX *r_u, prs_struct *ps, int depth) -{ - uint32 data_offset, end_offset; - prs_debug(ps, depth, desc, "spoolss_io_r_enumprinterdataex"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("size", ps, depth, &r_u->ctr.size)) - return False; - - data_offset = prs_offset(ps); - - if (!prs_set_offset(ps, data_offset + r_u->ctr.size)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_uint32("returned", ps, depth, &r_u->returned)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - r_u->ctr.size_of_array = r_u->returned; - - end_offset = prs_offset(ps); - - if (!prs_set_offset(ps, data_offset)) - return False; - - if (r_u->ctr.size) - if (!spoolss_io_printer_enum_values_ctr("", ps, &r_u->ctr, depth )) - return False; - - if (!prs_set_offset(ps, end_offset)) - return False; - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -/* - uint32 GetPrintProcessorDirectory( - [in] unistr2 *name, - [in] unistr2 *environment, - [in] uint32 level, - [in,out] NEW_BUFFER buffer, - [in] uint32 offered, - [out] uint32 needed, - [out] uint32 returned - ); - -*/ - -BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, const char *name, char *environment, int level, NEW_BUFFER *buffer, uint32 offered) -{ - DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n")); - - init_unistr2(&q_u->name, name, strlen(name)+1); - init_unistr2(&q_u->environment, environment, strlen(environment)+1); - - q_u->level = level; - - q_u->buffer = buffer; - q_u->offered = offered; - - return True; -} - -BOOL spoolss_io_q_getprintprocessordirectory(const char *desc, SPOOL_Q_GETPRINTPROCESSORDIRECTORY *q_u, prs_struct *ps, int depth) -{ - uint32 ptr; - - prs_debug(ps, depth, desc, "spoolss_io_q_getprintprocessordirectory"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!prs_uint32("ptr", ps, depth, &ptr)) - return False; - - if (ptr) { - if(!smb_io_unistr2("name", &q_u->name, True, ps, depth)) - return False; - } - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr", ps, depth, &ptr)) - return False; - - if (ptr) { - if(!smb_io_unistr2("environment", &q_u->environment, True, - ps, depth)) - return False; - } - - if (!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_u->level)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &q_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("offered", ps, depth, &q_u->offered)) - return False; - - return True; -} - -/******************************************************************* - * write a structure. - ********************************************************************/ - -BOOL spoolss_io_r_getprintprocessordirectory(const char *desc, SPOOL_R_GETPRINTPROCESSORDIRECTORY *r_u, prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "spoolss_io_r_getprintprocessordirectory"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!spoolss_io_buffer("", ps, depth, &r_u->buffer)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("needed", ps, depth, &r_u->needed)) - return False; - - if(!prs_werror("status", ps, depth, &r_u->status)) - return False; - - return True; -} - -BOOL smb_io_printprocessordirectory_1(const char *desc, NEW_BUFFER *buffer, PRINTPROCESSOR_DIRECTORY_1 *info, int depth) -{ - prs_struct *ps=&buffer->prs; - - prs_debug(ps, depth, desc, "smb_io_printprocessordirectory_1"); - depth++; - - buffer->struct_start=prs_offset(ps); - - if (!smb_io_unistr(desc, &info->name, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_addform(SPOOL_Q_ADDFORM *q_u, POLICY_HND *handle, - int level, FORM *form) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->level = level; - q_u->level2 = level; - memcpy(&q_u->form, form, sizeof(FORM)); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle, - int level, const char *form_name, FORM *form) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->level = level; - q_u->level2 = level; - memcpy(&q_u->form, form, sizeof(FORM)); - init_unistr2(&q_u->name, form_name, strlen(form_name) + 1); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle, - const char *form) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - init_unistr2(&q_u->name, form, strlen(form) + 1); - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle, - const char *formname, uint32 level, - NEW_BUFFER *buffer, uint32 offered) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->level = level; - init_unistr2(&q_u->formname, formname, strlen(formname) + 1); - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_enumforms(SPOOL_Q_ENUMFORMS *q_u, POLICY_HND *handle, - uint32 level, NEW_BUFFER *buffer, - uint32 offered) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->level = level; - q_u->buffer=buffer; - q_u->offered=offered; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_setjob(SPOOL_Q_SETJOB *q_u, POLICY_HND *handle, - uint32 jobid, uint32 level, uint32 command) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->jobid = jobid; - q_u->level = level; - - /* Hmm - the SPOOL_Q_SETJOB structure has a JOB_INFO ctr in it but - the server side code has it marked as unused. */ - - q_u->command = command; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_getjob(SPOOL_Q_GETJOB *q_u, POLICY_HND *handle, - uint32 jobid, uint32 level, NEW_BUFFER *buffer, - uint32 offered) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->jobid = jobid; - q_u->level = level; - q_u->buffer = buffer; - q_u->offered = offered; - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_startpageprinter(SPOOL_Q_STARTPAGEPRINTER *q_u, - POLICY_HND *handle) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_endpageprinter(SPOOL_Q_ENDPAGEPRINTER *q_u, - POLICY_HND *handle) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u, - POLICY_HND *handle, uint32 level, - char *docname, char *outputfile, - char *datatype) -{ - DOC_INFO_CONTAINER *ctr = &q_u->doc_info_container; - - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - - ctr->level = level; - - switch (level) { - case 1: - ctr->docinfo.switch_value = level; - - ctr->docinfo.doc_info_1.p_docname = docname ? 1 : 0; - ctr->docinfo.doc_info_1.p_outputfile = outputfile ? 1 : 0; - ctr->docinfo.doc_info_1.p_datatype = datatype ? 1 : 0; - - if (docname) - init_unistr2(&ctr->docinfo.doc_info_1.docname, docname, - strlen(docname) + 1); - - if (outputfile) - init_unistr2(&ctr->docinfo.doc_info_1.outputfile, outputfile, - strlen(outputfile) + 1); - - if (datatype) - init_unistr2(&ctr->docinfo.doc_info_1.datatype, datatype, - strlen(datatype) + 1); - - break; - case 2: - /* DOC_INFO_2 is only used by Windows 9x and since it - doesn't do printing over RPC we don't have to worry - about it. */ - default: - DEBUG(3, ("unsupported info level %d\n", level)); - return False; - } - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_enddocprinter(SPOOL_Q_ENDDOCPRINTER *q_u, - POLICY_HND *handle) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_writeprinter(SPOOL_Q_WRITEPRINTER *q_u, - POLICY_HND *handle, uint32 data_size, - char *data) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - q_u->buffer_size = q_u->buffer_size2 = data_size; - q_u->buffer = data; - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA *q_u, - POLICY_HND *handle, char *valuename) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX *q_u, - POLICY_HND *handle, char *key, - char *value) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - init_unistr2(&q_u->valuename, value, strlen(value) + 1); - init_unistr2(&q_u->keyname, key, strlen(key) + 1); - - return True; -} - -/******************************************************************* - * init a structure. - ********************************************************************/ - -BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle, - uint32 flags, uint32 options, const char *localmachine, - uint32 printerlocal, SPOOL_NOTIFY_OPTION *option) -{ - memcpy(&q_u->handle, handle, sizeof(POLICY_HND)); - - q_u->flags = flags; - q_u->options = options; - - q_u->localmachine_ptr = 1; - - init_unistr2(&q_u->localmachine, localmachine, - strlen(localmachine) + 1); - - q_u->printerlocal = printerlocal; - - if (option) - q_u->option_ptr = 1; - - q_u->option = option; - - return True; -} diff --git a/source4/rpc_parse/parse_srv.c b/source4/rpc_parse/parse_srv.c deleted file mode 100644 index bfa1a13be9..0000000000 --- a/source4/rpc_parse/parse_srv.c +++ /dev/null @@ -1,3590 +0,0 @@ -/* - * 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) Jeremy Allison 1999, - * Copyright (C) Nigel Williams 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 SH_INFO_0_STR structure -********************************************************************/ - -void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name) -{ - DEBUG(5,("init_srv_share_info0_str\n")); - - if(net_name) - init_unistr2(&sh0->uni_netname, net_name, strlen(net_name)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info0_str(const char *desc, SH_INFO_0_STR *sh0, prs_struct *ps, int depth) -{ - if (sh0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info0_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh0->ptrs->ptr_netname) - if(!smb_io_unistr2("", &sh0->uni_netname, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_0 structure -********************************************************************/ - -void init_srv_share_info0(SH_INFO_0 *sh0, const char *net_name) -{ - DEBUG(5,("init_srv_share_info0: %s\n", net_name)); - - sh0->ptr_netname = (net_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info0(const char *desc, SH_INFO_0 *sh0, prs_struct *ps, int depth) -{ - if (sh0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh0->ptr_netname)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1_STR structure -********************************************************************/ - -void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const char *remark) -{ - DEBUG(5,("init_srv_share_info1_str\n")); - - if(net_name) - init_unistr2(&sh1->uni_netname, net_name, strlen(net_name)+1); - if(remark) - init_unistr2(&sh1->uni_remark, remark, strlen(remark)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1_str(const char *desc, SH_INFO_1_STR *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(sh1->ptrs->ptr_netname) - if(!smb_io_unistr2("", &sh1->uni_netname, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(sh1->ptrs->ptr_remark) - if(!smb_io_unistr2("", &sh1->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1 structure -********************************************************************/ - -void init_srv_share_info1(SH_INFO_1 *sh1, const char *net_name, uint32 type, const char *remark) -{ - DEBUG(5,("init_srv_share_info1: %s %8x %s\n", net_name, type, remark)); - - sh1->ptr_netname = (net_name != NULL) ? 1 : 0; - sh1->type = type; - sh1->ptr_remark = (remark != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1(const char *desc, SH_INFO_1 *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh1->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh1->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh1->ptr_remark)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_2_STR structure -********************************************************************/ - -void init_srv_share_info2_str(SH_INFO_2_STR *sh2, - const char *net_name, const char *remark, - const char *path, const char *passwd) -{ - DEBUG(5,("init_srv_share_info2_str\n")); - - if (net_name) - init_unistr2(&sh2->uni_netname, net_name, strlen(net_name)+1); - if (remark) - init_unistr2(&sh2->uni_remark, remark, strlen(remark)+1); - if (path) - init_unistr2(&sh2->uni_path, path, strlen(path)+1); - if (passwd) - init_unistr2(&sh2->uni_passwd, passwd, strlen(passwd)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info2_str(const char *desc, SH_INFO_2 *sh, SH_INFO_2_STR *sh2, prs_struct *ps, int depth) -{ - if (sh2 == NULL) - return False; - - if (UNMARSHALLING(ps)) - ZERO_STRUCTP(sh2); - - prs_debug(ps, depth, desc, "srv_io_share_info2_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if (sh->ptr_netname) - if(!smb_io_unistr2("", &sh2->uni_netname, True, ps, depth)) - return False; - - if (sh->ptr_remark) - if(!smb_io_unistr2("", &sh2->uni_remark, True, ps, depth)) - return False; - - if (sh->ptr_netname) - if(!smb_io_unistr2("", &sh2->uni_path, True, ps, depth)) - return False; - - if (sh->ptr_passwd) - if(!smb_io_unistr2("", &sh2->uni_passwd, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_2 structure -********************************************************************/ - -void init_srv_share_info2(SH_INFO_2 *sh2, - const char *net_name, uint32 type, const char *remark, - uint32 perms, uint32 max_uses, uint32 num_uses, - const char *path, const char *passwd) -{ - DEBUG(5,("init_srv_share_info2: %s %8x %s\n", net_name, type, remark)); - - sh2->ptr_netname = (net_name != NULL) ? 1 : 0; - sh2->type = type; - sh2->ptr_remark = (remark != NULL) ? 1 : 0; - sh2->perms = perms; - sh2->max_uses = max_uses; - sh2->num_uses = num_uses; - sh2->ptr_path = (path != NULL) ? 1 : 0; - sh2->ptr_passwd = (passwd != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info2(const char *desc, SH_INFO_2 *sh2, prs_struct *ps, int depth) -{ - if (sh2 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info2"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh2->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh2->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh2->ptr_remark)) - return False; - if(!prs_uint32("perms ", ps, depth, &sh2->perms)) - return False; - if(!prs_uint32("max_uses ", ps, depth, &sh2->max_uses)) - return False; - if(!prs_uint32("num_uses ", ps, depth, &sh2->num_uses)) - return False; - if(!prs_uint32("ptr_path ", ps, depth, &sh2->ptr_path)) - return False; - if(!prs_uint32("ptr_passwd ", ps, depth, &sh2->ptr_passwd)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_501_STR structure -********************************************************************/ - -void init_srv_share_info501_str(SH_INFO_501_STR *sh501, - const char *net_name, const char *remark) -{ - DEBUG(5,("init_srv_share_info501_str\n")); - - if(net_name) - init_unistr2(&sh501->uni_netname, net_name, strlen(net_name)+1); - if(remark) - init_unistr2(&sh501->uni_remark, remark, strlen(remark)+1); -} - -/******************************************************************* - Inits a SH_INFO_2 structure -*******************************************************************/ - -void init_srv_share_info501(SH_INFO_501 *sh501, const char *net_name, uint32 type, const char *remark, uint32 csc_policy) -{ - DEBUG(5,("init_srv_share_info501: %s %8x %s %08x\n", net_name, type, - remark, csc_policy)); - - ZERO_STRUCTP(sh501); - - sh501->ptr_netname = (net_name != NULL) ? 1 : 0; - sh501->type = type; - sh501->ptr_remark = (remark != NULL) ? 1 : 0; - sh501->csc_policy = csc_policy; -} - -/******************************************************************* - Reads of writes a structure. -*******************************************************************/ - -static BOOL srv_io_share_info501(const char *desc, SH_INFO_501 *sh501, prs_struct *ps, int depth) -{ - if (sh501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info501"); - depth++; - - if (!prs_align(ps)) - return False; - - if (!prs_uint32("ptr_netname", ps, depth, &sh501->ptr_netname)) - return False; - if (!prs_uint32("type ", ps, depth, &sh501->type)) - return False; - if (!prs_uint32("ptr_remark ", ps, depth, &sh501->ptr_remark)) - return False; - if (!prs_uint32("csc_policy ", ps, depth, &sh501->csc_policy)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info501_str(const char *desc, SH_INFO_501_STR *sh501, prs_struct *ps, int depth) -{ - if (sh501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info501_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("", &sh501->uni_netname, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("", &sh501->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_502 structure -********************************************************************/ - -void init_srv_share_info502(SH_INFO_502 *sh502, - const char *net_name, uint32 type, const char *remark, - uint32 perms, uint32 max_uses, uint32 num_uses, - const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size) -{ - DEBUG(5,("init_srv_share_info502: %s %8x %s\n", net_name, type, remark)); - - ZERO_STRUCTP(sh502); - - sh502->ptr_netname = (net_name != NULL) ? 1 : 0; - sh502->type = type; - sh502->ptr_remark = (remark != NULL) ? 1 : 0; - sh502->perms = perms; - sh502->max_uses = max_uses; - sh502->num_uses = num_uses; - sh502->ptr_path = (path != NULL) ? 1 : 0; - sh502->ptr_passwd = (passwd != NULL) ? 1 : 0; - sh502->reserved = 0; /* actual size within rpc */ - sh502->sd_size = (uint32)sd_size; - sh502->ptr_sd = (psd != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info502(const char *desc, SH_INFO_502 *sh502, prs_struct *ps, int depth) -{ - if (sh502 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info502"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_netname", ps, depth, &sh502->ptr_netname)) - return False; - if(!prs_uint32("type ", ps, depth, &sh502->type)) - return False; - if(!prs_uint32("ptr_remark ", ps, depth, &sh502->ptr_remark)) - return False; - if(!prs_uint32("perms ", ps, depth, &sh502->perms)) - return False; - if(!prs_uint32("max_uses ", ps, depth, &sh502->max_uses)) - return False; - if(!prs_uint32("num_uses ", ps, depth, &sh502->num_uses)) - return False; - if(!prs_uint32("ptr_path ", ps, depth, &sh502->ptr_path)) - return False; - if(!prs_uint32("ptr_passwd ", ps, depth, &sh502->ptr_passwd)) - return False; - if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &sh502->reserved_offset)) - return False; - if(!prs_uint32("ptr_sd ", ps, depth, &sh502->ptr_sd)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_502_STR structure -********************************************************************/ - -void init_srv_share_info502_str(SH_INFO_502_STR *sh502str, - const char *net_name, const char *remark, - const char *path, const char *passwd, SEC_DESC *psd, size_t sd_size) -{ - DEBUG(5,("init_srv_share_info502_str\n")); - - if(net_name) - init_unistr2(&sh502str->uni_netname, net_name, strlen(net_name)+1); - if(remark) - init_unistr2(&sh502str->uni_remark, remark, strlen(remark)+1); - if(path) - init_unistr2(&sh502str->uni_path, path, strlen(path)+1); - if(passwd) - init_unistr2(&sh502str->uni_passwd, passwd, strlen(passwd)+1); - sh502str->sd = psd; - sh502str->reserved = 0; - sh502str->sd_size = sd_size; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info502_str(const char *desc, SH_INFO_502_STR *sh502, prs_struct *ps, int depth) -{ - if (sh502 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info502_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_netname) { - if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_remark) { - if(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_path) { - if(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_passwd) { - if(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - - if(sh502->ptrs->ptr_sd) { - uint32 old_offset; - uint32 reserved_offset; - - if(!prs_uint32_pre("reserved ", ps, depth, &sh502->reserved, &reserved_offset)) - return False; - - old_offset = prs_offset(ps); - - if (!sec_io_desc(desc, &sh502->sd, ps, depth)) - return False; - - if(UNMARSHALLING(ps)) { - - sh502->ptrs->sd_size = sh502->sd_size = sec_desc_size(sh502->sd); - - prs_set_offset(ps, old_offset + sh502->reserved); - } - - prs_align(ps); - - if(MARSHALLING(ps)) { - - sh502->ptrs->reserved = sh502->reserved = prs_offset(ps) - old_offset; - } - - if(!prs_uint32_post("reserved ", ps, depth, - &sh502->reserved, reserved_offset, sh502->reserved)) - return False; - if(!prs_uint32_post("reserved ", ps, depth, - &sh502->ptrs->reserved, sh502->ptrs->reserved_offset, sh502->ptrs->reserved)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1004_STR structure -********************************************************************/ - -void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark) -{ - DEBUG(5,("init_srv_share_info1004_str\n")); - - if(remark) - init_unistr2(&sh1004->uni_remark, remark, strlen(remark)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1004_str(const char *desc, SH_INFO_1004_STR *sh1004, prs_struct *ps, int depth) -{ - if (sh1004 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1004_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh1004->ptrs->ptr_remark) - if(!smb_io_unistr2("", &sh1004->uni_remark, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1004 structure -********************************************************************/ - -void init_srv_share_info1004(SH_INFO_1004 *sh1004, const char *remark) -{ - DEBUG(5,("init_srv_share_info1004: %s\n", remark)); - - sh1004->ptr_remark = (remark != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1004(const char *desc, SH_INFO_1004 *sh1004, prs_struct *ps, int depth) -{ - if (sh1004 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1004"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_remark", ps, depth, &sh1004->ptr_remark)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1005(const char* desc, SRV_SHARE_INFO_1005* sh1005, prs_struct* ps, int depth) -{ - if(sh1005 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1005"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("dfs_root_flag", ps, depth, &sh1005->dfs_root_flag)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1006(const char* desc, SRV_SHARE_INFO_1006* sh1006, prs_struct* ps, int depth) -{ - if(sh1006 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1006"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("max uses ", ps, depth, &sh1006->max_uses)) - return False; - - return True; -} - -/******************************************************************* - Inits a SH_INFO_1007_STR structure -********************************************************************/ - -void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate_directory_name) -{ - DEBUG(5,("init_srv_share_info1007_str\n")); - - if(alternate_directory_name) - init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, strlen(alternate_directory_name)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1007_str(const char *desc, SH_INFO_1007_STR *sh1007, prs_struct *ps, int depth) -{ - if (sh1007 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1007_str"); - depth++; - - if(!prs_align(ps)) - return False; - if(sh1007->ptrs->ptr_AlternateDirectoryName) - if(!smb_io_unistr2("", &sh1007->uni_AlternateDirectoryName, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - makes a SH_INFO_1007 structure -********************************************************************/ - -void init_srv_share_info1007(SH_INFO_1007 *sh1007, uint32 flags, const char *alternate_directory_name) -{ - DEBUG(5,("init_srv_share_info1007: %s\n", alternate_directory_name)); - - sh1007->flags = flags; - sh1007->ptr_AlternateDirectoryName = (alternate_directory_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1007(const char *desc, SH_INFO_1007 *sh1007, prs_struct *ps, int depth) -{ - if (sh1007 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1007"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("flags ", ps, depth, &sh1007->flags)) - return False; - if(!prs_uint32("ptr_Alter..", ps, depth, &sh1007->ptr_AlternateDirectoryName)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_share_info1501(const char* desc, SRV_SHARE_INFO_1501* sh1501, - prs_struct* ps, int depth) -{ - if(sh1501 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_share_info1501"); - depth++; - - if(!prs_align(ps)) - return False; - - if (!sec_io_desc_buf(desc, &sh1501->sdb, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_share_ctr(const char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_share_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - memset(ctr, '\0', sizeof(SRV_SHARE_INFO_CTR)); - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &ctr->info_level)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_share_info", ps, depth, &ctr->ptr_share_info)) - return False; - - if (ctr->ptr_share_info == 0) - return True; - - if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries)) - return False; - - if (ctr->ptr_entries == 0) { - if (ctr->num_entries == 0) - return True; - else - return False; - } - - if(!prs_uint32("num_entries2", ps, depth, &ctr->num_entries2)) - return False; - - if (ctr->num_entries2 != ctr->num_entries) - return False; - - switch (ctr->switch_value) { - - case 0: - { - SRV_SHARE_INFO_0 *info0 = ctr->share.info0; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info0 = (SRV_SHARE_INFO_0 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_0)))) - return False; - ctr->share.info0 = info0; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info0("", &info0[i].info_0, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info0[i].info_0_str.ptrs = &info0[i].info_0; - if(!srv_io_share_info0_str("", &info0[i].info_0_str, ps, depth)) - return False; - } - - break; - } - - case 1: - { - SRV_SHARE_INFO_1 *info1 = ctr->share.info1; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1 = (SRV_SHARE_INFO_1 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_SHARE_INFO_1)))) - return False; - ctr->share.info1 = info1; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1("", &info1[i].info_1, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1[i].info_1_str.ptrs = &info1[i].info_1; - if(!srv_io_share_info1_str("", &info1[i].info_1_str, ps, depth)) - return False; - } - - break; - } - - case 2: - { - SRV_SHARE_INFO_2 *info2 = ctr->share.info2; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info2 = (SRV_SHARE_INFO_2 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_2)))) - return False; - ctr->share.info2 = info2; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info2("", &info2[i].info_2, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info2_str("", &info2[i].info_2, &info2[i].info_2_str, ps, depth)) - return False; - } - - break; - } - - case 501: - { - SRV_SHARE_INFO_501 *info501 = ctr->share.info501; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info501 = (SRV_SHARE_INFO_501 *) prs_alloc_mem(ps, num_entries * - sizeof (SRV_SHARE_INFO_501)))) - return False; - ctr->share.info501 = info501; - } - - for (i = 0; i < num_entries; i++) { - if (!srv_io_share_info501("", &info501[i].info_501, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if (!srv_io_share_info501_str("", &info501[i].info_501_str, ps, depth)) - return False; - } - - break; - } - - case 502: - { - SRV_SHARE_INFO_502 *info502 = ctr->share.info502; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info502 = (SRV_SHARE_INFO_502 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_502)))) - return False; - ctr->share.info502 = info502; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info502("", &info502[i].info_502, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info502[i].info_502_str.ptrs = &info502[i].info_502; - if(!srv_io_share_info502_str("", &info502[i].info_502_str, ps, depth)) - return False; - } - - break; - } - - case 1004: - { - SRV_SHARE_INFO_1004 *info1004 = ctr->share.info1004; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1004 = (SRV_SHARE_INFO_1004 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1004)))) - return False; - ctr->share.info1004 = info1004; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1004("", &info1004[i].info_1004, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1004[i].info_1004_str.ptrs = &info1004[i].info_1004; - if(!srv_io_share_info1004_str("", &info1004[i].info_1004_str, ps, depth)) - return False; - } - - break; - } - - case 1005: - { - SRV_SHARE_INFO_1005 *info1005 = ctr->share.info1005; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1005 = (SRV_SHARE_INFO_1005 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1005)))) - return False; - ctr->share.info1005 = info1005; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1005("", &info1005[i], ps, depth)) - return False; - } - - break; - } - - case 1006: - { - SRV_SHARE_INFO_1006 *info1006 = ctr->share.info1006; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1006 = (SRV_SHARE_INFO_1006 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1006)))) - return False; - ctr->share.info1006 = info1006; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1006("", &info1006[i], ps, depth)) - return False; - } - - break; - } - - case 1007: - { - SRV_SHARE_INFO_1007 *info1007 = ctr->share.info1007; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1007 = (SRV_SHARE_INFO_1007 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1007)))) - return False; - ctr->share.info1007 = info1007; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1007("", &info1007[i].info_1007, ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - info1007[i].info_1007_str.ptrs = &info1007[i].info_1007; - if(!srv_io_share_info1007_str("", &info1007[i].info_1007_str, ps, depth)) - return False; - } - - break; - } - - case 1501: - { - SRV_SHARE_INFO_1501 *info1501 = ctr->share.info1501; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info1501 = (SRV_SHARE_INFO_1501 *)prs_alloc_mem(ps,num_entries * sizeof(SRV_SHARE_INFO_1501)))) - return False; - ctr->share.info1501 = info1501; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_share_info1501("", &info1501[i], ps, depth)) - return False; - } - - break; - } - - default: - DEBUG(5,("%s no share info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SHARE_ENUM structure. -********************************************************************/ - -void init_srv_q_net_share_enum(SRV_Q_NET_SHARE_ENUM *q_n, - const char *srv_name, uint32 info_level, - uint32 preferred_len, ENUM_HND *hnd) -{ - - DEBUG(5,("init_q_net_share_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - - q_n->ctr.info_level = q_n->ctr.switch_value = info_level; - q_n->ctr.ptr_share_info = 1; - q_n->ctr.num_entries = 0; - q_n->ctr.ptr_entries = 0; - q_n->ctr.num_entries2 = 0; - q_n->preferred_len = preferred_len; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_enum(const char *desc, SRV_Q_NET_SHARE_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!srv_io_srv_share_ctr("share_ctr", &q_n->ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_enum(const char *desc, SRV_R_NET_SHARE_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_enum"); - depth++; - - if(!srv_io_srv_share_ctr("share_ctr", &r_n->ctr, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. -********************************************************************/ - -BOOL init_srv_q_net_share_get_info(SRV_Q_NET_SHARE_GET_INFO *q_n, const char *srv_name, const char *share_name, uint32 info_level) -{ - - uint32 ptr_share_name; - - DEBUG(5,("init_srv_q_net_share_get_info\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name); - - q_n->info_level = info_level; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_get_info(const char *desc, SRV_Q_NET_SHARE_GET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_share_info(const char *desc, prs_struct *ps, int depth, SRV_SHARE_INFO *r_n) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_share_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &r_n->switch_value )) - return False; - - if(!prs_uint32("ptr_share_ctr", ps, depth, &r_n->ptr_share_ctr)) - return False; - - if (r_n->ptr_share_ctr != 0) { - switch (r_n->switch_value) { - case 0: - if(!srv_io_share_info0("", &r_n->share.info0.info_0, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info0.info_0_str.ptrs = &r_n->share.info0.info_0; - - if(!srv_io_share_info0_str("", &r_n->share.info0.info_0_str, ps, depth)) - return False; - - break; - case 1: - if(!srv_io_share_info1("", &r_n->share.info1.info_1, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1.info_1_str.ptrs = &r_n->share.info1.info_1; - - if(!srv_io_share_info1_str("", &r_n->share.info1.info_1_str, ps, depth)) - return False; - - break; - case 2: - if(!srv_io_share_info2("", &r_n->share.info2.info_2, ps, depth)) - return False; - - if(!srv_io_share_info2_str("", &r_n->share.info2.info_2, &r_n->share.info2.info_2_str, ps, depth)) - return False; - - break; - case 501: - if (!srv_io_share_info501("", &r_n->share.info501.info_501, ps, depth)) - return False; - if (!srv_io_share_info501_str("", &r_n->share.info501.info_501_str, ps, depth)) - return False; - break; - - case 502: - if(!srv_io_share_info502("", &r_n->share.info502.info_502, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info502.info_502_str.ptrs = &r_n->share.info502.info_502; - - if(!srv_io_share_info502_str("", &r_n->share.info502.info_502_str, ps, depth)) - return False; - break; - case 1004: - if(!srv_io_share_info1004("", &r_n->share.info1004.info_1004, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1004.info_1004_str.ptrs = &r_n->share.info1004.info_1004; - - if(!srv_io_share_info1004_str("", &r_n->share.info1004.info_1004_str, ps, depth)) - return False; - break; - case 1005: - if(!srv_io_share_info1005("", &r_n->share.info1005, ps, depth)) - return False; - break; - case 1006: - if(!srv_io_share_info1006("", &r_n->share.info1006, ps, depth)) - return False; - break; - case 1007: - if(!srv_io_share_info1007("", &r_n->share.info1007.info_1007, ps, depth)) - return False; - - /* allow access to pointers in the str part. */ - r_n->share.info1007.info_1007_str.ptrs = &r_n->share.info1007.info_1007; - - if(!srv_io_share_info1007_str("", &r_n->share.info1007.info_1007_str, ps, depth)) - return False; - break; - case 1501: - if (!srv_io_share_info1501("", &r_n->share.info1501, ps, depth)) - return False; - default: - DEBUG(5,("%s no share info at switch_value %d\n", - tab_depth(depth), r_n->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_get_info(const char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &r_n->info)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - intialises a structure. -********************************************************************/ - -BOOL init_srv_q_net_share_set_info(SRV_Q_NET_SHARE_SET_INFO *q_n, - const char *srv_name, - const char *share_name, - uint32 info_level, - const SRV_SHARE_INFO *info) -{ - - uint32 ptr_share_name; - - DEBUG(5,("init_srv_q_net_share_set_info\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_share_name, &ptr_share_name, share_name); - - q_n->info_level = info_level; - - q_n->info = *info; - - q_n->ptr_parm_error = 1; - q_n->parm_error = 0; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_set_info(const char *desc, SRV_Q_NET_SHARE_SET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_parm_error", ps, depth, &q_n->ptr_parm_error)) - return False; - if(q_n->ptr_parm_error!=0) { - if(!prs_uint32("parm_error", ps, depth, &q_n->parm_error)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_set_info(const char *desc, SRV_R_NET_SHARE_SET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_parm_error ", ps, depth, &r_n->ptr_parm_error)) - return False; - - if(r_n->ptr_parm_error) { - - if(!prs_uint32("parm_error ", ps, depth, &r_n->parm_error)) - return False; - } - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_add(const char *desc, SRV_Q_NET_SHARE_ADD *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_add"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("info_level", ps, depth, &q_n->info_level)) - return False; - - if(!prs_align(ps)) - return False; - - if(!srv_io_srv_share_info("info ", ps, depth, &q_n->info)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_err_index", ps, depth, &q_n->ptr_err_index)) - return False; - if (q_n->ptr_err_index) - if (!prs_uint32("err_index", ps, depth, &q_n->err_index)) - return False; - - return True; -} - -void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname, - const char *netname, uint32 type, const char *remark, - uint32 perms, uint32 max_uses, uint32 num_uses, - const char *path, const char *passwd) -{ - q->ptr_srv_name = 1; - init_unistr2(&q->uni_srv_name, srvname, strlen(srvname) +1); - q->info.switch_value = q->info_level = 2; - - q->info.ptr_share_ctr = 1; - init_srv_share_info2(&q->info.share.info2.info_2, netname, type, - remark, perms, max_uses, num_uses, path, passwd); - init_srv_share_info2_str(&q->info.share.info2.info_2_str, netname, - remark, path, passwd); - q->ptr_err_index = 1; - q->err_index = 0; -} - - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_add(const char *desc, SRV_R_NET_SHARE_ADD *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_add"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_parm_error", ps, depth, &r_n->ptr_parm_error)) - return False; - - if(r_n->ptr_parm_error) { - - if(!prs_uint32("parm_error", ps, depth, &r_n->parm_error)) - return False; - } - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. -********************************************************************/ - -void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname, - const char *sharename) -{ - del->ptr_srv_name = 1; - init_unistr2(&del->uni_srv_name, srvname, strlen(srvname) +1 ); - init_unistr2(&del->uni_share_name, sharename, strlen(sharename) + 1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_share_del(const char *desc, SRV_Q_NET_SHARE_DEL *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_share_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_share_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("reserved", ps, depth, &q_n->reserved)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_share_del(const char *desc, SRV_R_NET_SHARE_DEL *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_share_del"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &q_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_0_STR structure -********************************************************************/ - -void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, const char *name) -{ - DEBUG(5,("init_srv_sess_info0_str\n")); - - init_unistr2(&ss0->uni_name, name, strlen(name)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_sess_info0_str(const char *desc, SESS_INFO_0_STR *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_sess_info0_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &ss0->uni_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_0 structure -********************************************************************/ - -void init_srv_sess_info0(SESS_INFO_0 *ss0, const char *name) -{ - DEBUG(5,("init_srv_sess_info0: %s\n", name)); - - ss0->ptr_name = (name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_sess_info0(const char *desc, SESS_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_sess_info0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_name", ps, depth, &ss0->ptr_name)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_info_0(const char *desc, SRV_SESS_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_info_0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read)) - return False; - if(!prs_uint32("ptr_sess_info", ps, depth, &ss0->ptr_sess_info)) - return False; - - if (ss0->ptr_sess_info != 0) { - int i; - int num_entries = ss0->num_entries_read; - - if (num_entries > MAX_SESS_ENTRIES) { - num_entries = MAX_SESS_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2)) - return False; - - SMB_ASSERT_ARRAY(ss0->info_0, num_entries); - - for (i = 0; i < num_entries; i++) { - if(!srv_io_sess_info0("", &ss0->info_0[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_sess_info0_str("", &ss0->info_0_str[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_1_STR structure -********************************************************************/ - -void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, const char *name, const char *user) -{ - DEBUG(5,("init_srv_sess_info1_str\n")); - - init_unistr2(&ss1->uni_name, name, strlen(name)+1); - init_unistr2(&ss1->uni_user, user, strlen(user)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_sess_info1_str(const char *desc, SESS_INFO_1_STR *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_sess_info1_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &ss1->uni_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("", &(ss1->uni_user), True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SESS_INFO_1 structure -********************************************************************/ - -void init_srv_sess_info1(SESS_INFO_1 *ss1, - const char *name, const char *user, - uint32 num_opens, uint32 open_time, uint32 idle_time, - uint32 user_flags) -{ - DEBUG(5,("init_srv_sess_info1: %s\n", name)); - - ss1->ptr_name = (name != NULL) ? 1 : 0; - ss1->ptr_user = (user != NULL) ? 1 : 0; - - ss1->num_opens = num_opens; - ss1->open_time = open_time; - ss1->idle_time = idle_time; - ss1->user_flags = user_flags; -} - -/******************************************************************* -reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_sess_info1(const char *desc, SESS_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_sess_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_name ", ps, depth, &ss1->ptr_name)) - return False; - if(!prs_uint32("ptr_user ", ps, depth, &ss1->ptr_user)) - return False; - - if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens)) - return False; - if(!prs_uint32("open_time ", ps, depth, &ss1->open_time)) - return False; - if(!prs_uint32("idle_time ", ps, depth, &ss1->idle_time)) - return False; - if(!prs_uint32("user_flags", ps, depth, &ss1->user_flags)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_info_1(const char *desc, SRV_SESS_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_info_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read)) - return False; - if(!prs_uint32("ptr_sess_info", ps, depth, &ss1->ptr_sess_info)) - return False; - - if (ss1->ptr_sess_info != 0) { - int i; - int num_entries = ss1->num_entries_read; - - if (num_entries > MAX_SESS_ENTRIES) { - num_entries = MAX_SESS_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2)) - return False; - - SMB_ASSERT_ARRAY(ss1->info_1, num_entries); - - for (i = 0; i < num_entries; i++) { - if(!srv_io_sess_info1("", &ss1->info_1[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_sess_info1_str("", &ss1->info_1_str[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_sess_ctr(const char *desc, SRV_SESS_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - SRV_SESS_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "srv_io_srv_sess_ctr"); - depth++; - - if(UNMARSHALLING(ps)) { - ctr = *pp_ctr = (SRV_SESS_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_SESS_INFO_CTR)); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_sess_ctr", ps, depth, &ctr->ptr_sess_ctr)) - return False; - - if (ctr->ptr_sess_ctr != 0) { - switch (ctr->switch_value) { - case 0: - if(!srv_io_srv_sess_info_0("", &ctr->sess.info0, ps, depth)) - return False; - break; - case 1: - if(!srv_io_srv_sess_info_1("", &ctr->sess.info1, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no session info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SESS_ENUM structure. -********************************************************************/ - -void init_srv_q_net_sess_enum(SRV_Q_NET_SESS_ENUM *q_n, - const char *srv_name, const char *qual_name, - const char *user_name, uint32 sess_level, - SRV_SESS_INFO_CTR *ctr, uint32 preferred_len, - ENUM_HND *hnd) -{ - q_n->ctr = ctr; - - DEBUG(5,("init_q_net_sess_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name); - init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name); - - q_n->sess_level = sess_level; - q_n->preferred_len = preferred_len; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_sess_enum(const char *desc, SRV_Q_NET_SESS_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_sess_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sess_level", ps, depth, &q_n->sess_level)) - return False; - - if (q_n->sess_level != -1) { - if(!srv_io_srv_sess_ctr("sess_ctr", &q_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level)) - return False; - - if (r_n->sess_level != -1) { - if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_0 structure -********************************************************************/ - -void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id) -{ - DEBUG(5,("init_srv_conn_info0\n")); - - ss0->id = id; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id", ps, depth, &ss0->id)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth) -{ - if (ss0 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read)) - return False; - if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info)) - return False; - - if (ss0->ptr_conn_info != 0) { - int i; - int num_entries = ss0->num_entries_read; - - if (num_entries > MAX_CONN_ENTRIES) { - num_entries = MAX_CONN_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2)) - return False; - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_1_STR structure -********************************************************************/ - -void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name) -{ - DEBUG(5,("init_srv_conn_info1_str\n")); - - init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1); - init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info1_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a CONN_INFO_1 structure -********************************************************************/ - -void init_srv_conn_info1(CONN_INFO_1 *ss1, - uint32 id, uint32 type, - uint32 num_opens, uint32 num_users, uint32 open_time, - const char *usr_name, const char *net_name) -{ - DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name)); - - ss1->id = id ; - ss1->type = type ; - ss1->num_opens = num_opens ; - ss1->num_users = num_users; - ss1->open_time = open_time; - - ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0; - ss1->ptr_net_name = (net_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_conn_info1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id ", ps, depth, &ss1->id)) - return False; - if(!prs_uint32("type ", ps, depth, &ss1->type)) - return False; - if(!prs_uint32("num_opens ", ps, depth, &ss1->num_opens)) - return False; - if(!prs_uint32("num_users ", ps, depth, &ss1->num_users)) - return False; - if(!prs_uint32("open_time ", ps, depth, &ss1->open_time)) - return False; - - if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name)) - return False; - if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth) -{ - if (ss1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read)) - return False; - if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info)) - return False; - - if (ss1->ptr_conn_info != 0) { - int i; - int num_entries = ss1->num_entries_read; - - if (num_entries > MAX_CONN_ENTRIES) { - num_entries = MAX_CONN_ENTRIES; /* report this! */ - } - - if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2)) - return False; - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth)) - return False; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth)) - return False; - } - - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth) -{ - SRV_CONN_INFO_CTR *ctr = *pp_ctr; - - prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - ctr = *pp_ctr = (SRV_CONN_INFO_CTR *)prs_alloc_mem(ps, sizeof(SRV_CONN_INFO_CTR)); - if (ctr == NULL) - return False; - } - - if (ctr == NULL) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr)) - return False; - - if (ctr->ptr_conn_ctr != 0) { - switch (ctr->switch_value) { - case 0: - if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth)) - return False; - break; - case 1: - if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no connection info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - } - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, - const char *srv_name, const char *qual_name, - uint32 conn_level, SRV_CONN_INFO_CTR *ctr, - uint32 preferred_len, - ENUM_HND *hnd) -{ - DEBUG(5,("init_q_net_conn_enum\n")); - - q_n->ctr = ctr; - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name ); - init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name); - - q_n->conn_level = conn_level; - q_n->preferred_len = preferred_len; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level)) - return False; - - if (q_n->conn_level != -1) { - if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_conn_enum(const char *desc, SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level)) - return False; - - if (r_n->conn_level != -1) { - if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a FILE_INFO_3_STR structure -********************************************************************/ - -void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, const char *user_name, const char *path_name) -{ - DEBUG(5,("init_srv_file_info3_str\n")); - - init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1); - init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth) -{ - if (sh1 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_file_info3_str"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &sh1->uni_path_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("", &sh1->uni_user_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a FILE_INFO_3 structure -********************************************************************/ - -void init_srv_file_info3(FILE_INFO_3 *fl3, - uint32 id, uint32 perms, uint32 num_locks, - const char *path_name, const char *user_name) -{ - DEBUG(5,("init_srv_file_info3: %s %s\n", path_name, user_name)); - - fl3->id = id; - fl3->perms = perms; - fl3->num_locks = num_locks; - - fl3->ptr_path_name = (path_name != NULL) ? 1 : 0; - fl3->ptr_user_name = (user_name != NULL) ? 1 : 0; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_file_info3(const char *desc, FILE_INFO_3 *fl3, prs_struct *ps, int depth) -{ - if (fl3 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_file_info3"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("id ", ps, depth, &fl3->id)) - return False; - if(!prs_uint32("perms ", ps, depth, &fl3->perms)) - return False; - if(!prs_uint32("num_locks ", ps, depth, &fl3->num_locks)) - return False; - if(!prs_uint32("ptr_path_name", ps, depth, &fl3->ptr_path_name)) - return False; - if(!prs_uint32("ptr_user_name", ps, depth, &fl3->ptr_user_name)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -static BOOL srv_io_srv_file_ctr(const char *desc, SRV_FILE_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_srv_file_ctr"); - depth++; - - if (UNMARSHALLING(ps)) { - memset(ctr, '\0', sizeof(SRV_FILE_INFO_CTR)); - } - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if (ctr->switch_value != 3) { - DEBUG(5,("%s File info %d level not supported\n", - tab_depth(depth), ctr->switch_value)); - } - if(!prs_uint32("ptr_file_info", ps, depth, &ctr->ptr_file_info)) - return False; - if(!prs_uint32("num_entries", ps, depth, &ctr->num_entries)) - return False; - if(!prs_uint32("ptr_entries", ps, depth, &ctr->ptr_entries)) - return False; - if (ctr->ptr_entries == 0) - return True; - if(!prs_uint32("num_entries2", ps, depth, - &ctr->num_entries2)) - return False; - - switch (ctr->switch_value) { - case 3: { - SRV_FILE_INFO_3 *info3 = ctr->file.info3; - int num_entries = ctr->num_entries; - int i; - - if (UNMARSHALLING(ps)) { - if (!(info3 = (SRV_FILE_INFO_3 *)prs_alloc_mem(ps, num_entries * sizeof(SRV_FILE_INFO_3)))) - return False; - ctr->file.info3 = info3; - } - - for (i = 0; i < num_entries; i++) { - if(!srv_io_file_info3("", &ctr->file.info3[i].info_3, ps, depth)) - return False; - } - for (i = 0; i < num_entries; i++) { - if(!srv_io_file_info3_str("", &ctr->file.info3[i].info_3_str, ps, depth)) - return False; - } - break; - } - default: - DEBUG(5,("%s no file info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_FILE_ENUM structure. -********************************************************************/ - -void init_srv_q_net_file_enum(SRV_Q_NET_FILE_ENUM *q_n, - const char *srv_name, const char *qual_name, - const char *user_name, - uint32 file_level, SRV_FILE_INFO_CTR *ctr, - uint32 preferred_len, - ENUM_HND *hnd) -{ - DEBUG(5,("init_q_net_file_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name); - init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name); - - q_n->file_level = q_n->ctr.switch_value = file_level; - q_n->preferred_len = preferred_len; - q_n->ctr.ptr_file_info = 1; - q_n->ctr.num_entries = 0; - q_n->ctr.num_entries2 = 0; - - memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd)); -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_enum(const char *desc, SRV_Q_NET_FILE_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - if(!prs_uint32("file_level", ps, depth, &q_n->file_level)) - return False; - - if (q_n->file_level != -1) { - if(!srv_io_srv_file_ctr("file_ctr", &q_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_enum(const char *desc, SRV_R_NET_FILE_ENUM *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("file_level", ps, depth, &r_n->file_level)) - return False; - - if (r_n->file_level != 0) { - if(!srv_io_srv_file_ctr("file_ctr", &r_n->ctr, ps, depth)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Initialize a net file close request -********************************************************************/ -void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server, - uint32 file_id) -{ - q_n->ptr_srv_name = 1; - init_unistr2(&q_n->uni_srv_name, server, strlen(server) + 1); - q_n->file_id = file_id; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ -BOOL srv_io_q_net_file_close(const char *desc, SRV_Q_NET_FILE_CLOSE *q_n, - prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("file_id", ps, depth, &q_n->file_id)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_close(const char *desc, SRV_R_NET_FILE_CLOSE *q_n, - prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_close"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &q_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_INFO_100 structure. - ********************************************************************/ - -void init_srv_info_100(SRV_INFO_100 *sv100, uint32 platform_id, const char *name) -{ - DEBUG(5,("init_srv_info_100\n")); - - sv100->platform_id = platform_id; - init_buf_unistr2(&sv100->uni_name, &sv100->ptr_name, name); -} - -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static BOOL srv_io_info_100(const char *desc, SRV_INFO_100 *sv100, prs_struct *ps, int depth) -{ - if (sv100 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_100"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv100->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv100->ptr_name)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv100->uni_name, True, ps, depth)) - return False; - - return True; -} - - -/******************************************************************* - Inits a SRV_INFO_101 structure. - ********************************************************************/ - -void init_srv_info_101(SRV_INFO_101 *sv101, uint32 platform_id, const char *name, - uint32 ver_major, uint32 ver_minor, - uint32 srv_type, const char *comment) -{ - DEBUG(5,("init_srv_info_101\n")); - - sv101->platform_id = platform_id; - init_buf_unistr2(&sv101->uni_name, &sv101->ptr_name, name); - sv101->ver_major = ver_major; - sv101->ver_minor = ver_minor; - sv101->srv_type = srv_type; - init_buf_unistr2(&sv101->uni_comment, &sv101->ptr_comment, comment); -} - -/******************************************************************* - Reads or writes a SRV_INFO_101 structure. - ********************************************************************/ - -static BOOL srv_io_info_101(const char *desc, SRV_INFO_101 *sv101, prs_struct *ps, int depth) -{ - if (sv101 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_101"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv101->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv101->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv101->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv101->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv101->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv101->ptr_comment)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv101->uni_name, True, ps, depth)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv101->uni_comment, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_INFO_102 structure. - ********************************************************************/ - -void init_srv_info_102(SRV_INFO_102 *sv102, uint32 platform_id, const char *name, - const char *comment, uint32 ver_major, uint32 ver_minor, - uint32 srv_type, uint32 users, uint32 disc, uint32 hidden, - uint32 announce, uint32 ann_delta, uint32 licenses, - const char *usr_path) -{ - DEBUG(5,("init_srv_info_102\n")); - - sv102->platform_id = platform_id; - init_buf_unistr2(&sv102->uni_name, &sv102->ptr_name, name); - sv102->ver_major = ver_major; - sv102->ver_minor = ver_minor; - sv102->srv_type = srv_type; - init_buf_unistr2(&sv102->uni_comment, &sv102->ptr_comment, comment); - - /* same as 101 up to here */ - - sv102->users = users; - sv102->disc = disc; - sv102->hidden = hidden; - sv102->announce = announce; - sv102->ann_delta = ann_delta; - sv102->licenses = licenses; - init_buf_unistr2(&sv102->uni_usr_path, &sv102->ptr_usr_path, usr_path); -} - - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - -static BOOL srv_io_info_102(const char *desc, SRV_INFO_102 *sv102, prs_struct *ps, int depth) -{ - if (sv102 == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info102"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &sv102->platform_id)) - return False; - if(!prs_uint32("ptr_name ", ps, depth, &sv102->ptr_name)) - return False; - if(!prs_uint32("ver_major ", ps, depth, &sv102->ver_major)) - return False; - if(!prs_uint32("ver_minor ", ps, depth, &sv102->ver_minor)) - return False; - if(!prs_uint32("srv_type ", ps, depth, &sv102->srv_type)) - return False; - if(!prs_uint32("ptr_comment ", ps, depth, &sv102->ptr_comment)) - return False; - - /* same as 101 up to here */ - - if(!prs_uint32("users ", ps, depth, &sv102->users)) - return False; - if(!prs_uint32("disc ", ps, depth, &sv102->disc)) - return False; - if(!prs_uint32("hidden ", ps, depth, &sv102->hidden)) - return False; - if(!prs_uint32("announce ", ps, depth, &sv102->announce)) - return False; - if(!prs_uint32("ann_delta ", ps, depth, &sv102->ann_delta)) - return False; - if(!prs_uint32("licenses ", ps, depth, &sv102->licenses)) - return False; - if(!prs_uint32("ptr_usr_path", ps, depth, &sv102->ptr_usr_path)) - return False; - - if(!smb_io_unistr2("uni_name ", &sv102->uni_name, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_comment ", &sv102->uni_comment, True, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - if(!smb_io_unistr2("uni_usr_path", &sv102->uni_usr_path, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a SRV_INFO_102 structure. - ********************************************************************/ - -static BOOL srv_io_info_ctr(const char *desc, SRV_INFO_CTR *ctr, prs_struct *ps, int depth) -{ - if (ctr == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_info_ctr"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value)) - return False; - if(!prs_uint32("ptr_srv_ctr ", ps, depth, &ctr->ptr_srv_ctr)) - return False; - - if (ctr->ptr_srv_ctr != 0 && ctr->switch_value != 0 && ctr != NULL) { - switch (ctr->switch_value) { - case 100: - if(!srv_io_info_100("sv100", &ctr->srv.sv100, ps, depth)) - return False; - break; - case 101: - if(!srv_io_info_101("sv101", &ctr->srv.sv101, ps, depth)) - return False; - break; - case 102: - if(!srv_io_info_102("sv102", &ctr->srv.sv102, ps, depth)) - return False; - break; - default: - DEBUG(5,("%s no server info at switch_value %d\n", - tab_depth(depth), ctr->switch_value)); - break; - } - if(!prs_align(ps)) - return False; - } - - return True; -} - -/******************************************************************* - Inits a SRV_Q_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_q_net_srv_get_info(SRV_Q_NET_SRV_GET_INFO *srv, - const char *server_name, uint32 switch_value) -{ - DEBUG(5,("init_srv_q_net_srv_get_info\n")); - - init_buf_unistr2(&srv->uni_srv_name, &srv->ptr_srv_name, server_name); - - srv->switch_value = switch_value; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_srv_get_info(const char *desc, SRV_Q_NET_SRV_GET_INFO *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - return True; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_GET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_get_info(SRV_R_NET_SRV_GET_INFO *srv, - uint32 switch_value, SRV_INFO_CTR *ctr, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_get_info\n")); - - srv->ctr = ctr; - - if (W_ERROR_IS_OK(status)) { - srv->ctr->switch_value = switch_value; - srv->ctr->ptr_srv_ctr = 1; - } else { - srv->ctr->switch_value = 0; - srv->ctr->ptr_srv_ctr = 0; - } - - srv->status = status; -} - -/******************************************************************* - Inits a SRV_R_NET_SRV_SET_INFO structure. - ********************************************************************/ - -void init_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv, - uint32 switch_value, WERROR status) -{ - DEBUG(5,("init_srv_r_net_srv_set_info\n")); - - srv->switch_value = switch_value; - srv->status = status; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_srv_set_info(const char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_q_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch_value ", ps, depth, &q_n->switch_value)) - return False; - - if (UNMARSHALLING(ps)) { - q_n->ctr = (SRV_INFO_CTR *) - prs_alloc_mem(ps, sizeof(SRV_INFO_CTR)); - - if (!q_n->ctr) - return False; - } - - if(!srv_io_info_ctr("ctr", q_n->ctr, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_srv_get_info(const char *desc, SRV_R_NET_SRV_GET_INFO *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_srv_get_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!srv_io_info_ctr("ctr", r_n->ctr, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_srv_set_info(const char *desc, SRV_R_NET_SRV_SET_INFO *r_n, - prs_struct *ps, int depth) -{ - prs_debug(ps, depth, desc, "srv_io_r_net_srv_set_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("switch value ", ps, depth, &r_n->switch_value)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_remote_tod(const char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -static BOOL srv_io_time_of_day_info(const char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth) -{ - if (tod == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_time_of_day_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("elapsedt ", ps, depth, &tod->elapsedt)) - return False; - if(!prs_uint32("msecs ", ps, depth, &tod->msecs)) - return False; - if(!prs_uint32("hours ", ps, depth, &tod->hours)) - return False; - if(!prs_uint32("mins ", ps, depth, &tod->mins)) - return False; - if(!prs_uint32("secs ", ps, depth, &tod->secs)) - return False; - if(!prs_uint32("hunds ", ps, depth, &tod->hunds)) - return False; - if(!prs_uint32("timezone ", ps, depth, &tod->zone)) - return False; - if(!prs_uint32("tintervals ", ps, depth, &tod->tintervals)) - return False; - if(!prs_uint32("day ", ps, depth, &tod->day)) - return False; - if(!prs_uint32("month ", ps, depth, &tod->month)) - return False; - if(!prs_uint32("year ", ps, depth, &tod->year)) - return False; - if(!prs_uint32("weekday ", ps, depth, &tod->weekday)) - return False; - - return True; -} - -/******************************************************************* - Inits a TIME_OF_DAY_INFO structure. - ********************************************************************/ - -void init_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs, - uint32 hours, uint32 mins, uint32 secs, uint32 hunds, - uint32 zone, uint32 tintervals, uint32 day, - uint32 month, uint32 year, uint32 weekday) -{ - DEBUG(5,("init_time_of_day_info\n")); - - tod->elapsedt = elapsedt; - tod->msecs = msecs; - tod->hours = hours; - tod->mins = mins; - tod->secs = secs; - tod->hunds = hunds; - tod->zone = zone; - tod->tintervals = tintervals; - tod->day = day; - tod->month = month; - tod->year = year; - tod->weekday = weekday; -} - - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_remote_tod(const char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_tod ", ps, depth, &r_n->ptr_srv_tod)) - return False; - - if(!srv_io_time_of_day_info("tod", r_n->tod, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. - ********************************************************************/ - -BOOL init_srv_q_net_disk_enum(SRV_Q_NET_DISK_ENUM *q_n, - const char *srv_name, - uint32 preferred_len, - ENUM_HND *enum_hnd - ) -{ - - - DEBUG(5,("init_srv_q_net_srv_disk_enum\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - - q_n->disk_enum_ctr.level = 0; - q_n->disk_enum_ctr.disk_info_ptr = 0; - - q_n->preferred_len = preferred_len; - memcpy(&q_n->enum_hnd, enum_hnd, sizeof(*enum_hnd)); - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_disk_enum(const char *desc, SRV_Q_NET_DISK_ENUM *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_disk_enum"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("level", ps, depth, &q_n->disk_enum_ctr.level)) - return False; - - if(!prs_uint32("entries_read", ps, depth, &q_n->disk_enum_ctr.entries_read)) - return False; - - if(!prs_uint32("buffer", ps, depth, &q_n->disk_enum_ctr.disk_info_ptr)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len)) - return False; - if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_disk_enum(const char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth) -{ - - int i; - uint32 entries_read, entries_read2, entries_read3; - - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum"); - depth++; - - entries_read = entries_read2 = entries_read3 = r_n->disk_enum_ctr.entries_read; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("entries_read", ps, depth, &entries_read)) - return False; - if(!prs_uint32("ptr_disk_info", ps, depth, &r_n->disk_enum_ctr.disk_info_ptr)) - return False; - - /*this may be max, unknown, actual?*/ - - if(!prs_uint32("max_elements", ps, depth, &entries_read2)) - return False; - if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown)) - return False; - if(!prs_uint32("actual_elements", ps, depth, &entries_read3)) - return False; - - r_n->disk_enum_ctr.entries_read = entries_read3; - - if(UNMARSHALLING(ps)) { - - DISK_INFO *dinfo; - - if(!(dinfo = (DISK_INFO *)prs_alloc_mem(ps, sizeof(*dinfo) * entries_read3))) - return False; - r_n->disk_enum_ctr.disk_info = dinfo; - } - - for(i=0; i < r_n->disk_enum_ctr.entries_read; i++) { - - if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.disk_info[i].unknown)) - return False; - - if(!smb_io_unistr3("disk_name", &r_n->disk_enum_ctr.disk_info[i].disk_name, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - } - - if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries)) - return False; - - if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - initialises a structure. - ********************************************************************/ - -BOOL init_srv_q_net_name_validate(SRV_Q_NET_NAME_VALIDATE *q_n, const char *srv_name, const char *share_name, int type) -{ - uint32 ptr_share_name; - - DEBUG(5,("init_srv_q_net_name_validate\n")); - - init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); - init_buf_unistr2(&q_n->uni_name, &ptr_share_name, share_name); - - q_n->type = type; - q_n->flags = 0; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_q_net_name_validate(const char *desc, SRV_Q_NET_NAME_VALIDATE *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_name_validate"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("type", ps, depth, &q_n->type)) - return False; - - if(!prs_uint32("flags", ps, depth, &q_n->flags)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. - ********************************************************************/ - -BOOL srv_io_r_net_name_validate(const char *desc, SRV_R_NET_NAME_VALIDATE *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_name_validate"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_query_secdesc(const char *desc, SRV_Q_NET_FILE_QUERY_SECDESC *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_query_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth)) - return False; - - if(!prs_uint32("unknown1", ps, depth, &q_n->unknown1)) - return False; - - if(!prs_uint32("unknown2", ps, depth, &q_n->unknown2)) - return False; - - if(!prs_uint32("unknown3", ps, depth, &q_n->unknown3)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_query_secdesc(const char *desc, SRV_R_NET_FILE_QUERY_SECDESC *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_query_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_response", ps, depth, &r_n->ptr_response)) - return False; - - if(!prs_uint32("size_response", ps, depth, &r_n->size_response)) - return False; - - if(!prs_uint32("ptr_secdesc", ps, depth, &r_n->ptr_secdesc)) - return False; - - if(!prs_uint32("size_secdesc", ps, depth, &r_n->size_secdesc)) - return False; - - if(!sec_io_desc("sec_desc", &r_n->sec_desc, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_q_net_file_set_secdesc(const char *desc, SRV_Q_NET_FILE_SET_SECDESC *q_n, prs_struct *ps, int depth) -{ - if (q_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_q_net_file_set_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_qual_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &q_n->uni_file_name, True, ps, depth)) - return False; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("sec_info", ps, depth, &q_n->sec_info)) - return False; - - if(!prs_uint32("size_set", ps, depth, &q_n->size_set)) - return False; - - if(!prs_uint32("ptr_secdesc", ps, depth, &q_n->ptr_secdesc)) - return False; - - if(!prs_uint32("size_secdesc", ps, depth, &q_n->size_secdesc)) - return False; - - if(!sec_io_desc("sec_desc", &q_n->sec_desc, ps, depth)) - return False; - - return True; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC *r_n, prs_struct *ps, int depth) -{ - if (r_n == NULL) - return False; - - prs_debug(ps, depth, desc, "srv_io_r_net_file_set_secdesc"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_werror("status", ps, depth, &r_n->status)) - return False; - - return True; -} - -/******************************************************************* - Inits a structure -********************************************************************/ - -void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server) -{ - q_u->ptr_srv_name = 1; - init_unistr2(&q_u->uni_srv_name, server, strlen(server) + 1); -} - diff --git a/source4/rpc_parse/parse_wks.c b/source4/rpc_parse/parse_wks.c deleted file mode 100644 index b6de058652..0000000000 --- a/source4/rpc_parse/parse_wks.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * 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. - * - * 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 - -/******************************************************************* - Init - ********************************************************************/ - -void init_wks_q_query_info(WKS_Q_QUERY_INFO *q_u, - char *server, uint16 switch_value) -{ - DEBUG(5,("init_wks_q_query_info\n")); - - init_buf_unistr2(&q_u->uni_srv_name, &q_u->ptr_srv_name, server); - q_u->switch_value = switch_value; -} - -/******************************************************************* - Reads or writes a WKS_Q_QUERY_INFO structure. -********************************************************************/ - -BOOL wks_io_q_query_info(const char *desc, WKS_Q_QUERY_INFO *q_u, prs_struct *ps, int depth) -{ - if (q_u == NULL) - return False; - - prs_debug(ps, depth, desc, "wks_io_q_query_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_srv_name", ps, depth, &q_u->ptr_srv_name)) - return False; - if(!smb_io_unistr2("", &q_u->uni_srv_name, q_u->ptr_srv_name, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &q_u->switch_value)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - wks_info_100 - ********************************************************************/ - -void init_wks_info_100(WKS_INFO_100 *inf, - uint32 platform_id, uint32 ver_major, uint32 ver_minor, - char *my_name, char *domain_name) -{ - DEBUG(5,("Init WKS_INFO_100: %d\n", __LINE__)); - - inf->platform_id = platform_id; /* 0x0000 01f4 - unknown */ - inf->ver_major = ver_major; /* os major version */ - inf->ver_minor = ver_minor; /* os minor version */ - - init_buf_unistr2(&inf->uni_compname, &inf->ptr_compname, my_name ); - init_buf_unistr2(&inf->uni_lan_grp, &inf->ptr_lan_grp, domain_name); -} - -/******************************************************************* - Reads or writes a WKS_INFO_100 structure. -********************************************************************/ - -static BOOL wks_io_wks_info_100(const char *desc, WKS_INFO_100 *inf, prs_struct *ps, int depth) -{ - if (inf == NULL) - return False; - - prs_debug(ps, depth, desc, "wks_io_wks_info_100"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint32("platform_id ", ps, depth, &inf->platform_id)) /* 0x0000 01f4 - unknown */ - return False; - if(!prs_uint32("ptr_compname", ps, depth, &inf->ptr_compname)) /* pointer to computer name */ - return False; - if(!prs_uint32("ptr_lan_grp ", ps, depth, &inf->ptr_lan_grp)) /* pointer to LAN group name */ - return False; - if(!prs_uint32("ver_major ", ps, depth, &inf->ver_major)) /* 4 - major os version */ - return False; - if(!prs_uint32("ver_minor ", ps, depth, &inf->ver_minor)) /* 0 - minor os version */ - return False; - - if(!smb_io_unistr2("", &inf->uni_compname, inf->ptr_compname, ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - if(!smb_io_unistr2("", &inf->uni_lan_grp, inf->ptr_lan_grp , ps, depth)) - return False; - if(!prs_align(ps)) - return False; - - return True; -} - -/******************************************************************* - Inits WKS_R_QUERY_INFO. - - only supports info level 100 at the moment. - - ********************************************************************/ - -void init_wks_r_query_info(WKS_R_QUERY_INFO *r_u, - uint32 switch_value, WKS_INFO_100 *wks100, - NTSTATUS status) -{ - DEBUG(5,("init_wks_r_unknown_0: %d\n", __LINE__)); - - r_u->switch_value = switch_value; /* same as in request */ - - r_u->ptr_1 = 1; /* pointer 1 */ - r_u->wks100 = wks100; - - r_u->status = status; -} - -/******************************************************************* - Reads or writes a structure. -********************************************************************/ - -BOOL wks_io_r_query_info(const char *desc, WKS_R_QUERY_INFO *r_u, prs_struct *ps, int depth) -{ - if (r_u == NULL) - return False; - - prs_debug(ps, depth, desc, "wks_io_r_query_info"); - depth++; - - if(!prs_align(ps)) - return False; - - if(!prs_uint16("switch_value", ps, depth, &r_u->switch_value)) /* level 100 (0x64) */ - return False; - if(!prs_align(ps)) - return False; - - if(!prs_uint32("ptr_1 ", ps, depth, &r_u->ptr_1)) /* pointer 1 */ - return False; - if(!wks_io_wks_info_100("inf", r_u->wks100, ps, depth)) - return False; - - if(!prs_ntstatus("status ", ps, depth, &r_u->status)) - return False; - - return True; -} |