diff options
author | Jeremy Allison <jra@samba.org> | 2001-05-01 01:01:19 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-05-01 01:01:19 +0000 |
commit | 8bd2a11c86ddc3bbb2bec32415e027d87df639af (patch) | |
tree | 35df56ea8db8e928720ffcc1e9f1da077600d234 /source3/rpc_parse | |
parent | 0901dd473ae163b815b364fc7ac954778b77d3b5 (diff) | |
download | samba-8bd2a11c86ddc3bbb2bec32415e027d87df639af.tar.gz samba-8bd2a11c86ddc3bbb2bec32415e027d87df639af.tar.bz2 samba-8bd2a11c86ddc3bbb2bec32415e027d87df639af.zip |
Added code from "Nigel Williams" <nigel@veritas.com> (yes, the same famous
Nigel Williams who did NIS/GINA !) to implement add/modify/delete shares
for Win2k. Needs testing as I made a few mods to the original code.
Jeremy.
(This used to be commit 9b3dd801765fad28c0f9d58e5af2537cfccdd4ee)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r-- | source3/rpc_parse/parse_misc.c | 31 | ||||
-rw-r--r-- | source3/rpc_parse/parse_srv.c | 224 |
2 files changed, 236 insertions, 19 deletions
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 81602a1dc4..4b118dd2b4 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -1457,6 +1457,37 @@ BOOL smb_io_pol_hnd(char *desc, POLICY_HND *pol, prs_struct *ps, int depth) } /******************************************************************* + 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"); + + /* store the string (null-terminated copy) */ + dos_struni2((char *)str->str.buffer, buf, len); +} + +/******************************************************************* Reads or writes a UNISTR3 structure. ********************************************************************/ diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 61d2ff7ba2..4abd93b159 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -280,18 +280,27 @@ static BOOL srv_io_share_info502(char *desc, SH_INFO_502 *sh502, prs_struct *ps, Inits a SH_INFO_502_STR structure ********************************************************************/ -void init_srv_share_info502_str(SH_INFO_502_STR *sh502, +void init_srv_share_info502_str(SH_INFO_502_STR *sh502str, + SH_INFO_502 *ptrs, char *net_name, char *remark, char *path, char *passwd, SEC_DESC *psd, size_t sd_size) { DEBUG(5,("init_srv_share_info502_str\n")); - init_unistr2(&sh502->uni_netname, net_name, strlen(net_name)+1); - init_unistr2(&sh502->uni_remark, remark, strlen(remark)+1); - init_unistr2(&sh502->uni_path, path, strlen(path)+1); - init_unistr2(&sh502->uni_passwd, passwd, strlen(passwd)+1); - sh502->sd = psd; - sh502->sd_size = sd_size; + sh502str->ptrs = ptrs; + + if(sh502str->ptrs->ptr_netname) + init_unistr2(&sh502str->uni_netname, net_name, strlen(net_name)+1); + if(sh502str->ptrs->ptr_remark) + init_unistr2(&sh502str->uni_remark, remark, strlen(remark)+1); + if(sh502str->ptrs->ptr_path) + init_unistr2(&sh502str->uni_path, path, strlen(path)+1); + if(sh502str->ptrs->ptr_passwd) + init_unistr2(&sh502str->uni_passwd, passwd, strlen(passwd)+1); + if(sh502str->ptrs->ptr_sd) { + sh502str->sd = psd; + sh502str->sd_size = sd_size; + } } /******************************************************************* @@ -308,31 +317,45 @@ static BOOL srv_io_share_info502_str(char *desc, SH_INFO_502_STR *sh502, prs_str if(!prs_align(ps)) return False; - if(!smb_io_unistr2("", &sh502->uni_netname, True, ps, depth)) - 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(!smb_io_unistr2("", &sh502->uni_remark, True, ps, depth)) - 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(!smb_io_unistr2("", &sh502->uni_path, True, ps, depth)) - 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(!smb_io_unistr2("", &sh502->uni_passwd, True, ps, depth)) - 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(!prs_uint32("sd_size ", ps, depth, &sh502->sd_size)) - return False; - if (!sec_io_desc(desc, &sh502->sd, ps, depth)) - return False; + if(sh502->ptrs->ptr_sd) { + if(!prs_uint32("sd_size ", ps, depth, &sh502->sd_size)) + return False; + if (!sec_io_desc(desc, &sh502->sd, ps, depth)) + return False; + } return True; } @@ -501,6 +524,7 @@ static BOOL srv_io_srv_share_ctr(char *desc, SRV_SHARE_INFO_CTR *ctr, prs_struct } 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; } @@ -675,6 +699,9 @@ static BOOL srv_io_srv_share_info(char *desc, prs_struct *ps, int depth, SRV_SHA 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; @@ -2374,3 +2401,162 @@ BOOL srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct * return True; } + +/******************************************************************* + Reads or writes a structure. + ********************************************************************/ + +BOOL srv_io_q_net_disk_enum(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(char *desc, SRV_R_NET_DISK_ENUM *r_n, prs_struct *ps, int depth) +{ + int i; + + if (r_n == NULL) + return False; + + prs_debug(ps, depth, desc, "srv_io_r_net_disk_enum"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("entries_read", ps, depth, &r_n->disk_enum_ctr.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, &r_n->disk_enum_ctr.entries_read)) + return False; + if(!prs_uint32("unknown", ps, depth, &r_n->disk_enum_ctr.unknown)) + return False; + if(!prs_uint32("actual_elements", ps, depth, &r_n->disk_enum_ctr.entries_read)) + return False; + + 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_uint32("status", ps, depth, &r_n->status)) + return False; + + return True; +} + +/******************************************************************* + Reads or writes a structure. + ********************************************************************/ + +BOOL srv_io_q_net_name_validate(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(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_uint32("status", ps, depth, &r_n->status)) + return False; + + return True; +} |