summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_reg.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-08-03 20:30:25 +0000
committerLuke Leighton <lkcl@samba.org>1999-08-03 20:30:25 +0000
commit8598bf2a7f0f71ae7a023aac054c4df42b969ce6 (patch)
tree53352e656e5d01de5a2711b62ac1239979f6d53f /source3/rpcclient/cmd_reg.c
parent9c593512155a4e1d9eb01ac63d4458df59b7357d (diff)
downloadsamba-8598bf2a7f0f71ae7a023aac054c4df42b969ce6.tar.gz
samba-8598bf2a7f0f71ae7a023aac054c4df42b969ce6.tar.bz2
samba-8598bf2a7f0f71ae7a023aac054c4df42b969ce6.zip
reverted jeremy's c++-like security descriptor modifications as the
simplest method to get rpcclient's reggetsec command working. the buffers passed as arguments in do_reg_get_key_sec() do need to be locally allocated not dynamically allocated, as two calls to reg_get_key_sec() are needed. on the first, the server fills in the size of the security descriptor buffer needed. on the second, the server fills in the security descriptor buffer. (This used to be commit b2d9cbef6f65bb696df8d8f49aa0c240e0bb1f50)
Diffstat (limited to 'source3/rpcclient/cmd_reg.c')
-rw-r--r--source3/rpcclient/cmd_reg.c50
1 files changed, 29 insertions, 21 deletions
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index ed337a59f5..d5b032be90 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -739,7 +739,7 @@ void cmd_reg_test_key_sec(struct client_info *info)
*/
uint32 sec_buf_size;
- SEC_DESC_BUF *psdb;
+ SEC_DESC_BUF sec_buf;
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
@@ -771,28 +771,32 @@ void cmd_reg_test_key_sec(struct client_info *info)
res3 = res ? do_reg_open_entry(smb_cli, fnum, &info->dom.reg_pol_connect,
key_name, 0x02000000, &key_pol) : False;
- /* Get the size. */
+ /* query key sec info. first call sets sec_buf_size. */
sec_buf_size = 0;
+ ZERO_STRUCT(sec_buf);
res4 = res3 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
- &sec_buf_size, &psdb) : False;
+ &sec_buf_size, &sec_buf) : False;
- free_sec_desc_buf(&psdb);
+ if (res4)
+ {
+ free_sec_desc_buf(&sec_buf);
+ }
res4 = res4 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
- &sec_buf_size, &psdb) : False;
+ &sec_buf_size, &sec_buf) : False;
- if (res4 && psdb->len > 0 && psdb->sec != NULL)
+ if (res4 && sec_buf.len > 0 && sec_buf.sec != NULL)
{
- display_sec_desc(out_hnd, ACTION_HEADER , psdb->sec);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, psdb->sec);
- display_sec_desc(out_hnd, ACTION_FOOTER , psdb->sec);
+ display_sec_desc(out_hnd, ACTION_HEADER , sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_ENUMERATE, sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_FOOTER , sec_buf.sec);
res4 = res4 ? do_reg_set_key_sec(smb_cli, fnum, &key_pol,
- psdb) : False;
+ sec_buf_size, sec_buf.sec) : False;
+ free_sec_desc_buf(&sec_buf);
}
- free_sec_desc_buf(&psdb);
/* close the key handle */
if ((*key_name) != 0)
@@ -836,7 +840,7 @@ void cmd_reg_get_key_sec(struct client_info *info)
*/
uint32 sec_buf_size;
- SEC_DESC_BUF *psdb;
+ SEC_DESC_BUF sec_buf;
DEBUG(5, ("cmd_reg_get_key_sec: smb_cli->fd:%d\n", smb_cli->fd));
@@ -868,25 +872,29 @@ void cmd_reg_get_key_sec(struct client_info *info)
res3 = res ? do_reg_open_entry(smb_cli, fnum, &info->dom.reg_pol_connect,
key_name, 0x02000000, &key_pol) : False;
- /* Get the size. */
+ /* query key sec info. first call sets sec_buf_size. */
sec_buf_size = 0;
+ ZERO_STRUCT(sec_buf);
res4 = res3 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
- &sec_buf_size, &psdb) : False;
+ &sec_buf_size, &sec_buf) : False;
- free_sec_desc_buf(&psdb);
+ if (res4)
+ {
+ free_sec_desc_buf(&sec_buf);
+ }
res4 = res4 ? do_reg_get_key_sec(smb_cli, fnum, &key_pol,
- &sec_buf_size, &psdb) : False;
+ &sec_buf_size, &sec_buf) : False;
- if (res4 && psdb->len > 0 && psdb->sec != NULL)
+ if (res4 && sec_buf.len > 0 && sec_buf.sec != NULL)
{
- display_sec_desc(out_hnd, ACTION_HEADER , psdb->sec);
- display_sec_desc(out_hnd, ACTION_ENUMERATE, psdb->sec);
- display_sec_desc(out_hnd, ACTION_FOOTER , psdb->sec);
+ display_sec_desc(out_hnd, ACTION_HEADER , sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_ENUMERATE, sec_buf.sec);
+ display_sec_desc(out_hnd, ACTION_FOOTER , sec_buf.sec);
+ free(sec_buf.sec);
}
- free_sec_desc_buf(&psdb);
/* close the key handle */
if ((*key_name) != 0)