*/
#include "includes.h"
#include "utils/net.h"
+#include "rpc_client/rpc_client.h"
#include "../librpc/gen_ndr/ndr_lsa_c.h"
#include "rpc_client/cli_lsarpc.h"
#include "rpc_client/init_lsa.h"
#include "../libcli/security/security.h"
+#include "lib/util/string_wrappers.h"
/********************************************************************
********************************************************************/
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
/* maybe its a raw SID */
- if ( strncmp(name, "S-", 2) == 0 && string_to_sid(sid, name) ) {
+ if (dom_sid_parse(name, sid)) {
return NT_STATUS_OK;
}
struct policy_handle *pol )
{
NTSTATUS status, result;
- uint32 enum_context = 0;
- uint32 pref_max_length=0x1000;
- int i;
- uint16 lang_id=0;
- uint16 lang_id_sys=0;
- uint16 lang_id_desc;
+ uint32_t enum_context = 0;
+ uint32_t pref_max_length=0x1000;
+ uint32_t i;
+ uint16_t lang_id=0;
+ uint16_t lang_id_sys=0;
+ uint16_t lang_id_desc;
struct lsa_StringLarge *description = NULL;
struct lsa_PrivArray priv_array;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
continue;
}
- d_printf("%s\n", description->string);
+ d_printf("%s\n", description ? description->string : "??????");
}
return NT_STATUS_OK;
{
NTSTATUS status, result;
struct lsa_RightSet rights;
- int i;
+ uint32_t i;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
status = dcerpc_lsa_EnumAccountRights(b, ctx,
}
for (i = 0; i < rights.count; i++) {
- if (StrCaseCmp(rights.names[i].string, right) == 0) {
+ if (strcasecmp_m(rights.names[i].string, right) == 0) {
return NT_STATUS_OK;
}
}
{
NTSTATUS status, result;
struct lsa_RightSet rights;
- int i;
+ uint32_t i;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
status = dcerpc_lsa_EnumAccountRights(b, ctx,
const char *privilege)
{
NTSTATUS status, result;
- uint32 enum_context=0;
- uint32 pref_max_length=0x1000;
+ uint32_t enum_context=0;
+ uint32_t pref_max_length=0x1000;
struct lsa_SidArray sid_array;
- int i;
+ uint32_t i;
fstring name;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
struct policy_handle *pol)
{
NTSTATUS status, result;
- uint32 enum_context=0;
- uint32 pref_max_length=0x1000;
+ uint32_t enum_context=0;
+ uint32_t pref_max_length=0x1000;
struct lsa_SidArray sid_array;
- int i;
+ uint32_t i;
fstring name;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
fstring privname;
struct lsa_String lsa_name;
struct lsa_StringLarge *description = NULL;
- uint16 lang_id = 0;
- uint16 lang_id_sys = 0;
- uint16 lang_id_desc;
+ uint16_t lang_id = 0;
+ uint16_t lang_id_sys = 0;
+ uint16_t lang_id_desc;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
if ( !NT_STATUS_IS_OK(status) )
return status;
- /* backwards compatibility; just list available privileges if no arguement */
+ /* backwards compatibility; just list available privileges if no argument */
if (argc == 0) {
status = enum_privileges(pipe_hnd, mem_ctx, &pol );
goto done;
}
- /* backward comaptibility: if no keyword provided, treat the key
+ /* backward compatibility: if no keyword provided, treat the key
as an account name */
if (argc > 1) {
d_printf("%s net rpc rights list [[accounts|privileges] "
int argc,
const char **argv )
{
- struct policy_handle dom_pol;
+ struct policy_handle dom_pol = {
+ .handle_type = 0,
+ };
NTSTATUS status, result;
struct lsa_RightSet rights;
int i;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
+ union lsa_revision_info out_revision_info = {
+ .info1 = {
+ .revision = 0,
+ },
+ };
+ uint32_t out_version = 0;
struct dom_sid sid;
if (!NT_STATUS_IS_OK(status))
goto done;
- status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true,
- SEC_FLAG_MAXIMUM_ALLOWED,
- &dom_pol);
-
- if (!NT_STATUS_IS_OK(status))
- return status;
+ status = dcerpc_lsa_open_policy_fallback(b,
+ mem_ctx,
+ pipe_hnd->srv_name_slash,
+ true,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &out_version,
+ &out_revision_info,
+ &dom_pol,
+ &result);
+ if (any_nt_status_not_ok(status, result, &status)) {
+ DBG_DEBUG("Couldn't open policy handle: %s\n",
+ nt_errstr(status));
+ goto done;
+ }
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
- if (!rights.names) {
- return NT_STATUS_NO_MEMORY;
+ if (rights.names == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
}
for (i=0; i<argc-1; i++) {
&sid,
&rights,
&result);
- if (!NT_STATUS_IS_OK(status))
- goto done;
- if (!NT_STATUS_IS_OK(result)) {
- status = result;
+ if (any_nt_status_not_ok(status, result, &status)) {
goto done;
}
struct dom_sid sid;
int i;
struct dcerpc_binding_handle *b = pipe_hnd->binding_handle;
+ union lsa_revision_info out_revision_info = {
+ .info1 =
+ {
+ .revision = 0,
+ },
+ };
+ uint32_t out_version = 0;
if (argc < 2 ) {
d_printf("%s\n%s",
if (!NT_STATUS_IS_OK(status))
return status;
- status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true,
- SEC_FLAG_MAXIMUM_ALLOWED,
- &dom_pol);
-
- if (!NT_STATUS_IS_OK(status))
+ status = dcerpc_lsa_open_policy_fallback(b,
+ mem_ctx,
+ pipe_hnd->srv_name_slash,
+ true,
+ SEC_FLAG_MAXIMUM_ALLOWED,
+ &out_version,
+ &out_revision_info,
+ &dom_pol,
+ &result);
+ if (any_nt_status_not_ok(status, result, &status)) {
+ DBG_DEBUG("Couldn't open policy handle: %s\n",
+ nt_errstr(status));
return status;
+ }
rights.count = argc-1;
- rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
+ rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
rights.count);
if (!rights.names) {
return NT_STATUS_NO_MEMORY;
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_lsarpc, 0,
rpc_rights_list_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_lsarpc, 0,
rpc_rights_grant_internal, argc, argv );
}
return 0;
}
- return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
+ return run_rpc_command(c, NULL, &ndr_table_lsarpc, 0,
rpc_rights_revoke_internal, argc, argv );
}
{
static struct rpc_sh_cmd cmds[] = {
- { "list", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_list,
+ { "list", NULL, &ndr_table_lsarpc, rpc_sh_rights_list,
N_("View available or assigned privileges") },
- { "grant", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_grant,
+ { "grant", NULL, &ndr_table_lsarpc, rpc_sh_rights_grant,
N_("Assign privilege[s]") },
- { "revoke", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_revoke,
+ { "revoke", NULL, &ndr_table_lsarpc, rpc_sh_rights_revoke,
N_("Revoke privilege[s]") },
{ NULL, NULL, 0, NULL, NULL }