diff options
author | Jeremy Allison <jra@samba.org> | 2000-05-15 20:53:08 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-05-15 20:53:08 +0000 |
commit | ad9a3a16e000e25693508e0b2eac280f7593d095 (patch) | |
tree | 4b9f0fb76c131b34d28c62fb44b8c80cb150f7e2 | |
parent | 4fb2e2c72f25a1204bf764504c370d746d12a162 (diff) | |
download | samba-ad9a3a16e000e25693508e0b2eac280f7593d095.tar.gz samba-ad9a3a16e000e25693508e0b2eac280f7593d095.tar.bz2 samba-ad9a3a16e000e25693508e0b2eac280f7593d095.zip |
Added Shirish's reg changes to HEAD. Sync up with 2.2.0 backport.
Also added prs_xx error return checks to new code in rpc_parse/parse_reg.c
Jeremy.
(This used to be commit a148cb996297ed34342660f82ef0e66773d40500)
-rw-r--r-- | source3/include/proto.h | 13 | ||||
-rw-r--r-- | source3/include/rpc_reg.h | 48 | ||||
-rw-r--r-- | source3/rpc_parse/parse_reg.c | 157 | ||||
-rw-r--r-- | source3/rpc_server/srv_reg.c | 24 |
4 files changed, 125 insertions, 117 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 0cc0546b88..b19d3d8f5c 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2071,7 +2071,7 @@ BOOL net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int /*The following definitions come from rpc_parse/parse_prs.c */ -void prs_dump(char *name, int level, prs_struct *ps); +void prs_dump(char *name, int v, prs_struct *ps); void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name); BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, BOOL io); BOOL prs_read(prs_struct *ps, int fd, size_t len, int timeout); @@ -2154,13 +2154,10 @@ 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); BOOL reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, int depth); BOOL reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, int depth); -void init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type, - time_t unix_time, uint8 major, uint8 minor); +BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name); BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth); -void init_reg_r_info(REG_R_INFO *r_r, - uint32 level, char *os_type, - uint32 unknown_0, uint32 unknown_1, - uint32 status); +BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, + BUFFER2* buf, uint32 type, uint32 status); BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth); void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol, uint32 val_idx, uint32 max_val_len, @@ -2725,6 +2722,8 @@ BOOL api_netlog_rpc(pipes_struct *p, prs_struct *data); BOOL create_next_pdu(pipes_struct *p); BOOL api_pipe_bind_auth_resp(pipes_struct *p, prs_struct *rpc_in_p); BOOL setup_fault_pdu(pipes_struct *p); +BOOL check_bind_req(char* pipe_name, RPC_IFACE* abstract, + RPC_IFACE* transfer); BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p); BOOL api_pipe_auth_process(pipes_struct *p, prs_struct *rpc_in); BOOL api_pipe_request(pipes_struct *p); diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h index 7766052588..103a7492cd 100644 --- a/source3/include/rpc_reg.h +++ b/source3/include/rpc_reg.h @@ -396,43 +396,43 @@ typedef struct r_reg_enum_key_info /* REG_Q_INFO */ typedef struct q_reg_info_info { - POLICY_HND pol; /* policy handle */ + POLICY_HND pol; /* policy handle */ - UNIHDR hdr_type; /* unicode product type header */ - UNISTR2 uni_type; /* unicode product type - "ProductType" */ + UNIHDR hdr_type; /* unicode product type header */ + UNISTR2 uni_type; /* unicode product type - "ProductType" */ - uint32 ptr1; /* pointer */ - NTTIME time; /* current time? */ - uint8 major_version1; /* 0x4 - os major version? */ - uint8 minor_version1; /* 0x1 - os minor version? */ - uint8 pad1[10]; /* padding - zeros */ + uint32 ptr_reserved; + + uint32 ptr_buf; /* the next three fields follow if ptr_buf != 0 */ + uint32 ptr_bufsize; + uint32 bufsize; + uint32 buf_unk; - uint32 ptr2; /* pointer */ - uint8 major_version2; /* 0x4 - os major version? */ - uint8 minor_version2; /* 0x1 - os minor version? */ - uint8 pad2[2]; /* padding - zeros */ - - uint32 ptr3; /* pointer */ - uint32 unknown; /* 0x0000 0000 */ + uint32 unk1; + uint32 ptr_buflen; + uint32 buflen; + + uint32 ptr_buflen2; + uint32 buflen2; } REG_Q_INFO; /* REG_R_INFO */ typedef struct r_reg_info_info { - uint32 ptr1; /* buffer pointer */ - uint32 level; /* 0x1 - info level? */ + uint32 ptr_type; /* keyvalue pointer */ + uint32 type; /* keyvalue datatype */ - uint32 ptr_type; /* pointer to o/s type */ - BUFFER2 uni_type; /* unicode string o/s type - "LanmanNT" */ + uint32 ptr_uni_val; /* pointer to o/s type */ + BUFFER2 *uni_val; /* unicode string o/s type - "LanmanNT" */ - uint32 ptr2; /* pointer to unknown_0 */ - uint32 unknown_0; /* 0x12 */ + uint32 ptr_max_len; /* pointer to unknown_0 */ + uint32 buf_max_len; /* 0x12 */ - uint32 ptr3; /* pointer to unknown_1 */ - uint32 unknown_1; /* 0x12 */ + uint32 ptr_len; /* pointer to unknown_1 */ + uint32 buf_len; /* 0x12 */ - uint32 status; /* return status */ + uint32 status; /* return status */ } REG_R_INFO; diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c index cc970e4150..e757245f7c 100644 --- a/source3/rpc_parse/parse_reg.c +++ b/source3/rpc_parse/parse_reg.c @@ -868,29 +868,33 @@ BOOL reg_io_r_get_key_sec(char *desc, REG_R_GET_KEY_SEC *r_q, prs_struct *ps, i makes a structure. ********************************************************************/ -void init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char *product_type, - time_t unix_time, uint8 major, uint8 minor) +BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name) { - int len_type = strlen(product_type); + int len_type = val_name != NULL ? strlen(val_name) + 1 : 0; - memcpy(&q_i->pol, pol, sizeof(q_i->pol)); + if (q_i == NULL) + return False; - init_uni_hdr(&q_i->hdr_type, len_type); - init_unistr2(&q_i->uni_type, product_type, len_type); + q_i->pol = *pol; - q_i->ptr1 = 1; - unix_to_nt_time(&q_i->time, unix_time); - q_i->major_version1 = major; - q_i->minor_version1 = minor; - memset(q_i->pad1, 0, sizeof(q_i->pad1)); + init_uni_hdr(&(q_i->hdr_type), len_type); + init_unistr2(&(q_i->uni_type), val_name, len_type); - q_i->ptr2 = 1; - q_i->major_version2 = major; - q_i->minor_version2 = minor; - memset(q_i->pad2, 0, sizeof(q_i->pad2)); + q_i->ptr_reserved = 1; + q_i->ptr_buf = 1; - q_i->ptr3 = 1; - q_i->unknown = 0x00000000; + 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; } /******************************************************************* @@ -918,68 +922,66 @@ BOOL reg_io_q_info(char *desc, REG_Q_INFO *r_q, prs_struct *ps, int depth) if(!prs_align(ps)) return False; - if(!prs_uint32("ptr1", ps, depth, &r_q->ptr1)) + if(!prs_uint32("ptr_reserved", ps, depth, &(r_q->ptr_reserved))) return False; - if (r_q->ptr1 != 0) { - if(!smb_io_time("", &r_q->time, ps, depth)) - return False; - if(!prs_uint8 ("major_version1", ps, depth, &r_q->major_version1)) - return False; - if(!prs_uint8 ("minor_version1", ps, depth, &r_q->minor_version1)) - return False; - if(!prs_uint8s(False, "pad1", ps, depth, r_q->pad1, sizeof(r_q->pad1))) - return False; - } - - if(!prs_uint32("ptr2", ps, depth, &r_q->ptr2)) + if(!prs_uint32("ptr_buf", ps, depth, &(r_q->ptr_buf))) return False; - if (r_q->ptr2 != 0) { - if(!prs_uint8 ("major_version2", ps, depth, &r_q->major_version2)) + if(r_q->ptr_buf) { + if(!prs_uint32("ptr_bufsize", ps, depth, &(r_q->ptr_bufsize))) return False; - if(!prs_uint8 ("minor_version2", ps, depth, &r_q->minor_version2)) + if(!prs_uint32("bufsize", ps, depth, &(r_q->bufsize))) return False; - if(!prs_uint8s(False, "pad2", ps, depth, r_q->pad2, sizeof(r_q->pad2))) + if(!prs_uint32("buf_unk", ps, depth, &(r_q->buf_unk))) return False; } - if(!prs_uint32("ptr3", ps, depth, &r_q->ptr3)) + if(!prs_uint32("unk1", ps, depth, &(r_q->unk1))) return False; - if (r_q->ptr3 != 0) { - if(!prs_uint32("unknown", ps, depth, &r_q->unknown)) - return False; - } + if(!prs_uint32("ptr_buflen", ps, depth, &(r_q->ptr_buflen))) + return False; + if(!prs_uint32("buflen", ps, depth, &(r_q->buflen))) + return False; - return True; + 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. ********************************************************************/ -void init_reg_r_info(REG_R_INFO *r_r, - uint32 level, char *os_type, - uint32 unknown_0, uint32 unknown_1, - uint32 status) +BOOL init_reg_r_info(uint32 include_keyval, REG_R_INFO *r_r, + BUFFER2* buf, uint32 type, uint32 status) { - uint8 buf[512]; - int len = dos_struni2((char *)buf, os_type, sizeof(buf)); + if(r_r == NULL) + return False; - r_r->ptr1 = 1; - r_r->level = level; + + r_r->ptr_type = 1; + r_r->type = type; - r_r->ptr_type = 1; - init_buffer2(&r_r->uni_type, buf, len*2); + /* 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->ptr2 = 1; - r_r->unknown_0 = unknown_0; + r_r->ptr_max_len = 1; + r_r->buf_max_len = r_r->uni_val->buf_max_len; - r_r->ptr3 = 1; - r_r->unknown_1 = unknown_1; + r_r->ptr_len = 1; + r_r->buf_len = r_r->uni_val->buf_len; - r_r->status = status; + r_r->status = status; + + return True; + } /******************************************************************* @@ -997,41 +999,44 @@ BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth) if(!prs_align(ps)) return False; - if(!prs_uint32("ptr1", ps, depth, &r_r->ptr1)) + if(!prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type))) return False; - if (r_r->ptr1 != 0) { - if(!prs_uint32("level", ps, depth, &r_r->level)) - return False; - if(!prs_uint32("ptr_type", ps, depth, &r_r->ptr_type)) + if (r_r->ptr_type != 0) { + if(!prs_uint32("type", ps, depth, &r_r->type)) return False; + } - if(!smb_io_buffer2("uni_type", &r_r->uni_type, r_r->ptr_type, ps, depth)) - return False; - if(!prs_align(ps)) - return False; + if(!prs_uint32("ptr_uni_val", ps, depth, &(r_r->ptr_uni_val))) + return False; - if(!prs_uint32("ptr2", ps, depth, &r_r->ptr2)) + 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 (r_r->ptr2 != 0) { - if(!prs_uint32("unknown_0", ps, depth, &r_r->unknown_0)) - return False; - } + if(!prs_align(ps)) + return False; - if(!prs_uint32("ptr3", ps, depth, &r_r->ptr3)) - return False; + if(!prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len))) + return False; - if (r_r->ptr3 != 0) { - if(!prs_uint32("unknown_1", ps, depth, &r_r->unknown_1)) - 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_uint32("status", ps, depth, &r_r->status)) return False; - return True; + return True; } /******************************************************************* diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c index 6a8d803c2e..cba24d7dfb 100644 --- a/source3/rpc_server/srv_reg.c +++ b/source3/rpc_server/srv_reg.c @@ -23,6 +23,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + #include "includes.h" extern int DEBUGLEVEL; @@ -59,7 +60,7 @@ static void reg_reply_close(REG_Q_CLOSE *q_r, /******************************************************************* api_reg_close ********************************************************************/ -static BOOL api_reg_close(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_close(prs_struct *data, prs_struct *rdata ) { REG_Q_CLOSE q_r; @@ -99,7 +100,7 @@ static void reg_reply_open(REG_Q_OPEN_HKLM *q_r, /******************************************************************* api_reg_open ********************************************************************/ -static BOOL api_reg_open(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_open(prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_HKLM q_u; @@ -164,7 +165,7 @@ static void reg_reply_open_entry(REG_Q_OPEN_ENTRY *q_u, /******************************************************************* api_reg_open_entry ********************************************************************/ -static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_open_entry(prs_struct *data, prs_struct *rdata ) { REG_Q_OPEN_ENTRY q_u; @@ -185,6 +186,11 @@ static void reg_reply_info(REG_Q_INFO *q_u, prs_struct *rdata) { uint32 status = 0; + fstring key = "ServerNT"; /* always a non-PDC */ + uint32 type=0x1; /* key type: REG_SZ */ + + UNISTR2 uni_key; + BUFFER2 buf; REG_R_INFO r_u; @@ -195,14 +201,13 @@ static void reg_reply_info(REG_Q_INFO *q_u, status = 0xC000000 | NT_STATUS_INVALID_HANDLE; } - if (status == 0) - { - } - /* This makes the server look like a member server to clients */ /* which tells clients that we have our own local user and */ /* group databases and helps with ACL support. */ - init_reg_r_info(&r_u, 1, "ServerNT", 0x12, 0x12, status); + init_unistr2(&uni_key, key, strlen(key)+1); + init_buffer2(&buf, (uint8*) uni_key.buffer, uni_key.uni_str_len*2); + + init_reg_r_info(q_u->ptr_buf, &r_u, &buf, type, status); /* store the response in the SMB stream */ reg_io_r_info("", &r_u, rdata, 0); @@ -213,7 +218,7 @@ static void reg_reply_info(REG_Q_INFO *q_u, /******************************************************************* api_reg_info ********************************************************************/ -static BOOL api_reg_info(prs_struct *data, prs_struct *rdata) +static BOOL api_reg_info(prs_struct *data, prs_struct *rdata ) { REG_Q_INFO q_u; @@ -246,5 +251,4 @@ BOOL api_reg_rpc(pipes_struct *p, prs_struct *data) { return api_rpcTNP(p, "api_reg_rpc", api_reg_cmds, data); } - #undef OLD_NTDOMAIN |