summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_lsarpc.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2001-04-28 00:32:56 +0000
committerGerald Carter <jerry@samba.org>2001-04-28 00:32:56 +0000
commite40449fa720d0934abd06cd0b0b05d0ca0f4e257 (patch)
tree3a66b67b2037a773ddad2d27bfd8d74250682159 /source3/rpcclient/cmd_lsarpc.c
parentb238f4a2ffeb225d16857b594355dc60c976e3e0 (diff)
downloadsamba-e40449fa720d0934abd06cd0b0b05d0ca0f4e257.tar.gz
samba-e40449fa720d0934abd06cd0b0b05d0ca0f4e257.tar.bz2
samba-e40449fa720d0934abd06cd0b0b05d0ca0f4e257.zip
rpcclient merge from 2.2 (including Jeremy's non-void return fix)
(This used to be commit 0a6ceed279cc8111008b21f75c6791efbd993f4b)
Diffstat (limited to 'source3/rpcclient/cmd_lsarpc.c')
-rw-r--r--source3/rpcclient/cmd_lsarpc.c66
1 files changed, 52 insertions, 14 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index a574f2e128..153d5366e0 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -34,12 +34,19 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
DOM_SID dom_sid;
fstring sid_str, domain_name;
uint32 info_class = 3;
+ TALLOC_CTX *mem_ctx;
if (argc > 2) {
printf("Usage: %s [info_class]\n", argv[0]);
return 0;
}
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_lsa_query_info_poicy: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
if (argc == 2) {
info_class = atoi(argv[1]);
}
@@ -50,7 +57,7 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
return NT_STATUS_UNSUCCESSFUL;
}
- if ((result = cli_lsa_open_policy(cli, True,
+ if ((result = cli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
@@ -60,7 +67,7 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
/* Lookup info policy */
- if ((result = cli_lsa_query_info_policy(cli, &pol, info_class,
+ if ((result = cli_lsa_query_info_policy(cli, mem_ctx, &pol, info_class,
domain_name, &dom_sid))
!= NT_STATUS_NOPROBLEMO) {
goto done;
@@ -73,10 +80,11 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
done:
if (got_policy_hnd) {
- cli_lsa_close(cli, &pol);
+ cli_lsa_close(cli, mem_ctx, &pol);
}
cli_nt_session_close(cli);
+ talloc_destroy(mem_ctx);
return result;
}
@@ -91,12 +99,19 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
DOM_SID *sids;
uint32 *types;
int num_names, i;
+ TALLOC_CTX *mem_ctx;
if (argc == 1) {
printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
return 0;
}
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_lsa_lookup_names: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
@@ -104,7 +119,7 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
}
- if ((result = cli_lsa_open_policy(cli, True,
+ if ((result = cli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
@@ -114,8 +129,8 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
/* Lookup the names */
- if ((result = cli_lsa_lookup_names(
- cli, &pol, argc - 1, &argv[1], &sids, &types, &num_names) !=
+ if ((result = cli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
+ &argv[1], &sids, &types, &num_names) !=
NT_STATUS_NOPROBLEMO)) {
goto done;
}
@@ -130,16 +145,19 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
types[i]);
}
+#if 0 /* JERRY */
safe_free(sids);
safe_free(types);
+#endif
done:
if (got_policy_hnd) {
- cli_lsa_close(cli, &pol);
+ cli_lsa_close(cli, mem_ctx, &pol);
}
cli_nt_session_close(cli);
+ talloc_destroy(mem_ctx);
return result;
}
@@ -155,19 +173,26 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
char **names;
uint32 *types;
int num_names, i;
+ TALLOC_CTX *mem_ctx;
if (argc == 1) {
printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
return 0;
}
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_lsa_lookup_sids: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
return NT_STATUS_UNSUCCESSFUL;
}
- if ((result = cli_lsa_open_policy(cli, True,
+ if ((result = cli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
@@ -177,7 +202,7 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
/* Convert arguments to sids */
- sids = (DOM_SID *)malloc(sizeof(DOM_SID) * (argc - 1));
+ sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * (argc - 1));
if (!sids) {
printf("out of memory\n");
@@ -190,7 +215,7 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
/* Lookup the SIDs */
- if ((result = cli_lsa_lookup_sids(cli, &pol, argc - 1, sids,
+ if ((result = cli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
&names, &types, &num_names) !=
NT_STATUS_NOPROBLEMO)) {
goto done;
@@ -206,6 +231,7 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
"*unknown*", types[i]);
}
+#if 0 /* JERRY */
safe_free(sids);
safe_free(types);
@@ -214,14 +240,16 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
}
safe_free(names);
+#endif
done:
if (got_policy_hnd) {
- cli_lsa_close(cli, &pol);
+ cli_lsa_close(cli, mem_ctx, &pol);
}
cli_nt_session_close(cli);
+ talloc_destroy (mem_ctx);
return result;
}
@@ -238,19 +266,26 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
uint32 enum_ctx = 0;
uint32 num_domains;
int i;
+ TALLOC_CTX *mem_ctx;
if (argc != 1) {
printf("Usage: %s\n", argv[0]);
return 0;
}
+ if (!(mem_ctx=talloc_init()))
+ {
+ DEBUG(0,("cmd_lsa_enum_trust_dom: talloc_init returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
return NT_STATUS_UNSUCCESSFUL;
}
- if ((result = cli_lsa_open_policy(cli, True,
+ if ((result = cli_lsa_open_policy(cli, mem_ctx, True,
SEC_RIGHTS_MAXIMUM_ALLOWED,
&pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
@@ -260,7 +295,7 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
/* Lookup list of trusted domains */
- if ((result = cli_lsa_enum_trust_dom(cli, &pol, &enum_ctx,
+ if ((result = cli_lsa_enum_trust_dom(cli, mem_ctx, &pol, &enum_ctx,
&num_domains, &domain_names,
&domain_sids)
!= NT_STATUS_NOPROBLEMO)) {
@@ -277,6 +312,7 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
"*unknown*", sid_str);
}
+#if 0 /* JERRY */
safe_free(domain_sids);
for (i = 0; i < num_domains; i++) {
@@ -284,14 +320,16 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
}
safe_free(domain_names);
+#endif
done:
if (got_policy_hnd) {
- cli_lsa_close(cli, &pol);
+ cli_lsa_close(cli, mem_ctx, &pol);
}
cli_nt_session_close(cli);
+ talloc_destroy(mem_ctx);
return result;
}