diff options
author | Gerald Carter <jerry@samba.org> | 2000-07-07 06:20:46 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2000-07-07 06:20:46 +0000 |
commit | d2b40a7de259377d937492acedd39988ddd108a4 (patch) | |
tree | f0849ba6679575e80500b43b8989b3dddf16e2a4 /source3/rpc_parse | |
parent | 9de93aa8188293671a92e84b2b9dc104cc7eb64c (diff) | |
download | samba-d2b40a7de259377d937492acedd39988ddd108a4.tar.gz samba-d2b40a7de259377d937492acedd39988ddd108a4.tar.bz2 samba-d2b40a7de259377d937492acedd39988ddd108a4.zip |
More rpcclient merge issues:
* fixes some readline bugs from the merge
* first attempt at commands (spoolenum almost works)
* no changes to existing functions in HEAD; only additions
of new functions. I'll weed out what I can as I go.
--jerry
(This used to be commit 61d2aad5dc2b212b11c981f1eca47efa627e9fc8)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r-- | source3/rpc_parse/parse_creds.c | 24 | ||||
-rw-r--r-- | source3/rpc_parse/parse_prs.c | 114 |
2 files changed, 137 insertions, 1 deletions
diff --git a/source3/rpc_parse/parse_creds.c b/source3/rpc_parse/parse_creds.c index 46fdc5b78f..672b9f28e0 100644 --- a/source3/rpc_parse/parse_creds.c +++ b/source3/rpc_parse/parse_creds.c @@ -425,6 +425,30 @@ void copy_unix_sec_creds(CREDS_UNIX_SEC *to, const CREDS_UNIX_SEC *from) } }; +void create_ntc_from_cli_state (CREDS_NT *to, const struct cli_state *cli_from) +{ + /* + * NULL credentials -- + * if this gets executed, it is a programming error. + * fall through to copy_nt_creds() + */ + if (cli_from == NULL) + { + copy_nt_creds (to, cli_from); + return; + } + + safe_strcpy(to->domain , cli_from->domain , sizeof(cli_from->domain )-1); + safe_strcpy(to->user_name, cli_from->user_name, sizeof(cli_from->user_name)-1); + memcpy(&to->pwd, &cli_from->pwd, sizeof(cli_from->pwd)); + to->ntlmssp_flags = cli_from->ntlmssp_flags; + DEBUG(10,("create_ntc_fromcli_state: user %s domain %s flgs: %x\n", + to->user_name, to->domain, + to->ntlmssp_flags)); + +}; + + void copy_nt_creds(struct ntuser_creds *to, const struct ntuser_creds *from) { diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c index 94a6100aa1..3b17f51c95 100644 --- a/source3/rpc_parse/parse_prs.c +++ b/source3/rpc_parse/parse_prs.c @@ -27,6 +27,35 @@ extern int DEBUGLEVEL; /******************************************************************* + search for a memory buffer that falls within the specified offset + ********************************************************************/ +static const prs_struct *prs_find(const prs_struct *buf, uint32 offset) +{ + const prs_struct *f = NULL; + +#if 0 /* comment out by JERRY */ + if (buf == NULL) + return False; + + f = buf; + + while (f != NULL && offset >= f->end) + { + DEBUG(200, ("prs_find: next[%d..%d]\n", f->start, f->end)); + + f = f->next; + } + + if (f != NULL) + { + DEBUG(200, ("prs_find: found [%d..%d]\n", f->start, f->end)); + } + +#endif + return f; +} + +/******************************************************************* dump a prs to a file ********************************************************************/ void prs_dump(char *name, int v, prs_struct *ps) @@ -63,10 +92,10 @@ void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name) DEBUG(5+depth, ("%s%06x %s %s\n", tab_depth(depth), ps->data_offset, fn_name, desc)); } + /******************************************************************* Initialise a parse structure - malloc the data if requested. ********************************************************************/ - BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, BOOL io) { ZERO_STRUCTP(ps); @@ -805,6 +834,89 @@ BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32, return True; } +/******************************************************************* + frees a memory buffer. + ********************************************************************/ +void prs_free_data(prs_struct *buf) +{ + if (buf == NULL) + return; + + if (buf->data_p != NULL) + { + free(buf->data_p); + buf->data_p = NULL; + } + buf->buffer_size = 0; +} + +/******************************************************************* + reallocate a memory buffer +********************************************************************/ +BOOL prs_realloc_data(prs_struct *buf, size_t new_size) +{ + char *new_data; + + /* prs_sma_init(); JERRY */ + + prs_debug(buf, 200, "prs_realloc_data - before", "prs_realloc_data"); + + SMB_ASSERT(((ssize_t) new_size) >= 0); + + if (new_size == 0) + { + prs_free_data(buf); + return True; + } + + /* new_data = sma_realloc(prs_sma_region, buf->data_p, new_size); */ + new_data = realloc(buf->data_p, new_size); + + if (new_data != NULL) + { + if (new_size > buf->buffer_size) + { + memset(&new_data[buf->buffer_size], 0, + new_size - buf->buffer_size); + } + buf->data_p = new_data; + buf->buffer_size = new_size; + } + else if (buf->buffer_size >= new_size) + { + DEBUG(3, ("prs_realloc_data: warning - " + "could not realloc to %d\n", new_size)); + } + else + { + DEBUG(3, ("prs_realloc_data: error - " + "could not realloc to %d\n", new_size)); + + prs_free_data(buf); + return False; + } + + prs_debug(buf, 200, "prs_realloc_data - after", "prs_realloc_data"); + return True; +} + +/******************************************************************* + return the memory location specified by may return NULL. + ********************************************************************/ +char *prs_data(const prs_struct *buf, uint32 offset) +{ + buf = prs_find(buf, offset); + if (buf != NULL) + { + /* return &(buf->data[offset - buf->start]); */ + return &(buf->data_p[offset]); + } + return NULL; +} + + + + /* useful function to store a structure in rpc wire format */ int tdb_prs_store(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps) { |