From c525a82cc2625dc586f500effa16623410899b46 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Tue, 7 Mar 2000 18:18:44 +0000 Subject: From Elrond@Wunder-Nett.org Wed Mar 8 05:16:00 2000 Date: Tue, 7 Mar 2000 18:03:39 +0100 From: Elrond To: Luke Kenneth Casson Leighton Subject: cleanup: sam_enum_domains (passdb) and share info 502 Hi Luke, - munged around with share_info_502, cause I want to integrate ShareGetInfo and ShareEnum more, so both support the same info-levels and there isn't so much doubled code. (note: I want that, it's not currently anywhere near there.) - moved enumdomains from lib/sids.c to samrd/srv_samr_passdb.c, it's only used there. --- source/include/rpc_srvsvc.h | 9 +++--- source/lib/sids.c | 12 ------- source/rpc_parse/parse_srv.c | 72 ++++++++++++++++++++++++++++++++---------- source/samrd/srv_samr_passdb.c | 12 +++++++ 4 files changed, 73 insertions(+), 32 deletions(-) diff --git a/source/include/rpc_srvsvc.h b/source/include/rpc_srvsvc.h index f6ad15386a1..625405ef477 100644 --- a/source/include/rpc_srvsvc.h +++ b/source/include/rpc_srvsvc.h @@ -2,9 +2,10 @@ Unix SMB/Netbios implementation. Version 1.9. SMB parameters and setup - Copyright (C) Andrew Tridgell 1992-1997 - Copyright (C) Luke Kenneth Casson Leighton 1996-1997 - Copyright (C) Paul Ashton 1997 + Copyright (C) Andrew Tridgell 1992-1997,2000 + Copyright (C) Luke Kenneth Casson Leighton 1996-1997,2000 + Copyright (C) Paul Ashton 1997,2000 + Copyright (C) Elrond 2000 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 @@ -416,7 +417,7 @@ typedef struct _share_info_502 typedef union _share_info_ctr { - SHARE_INFO_502 info502; + SHARE_INFO_502 *info502; } SHARE_INFO_CTR; diff --git a/source/lib/sids.c b/source/lib/sids.c index 3e66c09e213..1bc0d68016b 100644 --- a/source/lib/sids.c +++ b/source/lib/sids.c @@ -569,15 +569,3 @@ BOOL enumtrustdoms(char ***doms, uint32 *num_entries) return True; } - -/************************************************************************** - enumerates all domains for which the SAM server is responsible -***************************************************************************/ -BOOL enumdomains(char ***doms, uint32 *num_entries) -{ - add_chars_to_array(num_entries, doms, global_sam_name); - add_chars_to_array(num_entries, doms, "Builtin"); - - return True; -} - diff --git a/source/rpc_parse/parse_srv.c b/source/rpc_parse/parse_srv.c index 3b22054f129..c3a3ba26b8a 100644 --- a/source/rpc_parse/parse_srv.c +++ b/source/rpc_parse/parse_srv.c @@ -361,7 +361,7 @@ static BOOL srv_io_share_info502_data(char *desc, reads or writes a structure. ********************************************************************/ static BOOL srv_io_share_info502(char *desc, - SHARE_INFO_502 *sh502, + SHARE_INFO_502 *sh502, uint32 count, prs_struct *ps, int depth) { if (sh502 == NULL) return False; @@ -381,6 +381,53 @@ static BOOL srv_io_share_info502(char *desc, } +/******************************************************************* + reads or writes a structure. + ********************************************************************/ +static BOOL srv_io_share_info_ctr(const char *desc, + SHARE_INFO_CTR *info, + uint32 info_level, uint32 count, + prs_struct *ps, int depth) +{ + if (info == NULL) return False; + + if (count != 1) + { + DEBUG(1, ("srv_io_share_info_ctr: count %d != 1\n", + count)); + return False; + } + + prs_debug(ps, depth, desc, "srv_io_share_info_ctr"); + depth++; + + prs_align(ps); + + switch (info_level) + { + case 502: + if (ps->io) + { + info->info502 = g_new(SHARE_INFO_502, count); + if (info->info502 == NULL) + { + DEBUG(1, ("srv_io_share_info_ctr at level 502: malloc failed\n")); + return False; + } + } + return srv_io_share_info502("info", + info->info502, count, + ps, depth); + break; + default: + DEBUG(1, ("srv_io_share_info_ctr: Unsupported info level %d\n", + info_level)); + return False; + break; + } +} + + /******************************************************************* reads or writes a structure. ********************************************************************/ @@ -522,6 +569,7 @@ static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struc return True; } + /******************************************************************* reads or writes a structure. ********************************************************************/ @@ -692,18 +740,12 @@ BOOL srv_io_r_net_share_get_info(char *desc, SRV_R_NET_SHARE_GET_INFO *r_n, if (r_n->info_ptr) { - switch (r_n->info_level) + if (!srv_io_share_info_ctr("info_ctr", + &(r_n->info), + r_n->info_level, 1, + ps, depth)) { - case 502: - srv_io_share_info502("info", - &(r_n->info.info502), - ps, depth); - break; - default: - DEBUG(1, ("srv_io_r_net_share_get_info: Unsupported info level %d\n", - r_n->info_level)); - return False; - break; + return False; } } @@ -1519,11 +1561,9 @@ static BOOL srv_io_srv_tprt_info_0(char *desc, SRV_TPRT_INFO_0 *tp0, prs_struct if (ps->io) { /* reading */ - tp0->info_0 = (TPRT_INFO_0*)malloc(num_entries * - sizeof(tp0->info_0[0])); + tp0->info_0 = g_new(TPRT_INFO_0, num_entries); - tp0->info_0_str = (TPRT_INFO_0_STR*)malloc(num_entries * - sizeof(tp0->info_0_str[0])); + tp0->info_0_str = g_new(TPRT_INFO_0_STR, num_entries); if (tp0->info_0 == NULL || tp0->info_0_str == NULL) { diff --git a/source/samrd/srv_samr_passdb.c b/source/samrd/srv_samr_passdb.c index 9a6c1d7dfa6..ebac22c4463 100644 --- a/source/samrd/srv_samr_passdb.c +++ b/source/samrd/srv_samr_passdb.c @@ -583,6 +583,18 @@ static void make_enum_domains(SAM_ENTRY **sam, UNISTR2 **uni_dom_name, } } + +/************************************************************************** + enumerates all domains for which the SAM server is responsible +***************************************************************************/ +static BOOL enumdomains(char ***doms, uint32 *num_entries) +{ + add_chars_to_array(num_entries, doms, global_sam_name); + add_chars_to_array(num_entries, doms, "Builtin"); + + return True; +} + /******************************************************************* samr_reply_enum_domains ********************************************************************/ -- cgit v1.2.1