diff options
author | Luke Leighton <lkcl@samba.org> | 1997-10-05 14:17:53 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1997-10-05 14:17:53 +0000 |
commit | 84e362dd132e250ddb5ca0223e2b27dc484b3ff7 (patch) | |
tree | 0dac28d5679264271743bce843f4e4546ba32723 | |
parent | 5e4bc79c6ee33704633c2616c030c263d14fefe0 (diff) | |
download | samba-84e362dd132e250ddb5ca0223e2b27dc484b3ff7.tar.gz samba-84e362dd132e250ddb5ca0223e2b27dc484b3ff7.tar.bz2 samba-84e362dd132e250ddb5ca0223e2b27dc484b3ff7.zip |
updating lsa and smb parsing routines and structures.
(This used to be commit 2f722fe289051558dbe77aeb0a830bb3ded10a83)
-rw-r--r-- | source3/include/proto.h | 32 | ||||
-rw-r--r-- | source3/include/smb.h | 23 | ||||
-rw-r--r-- | source3/lsaparse.c | 15 | ||||
-rw-r--r-- | source3/smbparse.c | 93 |
4 files changed, 155 insertions, 8 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 4ec4a42f2a..705b08b633 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -310,6 +310,11 @@ void del_share_mode(share_lock_token token, int fnum); BOOL set_share_mode(share_lock_token token,int fnum, uint16 port, uint16 op_type); BOOL remove_share_oplock(int fnum, share_lock_token token); +/*The following definitions come from lsaparse.c */ + +char* lsa_io_q_query(BOOL io, LSA_Q_QUERY_INFO *q_q, char *q, char *base, int align); +char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int align); + /*The following definitions come from mangle.c */ int str_checksum(char *s); @@ -772,6 +777,33 @@ void SMBencrypt(uchar *passwd, uchar *c8, uchar *p24); void E_md4hash(uchar *passwd, uchar *p16); void SMBNTencrypt(uchar *passwd, uchar *c8, uchar *p24); +/*The following definitions come from smbparse.c */ + +char* smb_io_utime(BOOL io, UTIME *t, char *q, char *base, int align); +char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align); +char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align); +char* smb_io_unihdr(BOOL io, UNIHDR *hdr, char *q, char *base, int align); +char* smb_io_unihdr2(BOOL io, UNIHDR2 *hdr2, char *q, char *base, int align); +char* smb_io_unistr(BOOL io, UNISTR *uni, char *q, char *base, int align); +char* smb_io_unistr2(BOOL io, UNISTR2 *uni2, char *q, char *base, int align); +char* smb_io_dom_sid2(BOOL io, DOM_SID2 *sid2, char *q, char *base, int align); +char* smb_io_dom_rid2(BOOL io, DOM_RID2 *rid2, char *q, char *base, int align); +char* smb_io_log_info(BOOL io, DOM_LOG_INFO *log, char *q, char *base, int align); +char* smb_io_chal(BOOL io, DOM_CHAL *chal, char *q, char *base, int align); +char* smb_io_cred(BOOL io, DOM_CRED *cred, char *q, char *base, int align); +char* smb_io_clnt_info(BOOL io, DOM_CLNT_INFO *clnt, char *q, char *base, int align); +char* smb_io_logon_id(BOOL io, DOM_LOGON_ID *log, char *q, char *base, int align); +char* smb_io_rc4_owf(BOOL io, RC4_OWF *hash, char *q, char *base, int align); +char* smb_io_id_info1(BOOL io, DOM_ID_INFO_1 *id, char *q, char *base, int align); +char* smb_io_sam_info(BOOL io, DOM_SAM_INFO *sam, char *q, char *base, int align); +char* smb_io_gid(BOOL io, DOM_GID *gid, char *q, char *base, int align); +char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align); +char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align); +char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align); +char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align); +char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align); +char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align); + /*The following definitions come from smbpass.c */ int pw_file_lock(char *name, int type, int secs); diff --git a/source3/include/smb.h b/source3/include/smb.h index eb20a16cd3..a3a6d326e0 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -331,6 +331,16 @@ typedef struct domsid2_info } DOM_SID2; +/* DOM_SID3 - domain SID structure - SIDs stored in unicode */ +typedef struct domsid3_info +{ + UNISTR str; /* domain SID unicode string */ + uint32 undoc; /* value is 0 */ + uint32 type1; /* value is 1 */ + uint32 type2; /* value is 5 or 3 */ + +} DOM_SID3; + /* DOM_RID2 - domain RID structure */ typedef struct domrid2_info { @@ -446,10 +456,11 @@ typedef struct rpc_hdr_info uint16 context_id; /* 0 - presentation context identifier */ uint8 cancel_count; /* 0 - cancel count */ uint8 reserved; /* 0 - reserved */ + } RPC_HDR; -/* DOM_QUERY_5 - info class 5 LSA Query response */ -typedef struct dom_query_5_info +/* DOM_QUERY - info class 3 and 5 LSA Query response */ +typedef struct dom_query_info { uint16 uni_dom_max_len; /* domain name string length * 2 */ uint16 uni_dom_str_len; /* domain name string length * 2 */ @@ -458,10 +469,11 @@ typedef struct dom_query_5_info UNISTR uni_domain_name; /* domain name (unicode string) */ DOM_SID dom_sid; /* domain SID */ -} DOM_QUERY_5; +} DOM_QUERY; /* level 5 is same as level 3. we hope. */ -typedef DOM_QUERY_5 DOM_QUERY_3; +typedef DOM_QUERY DOM_QUERY_3; +typedef DOM_QUERY DOM_QUERY_5; /* LSA_POL_HND */ typedef struct lsa_policy_info @@ -507,8 +519,7 @@ typedef struct dom_ref_info UNIHDR2 hdr_ref_dom[MAX_REF_DOMAINS]; /* referenced domain unicode string headers */ UNISTR uni_dom_name; /* domain name unicode string */ - DOM_SID uni_dom_sid; /* domain SID */ - DOM_SID uni_ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */ + DOM_SID ref_dom[MAX_REF_DOMAINS]; /* referenced domain SIDs */ } DOM_R_REF; diff --git a/source3/lsaparse.c b/source3/lsaparse.c index 52c9335cd0..0e38c8a667 100644 --- a/source3/lsaparse.c +++ b/source3/lsaparse.c @@ -75,7 +75,20 @@ char* lsa_io_r_query(BOOL io, LSA_R_QUERY_INFO *r_q, char *q, char *base, int al /******************************************************************* reads or writes a structure. ********************************************************************/ - char* smb_io_(BOOL io, *, char *q, char *base, int align) + char* lsa_io_(BOOL io, *, char *q, char *base, int align) +{ + if (== NULL) return NULL; + + q = align_offset(q, base, align); + + RW_IVAL(io, q, , 0); q += 4; + + return q; +} +/******************************************************************* +reads or writes a structure. +********************************************************************/ + char* lsa_io_(BOOL io, *, char *q, char *base, int align) { if (== NULL) return NULL; diff --git a/source3/smbparse.c b/source3/smbparse.c index 869aab21c1..e109f09a6f 100644 --- a/source3/smbparse.c +++ b/source3/smbparse.c @@ -56,7 +56,7 @@ char* smb_io_time(BOOL io, NTTIME *nttime, char *q, char *base, int align) /******************************************************************* reads or writes a DOM_SID structure. ********************************************************************/ -char* smb_io_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align) +char* smb_io_dom_sid(BOOL io, DOM_SID *sid, char *q, char *base, int align) { int i; @@ -407,6 +407,97 @@ char* smb_io_rpc_hdr(BOOL io, RPC_HDR *rpc, char *q, char *base, int align) return q; } +/******************************************************************* +reads or writes an LSA_POL_HND structure. +********************************************************************/ +char* smb_io_pol_hnd(BOOL io, LSA_POL_HND *pol, char *q, char *base, int align) +{ + if (pol == NULL) return NULL; + + q = align_offset(q, base, align); + + RW_PCVAL(io, q, pol->data, 20); q += 20; + + return q; +} + +/******************************************************************* +reads or writes a dom query structure. +********************************************************************/ +char* smb_io_dom_query_3(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align) +{ + return smb_io_dom_query(io, d_q, q, base, align); +} + +/******************************************************************* +reads or writes a dom query structure. +********************************************************************/ +char* smb_io_dom_query_5(BOOL io, DOM_QUERY_3 *d_q, char *q, char *base, int align) +{ + return smb_io_dom_query(io, d_q, q, base, align); +} + +/******************************************************************* +reads or writes a dom query structure. +********************************************************************/ +char* smb_io_dom_query(BOOL io, DOM_QUERY *d_q, char *q, char *base, int align) +{ + if (d_q == NULL) return NULL; + + q = align_offset(q, base, align); + + + RW_SVAL(io, q, d_q->uni_dom_max_len, 0); q += 2; /* domain name string length * 2 */ + RW_SVAL(io, q, d_q->uni_dom_str_len, 0); q += 2; /* domain name string length * 2 */ + + RW_IVAL(io, q, d_q->buffer_dom_name, 0); q += 4; /* undocumented domain name string buffer pointer */ + RW_IVAL(io, q, d_q->buffer_dom_sid , 0); q += 4; /* undocumented domain SID string buffer pointer */ + + if (d_q->buffer_dom_name != 0) + { + q = smb_io_unistr(io, &(d_q->uni_domain_name), q, base, align); /* domain name (unicode string) */ + } + if (d_q->buffer_dom_sid != 0) + { + q = smb_io_dom_sid(io, &(d_q->dom_sid), q, base, align); /* domain SID */ + } + + return q; +} + +/******************************************************************* +reads or writes a DOM_R_REF structure. +********************************************************************/ +char* smb_io_dom_r_ref(BOOL io, DOM_R_REF *r_r, char *q, char *base, int align) +{ + int i; + + if (r_r == NULL) return NULL; + + q = align_offset(q, base, align); + + RW_IVAL(io, q, r_r->undoc_buffer, 0); q += 4; /* undocumented buffer pointer. */ + RW_IVAL(io, q, r_r->num_ref_doms_1, 0); q += 4; /* num referenced domains? */ + RW_IVAL(io, q, r_r->buffer_dom_name, 0); q += 4; /* undocumented domain name buffer pointer. */ + RW_IVAL(io, q, r_r->max_entries, 0); q += 4; /* 32 - max number of entries */ + RW_IVAL(io, q, r_r->num_ref_doms_2, 0); q += 4; /* 4 - num referenced domains? */ + + q = smb_io_unihdr2(io, &(r_r->hdr_dom_name), q, base, align); /* domain name unicode string header */ + + for (i = 0; i < r_r->num_ref_doms_1-1; i++) + { + q = smb_io_unihdr2(io, &(r_r->hdr_ref_dom[i]), q, base, align); + } + + q = smb_io_unistr(io, &(r_r->uni_dom_name), q, base, align); /* domain name unicode string */ + + for (i = 0; i < r_r->num_ref_doms_2; i++) + { + q = smb_io_dom_sid(io, &(r_r->ref_dom[i]), q, base, align); /* referenced domain SIDs */ + } + return q; +} + #if 0 /******************************************************************* reads or writes a structure. |