diff options
author | Günther Deschner <gd@samba.org> | 2009-07-17 13:37:08 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2009-07-17 13:50:34 +0200 |
commit | 7e9f8f0f951912943208af8cdb47c6b733b0d82c (patch) | |
tree | 86e48346b4b16371ae592fd86eef020c2a8806b5 /source3 | |
parent | 27c39a280460a1ae94bd2936535263c77729af5a (diff) | |
download | samba-7e9f8f0f951912943208af8cdb47c6b733b0d82c.tar.gz samba-7e9f8f0f951912943208af8cdb47c6b733b0d82c.tar.bz2 samba-7e9f8f0f951912943208af8cdb47c6b733b0d82c.zip |
s3-rpcclient: add LSA storeprivatedata command.
Guenther
Diffstat (limited to 'source3')
-rw-r--r-- | source3/rpcclient/cmd_lsarpc.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index c4f8e2654b..d7f8041779 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -1661,6 +1661,61 @@ static NTSTATUS cmd_lsa_retrieve_private_data(struct rpc_pipe_client *cli, return status; } +static NTSTATUS cmd_lsa_store_private_data(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + NTSTATUS status; + struct policy_handle handle; + struct lsa_String name; + struct lsa_DATA_BUF val; + DATA_BLOB session_key; + DATA_BLOB enc_key; + + if (argc < 3) { + printf("Usage: %s name secret\n", argv[0]); + return NT_STATUS_OK; + } + + status = rpccli_lsa_open_policy2(cli, mem_ctx, + true, + SEC_FLAG_MAXIMUM_ALLOWED, + &handle); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + init_lsa_String(&name, argv[1]); + + ZERO_STRUCT(val); + + status = cli_get_session_key(mem_ctx, cli, &session_key); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + enc_key = sess_encrypt_string(argv[2], &session_key); + + val.length = enc_key.length; + val.size = enc_key.length; + val.data = enc_key.data; + + status = rpccli_lsa_StorePrivateData(cli, mem_ctx, + &handle, + &name, + &val); + if (!NT_STATUS_IS_OK(status)) { + goto done; + } + + done: + if (is_valid_policy_hnd(&handle)) { + rpccli_lsa_Close(cli, mem_ctx, &handle); + } + + return status; +} + /* List of commands exported by this module */ @@ -1694,6 +1749,7 @@ struct cmd_set lsarpc_commands[] = { { "querysecret", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query Secret", "" }, { "setsecret", RPC_RTYPE_NTSTATUS, cmd_lsa_set_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Set Secret", "" }, { "retrieveprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_retrieve_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Retrieve Private Data", "" }, + { "storeprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_store_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Store Private Data", "" }, { NULL } }; |