updating reg_value_info() parsing code to take BUFFER2 instead of just
authorLuke Leighton <lkcl@samba.org>
Thu, 18 Nov 1999 17:57:21 +0000 (17:57 +0000)
committerLuke Leighton <lkcl@samba.org>
Thu, 18 Nov 1999 17:57:21 +0000 (17:57 +0000)
a char*.  now copes with multiple types.

source/include/proto.h
source/include/rpc_reg.h
source/rpc_client/cli_reg.c
source/rpc_parse/parse_reg.c
source/rpc_server/srv_reg.c
source/rpcclient/cmd_reg.c

index b84b6ef26d9b7e67003c975d3606c98be4adbe69..5183f5dfb0a65128e892672331258de4791253d4 100644 (file)
@@ -1874,7 +1874,7 @@ BOOL do_reg_query_key(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
 BOOL do_reg_unknown_1a(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd, uint32 *unk);
 BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
                                const char* val_name,
-                               char *type);
+                               uint32 *type, BUFFER2 *buf);
 BOOL do_reg_set_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
                                uint32 sec_buf_size, SEC_DESC *sec_buf);
 BOOL do_reg_get_key_sec(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
@@ -2499,7 +2499,7 @@ BOOL make_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, const char *val_name,
                                uint8 major, uint8 minor);
 BOOL reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth);
 BOOL make_reg_r_info(REG_R_INFO *r_r,
-                               uint32 type, char *buf,
+                               uint32 *type, BUFFER2 *buf,
                                uint32 status);
 BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth);
 BOOL make_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
index b00b7a5a900896e8eb867264c16bf0c2361f1839..6b141b9f475461d5be038ac333bafb1ef8828721 100644 (file)
@@ -442,10 +442,10 @@ typedef struct q_reg_info_info
 typedef struct r_reg_info_info
 { 
        uint32 ptr_type;            /* buffer pointer */
-       uint32 type;          /* 0x1 - info level? */
+       uint32 *type;          /* 0x1 - info level? */
 
        uint32 ptr_uni_type;       /* pointer to o/s type */
-       BUFFER2 uni_type;      /* unicode string o/s type - "LanmanNT" */
+       BUFFER2 *uni_type;      /* unicode string o/s type - "LanmanNT" */
 
        uint32 ptr_max_len;    /* pointer to unknown_0 */
        uint32 buf_max_len;    /* 0x12 */
index 53d17bdefa4a806b6de3d9d9be1743ef1a662ba5..dbdf98dcf71f31134805deb84b60a422ba004a14 100644 (file)
@@ -451,7 +451,7 @@ do a REG Query Info
 ****************************************************************************/
 BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
                                const char* val_name,
-                               char *type)
+                               uint32 *type, BUFFER2 *buffer)
 {
        prs_struct rbuf;
        prs_struct buf; 
@@ -480,6 +480,9 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
 
                ZERO_STRUCT(r_o);
 
+               r_o.type = type;
+               r_o.uni_type = buffer;
+
                reg_io_r_info("", &r_o, &rbuf, 0);
                p = rbuf.offset != 0;
 
@@ -493,8 +496,6 @@ BOOL do_reg_query_info(struct cli_state *cli, uint16 fnum, POLICY_HND *hnd,
                if (p)
                {
                        valid_query = True;
-                       unibuf_to_ascii(type, (const char*)r_o.uni_type.buffer,
-                               MIN(r_o.uni_type.buf_len, sizeof(fstring)-1));
                }
        }
 
index 1a0168f21d2c632dad58468c2b42678e59166749..ec2699e745fce83ac172481c6dd7ec5206c6ddf2 100644 (file)
@@ -896,27 +896,31 @@ BOOL reg_io_q_info(char *desc,  REG_Q_INFO *r_q, prs_struct *ps, int depth)
 creates a structure.
 ********************************************************************/
 BOOL make_reg_r_info(REG_R_INFO *r_r,
-                               uint32 type, char *buf,
+                               uint32 *type, BUFFER2 *buf,
                                uint32 status)
 {
-       int len;
-
-       if (r_r == NULL || buf == NULL) return False;
-
-       len = strlen(buf);
+       if (r_r == NULL) return False;
 
-       r_r->ptr_type = type;
+       r_r->ptr_type = type != NULL ? 1 : 0;
        r_r->type = type;
 
-       r_r->ptr_uni_type = 1;
-       make_buffer2(&(r_r->uni_type), buf, len);
-
-       r_r->ptr_max_len = 1;
-       r_r->buf_max_len = r_r->uni_type.buf_max_len;
+       r_r->ptr_uni_type = buf != NULL ? 1 : 0;
+       r_r->uni_type = buf;
 
-       r_r->ptr_len = 1;
-       r_r->buf_len = r_r->uni_type.buf_len;
+       if (buf != NULL)
+       {
+               r_r->ptr_max_len = 1;
+               r_r->buf_max_len = r_r->uni_type->buf_max_len;
 
+               r_r->ptr_len = 1;
+               r_r->buf_len = r_r->uni_type->buf_len;
+       }
+       else
+       {
+               r_r->ptr_max_len = 0;
+               r_r->ptr_len = 0;
+       }
+               
        r_r->status = status;
 
        return True;
@@ -937,11 +941,11 @@ BOOL reg_io_r_info(char *desc, REG_R_INFO *r_r, prs_struct *ps, int depth)
        prs_uint32("ptr_type", ps, depth, &(r_r->ptr_type));
        if (r_r->ptr_type != 0)
        {
-               prs_uint32("type", ps, depth, &(r_r->type));
+               prs_uint32("type", ps, depth, r_r->type);
        }
 
        prs_uint32("ptr_uni_type", ps, depth, &(r_r->ptr_uni_type));
-       smb_io_buffer2("uni_type", &(r_r->uni_type), r_r->ptr_uni_type, ps, depth);
+       smb_io_buffer2("uni_type", r_r->uni_type, r_r->ptr_uni_type, ps, depth);
        prs_align(ps);
 
        prs_uint32("ptr_max_len", ps, depth, &(r_r->ptr_max_len));
index ab7e4cf3ecfa3d16cf46c317a7df35baa91ee0ec..18781d0cd0441dda81735424003b961155501279 100644 (file)
@@ -187,6 +187,8 @@ static void reg_reply_info(REG_Q_INFO *q_u,
        uint32 status     = 0;
 
        REG_R_INFO r_u;
+       uint32 type = 1;
+       BUFFER2 buf;
 
        DEBUG(5,("reg_info: %d\n", __LINE__));
 
@@ -197,7 +199,9 @@ static void reg_reply_info(REG_Q_INFO *q_u,
 
        if (status == 0)
        {
-               make_reg_r_info(&r_u, 1, "LanmanNT", status);
+               char *key = "LanmanNT";
+               make_buffer2(&buf, key, strlen(key));
+               make_reg_r_info(&r_u, &type, &buf, status);
        }
 
 
index 316b5f6bc1dc71d919980147a6169cb9fbdf7482..02544987ece3d098af47219cbcf3f14534ada33e 100644 (file)
@@ -97,24 +97,6 @@ static void reg_display_key(int val, const char *full_keyname, int num)
        }
 }
 
-static void reg_display_key_info(const char *full_name,
-                               const char *name, time_t key_mod_time)
-{
-       display_reg_key_info(out_hnd, ACTION_HEADER   , name, key_mod_time);
-       display_reg_key_info(out_hnd, ACTION_ENUMERATE, name, key_mod_time);
-       display_reg_key_info(out_hnd, ACTION_FOOTER   , name, key_mod_time);
-}
-
-static void reg_display_val_info(const char *full_name,
-                               const char* name,
-                               uint32 type,
-                               const BUFFER2 *const value)
-{
-       display_reg_value_info(out_hnd, ACTION_HEADER   , name, type, value);
-       display_reg_value_info(out_hnd, ACTION_ENUMERATE, name, type, value);
-       display_reg_value_info(out_hnd, ACTION_FOOTER   , name, type, value);
-}
-
 
 /****************************************************************************
 nt registry enum
@@ -283,6 +265,24 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
        return res1;
 }
 
+static void reg_display_key_info(const char *full_name,
+                               const char *name, time_t key_mod_time)
+{
+       display_reg_key_info(out_hnd, ACTION_HEADER   , name, key_mod_time);
+       display_reg_key_info(out_hnd, ACTION_ENUMERATE, name, key_mod_time);
+       display_reg_key_info(out_hnd, ACTION_FOOTER   , name, key_mod_time);
+}
+
+static void reg_display_val_info(const char *full_name,
+                               const char* name,
+                               uint32 type,
+                               const BUFFER2 *const value)
+{
+       display_reg_value_info(out_hnd, ACTION_HEADER   , name, type, value);
+       display_reg_value_info(out_hnd, ACTION_ENUMERATE, name, type, value);
+       display_reg_value_info(out_hnd, ACTION_FOOTER   , name, type, value);
+}
+
 /****************************************************************************
 nt registry enum
 ****************************************************************************/
@@ -325,9 +325,9 @@ void cmd_reg_query_info(struct client_info *info)
         * query value info
         */
 
-       fstring type;
+       BUFFER2 buf;
+       uint32 type;
 
-       type[0] = 0;
        DEBUG(5, ("cmd_reg_enum: smb_cli->fd:%d\n", smb_cli->fd));
 
        if (!next_token(NULL, full_keyname, NULL, sizeof(full_keyname)))
@@ -364,11 +364,11 @@ void cmd_reg_query_info(struct client_info *info)
 
        /* query it */
        res1 = res1 ? do_reg_query_info(smb_cli, fnum, &key_pol,
-                               val_name, type) : False;
+                               val_name, &type, &buf) : False;
 
        if (res1)
        {
-               report(out_hnd, "type:\t%s\n", type);
+               reg_display_val_info(full_keyname, val_name, type, &buf);
        }
 
        /* close the handles */