From 976fba87eb76649d62aaa335d15338ac151de0e0 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 10:33:31 +0100 Subject: Use rpccli_lsa_EnumPrivs() in net and rpcclient. Guenther (This used to be commit bb24cccfc87dd8b97cc68a0dd205dc338f21f37d) --- source3/utils/net_rpc_rights.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 5f222b8c7e..afa786f0f5 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -94,31 +94,32 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, NTSTATUS result; uint32 enum_context = 0; uint32 pref_max_length=0x1000; - uint32 count=0; - char **privs_name; - uint32 *privs_high; - uint32 *privs_low; int i; uint16 lang_id=0; uint16 lang_id_sys=0; uint16 lang_id_desc; fstring description; + struct lsa_PrivArray priv_array; - result = rpccli_lsa_enum_privilege(pipe_hnd, ctx, pol, &enum_context, - pref_max_length, &count, &privs_name, &privs_high, &privs_low); + result = rpccli_lsa_EnumPrivs(pipe_hnd, ctx, + pol, + &enum_context, + &priv_array, + pref_max_length); if ( !NT_STATUS_IS_OK(result) ) return result; /* Print results */ - - for (i = 0; i < count; i++) { - d_printf("%30s ", privs_name[i] ? privs_name[i] : "*unknown*" ); - + + for (i = 0; i < priv_array.count; i++) { + d_printf("%30s ", + priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*" ); + /* try to get the description */ if ( !NT_STATUS_IS_OK(rpccli_lsa_get_dispname(pipe_hnd, ctx, pol, - privs_name[i], lang_id, lang_id_sys, description, &lang_id_desc)) ) + priv_array.privs[i].name.string, lang_id, lang_id_sys, description, &lang_id_desc)) ) { d_printf("??????\n"); continue; -- cgit From 7b502954002dd9b4aa413dbf334aa25d5865656e Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 11 Feb 2008 12:17:27 +0100 Subject: Use rpccli_lsa_LookupPrivDisplayName() in net and rpcclient. Guenther (This used to be commit be932cbdfa51eefafe79a81fa393ffea1fa4e25e) --- source3/utils/net_rpc_rights.c | 48 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index afa786f0f5..e110c412e0 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -19,6 +19,11 @@ #include "includes.h" #include "utils/net.h" +static void init_lsa_String(struct lsa_String *name, const char *s) +{ + name->string = s; +} + /******************************************************************** ********************************************************************/ @@ -98,7 +103,7 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, uint16 lang_id=0; uint16 lang_id_sys=0; uint16 lang_id_desc; - fstring description; + struct lsa_StringLarge *description = NULL; struct lsa_PrivArray priv_array; result = rpccli_lsa_EnumPrivs(pipe_hnd, ctx, @@ -113,19 +118,30 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, /* Print results */ for (i = 0; i < priv_array.count; i++) { + + struct lsa_String lsa_name; + d_printf("%30s ", priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*" ); /* try to get the description */ - - if ( !NT_STATUS_IS_OK(rpccli_lsa_get_dispname(pipe_hnd, ctx, pol, - priv_array.privs[i].name.string, lang_id, lang_id_sys, description, &lang_id_desc)) ) - { + + init_lsa_String(&lsa_name, priv_array.privs[i].name.string); + + result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, ctx, + pol, + &lsa_name, + lang_id, + lang_id_sys, + &description, + &lang_id_desc); + + if (!NT_STATUS_IS_OK(result)) { d_printf("??????\n"); continue; } - - d_printf("%s\n", description ); + + d_printf("%s\n", description->string); } return NT_STATUS_OK; @@ -298,7 +314,8 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid, NTSTATUS result; DOM_SID sid; fstring privname; - fstring description; + struct lsa_String lsa_name; + struct lsa_StringLarge *description = NULL; uint16 lang_id = 0; uint16 lang_id_sys = 0; uint16 lang_id_desc; @@ -326,14 +343,19 @@ static NTSTATUS rpc_rights_list_internal(const DOM_SID *domain_sid, } while ( argv[i] != NULL ) { - fstrcpy( privname, argv[i] ); + fstrcpy(privname, argv[i]); + init_lsa_String(&lsa_name, argv[i]); i++; /* verify that this is a valid privilege for error reporting */ - - result = rpccli_lsa_get_dispname(pipe_hnd, mem_ctx, &pol, privname, lang_id, - lang_id_sys, description, &lang_id_desc); - + result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, mem_ctx, + &pol, + &lsa_name, + lang_id, + lang_id_sys, + &description, + &lang_id_desc); + if ( !NT_STATUS_IS_OK(result) ) { if ( NT_STATUS_EQUAL( result, NT_STATUS_NO_SUCH_PRIVILEGE ) ) d_fprintf(stderr, "No such privilege exists: %s.\n", privname); -- cgit From e2b3aad8174daede0248ce96df624e575867cfd8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 12 Feb 2008 22:05:39 +0100 Subject: Collect all init_lsa_string varients in one place. Guenther (This used to be commit f4581e9f4482566fba9436d5ae058b8d840fa394) --- source3/utils/net_rpc_rights.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index e110c412e0..de6e14ebad 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -19,11 +19,6 @@ #include "includes.h" #include "utils/net.h" -static void init_lsa_String(struct lsa_String *name, const char *s) -{ - name->string = s; -} - /******************************************************************** ********************************************************************/ -- cgit From 2b84f4119d0d5dc0eac0e3596260901e3dc3eefd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 01:32:56 +0100 Subject: Use rpccli_lsa_EnumAccounts() in net and rpcclient. Guenther (This used to be commit bdbcfa4419a54b98ea577b0052894ddaa06890ce) --- source3/utils/net_rpc_rights.c | 55 +++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index de6e14ebad..d8c7462c0d 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -214,24 +214,27 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd, NTSTATUS result; uint32 enum_context=0; uint32 pref_max_length=0x1000; - DOM_SID *sids = NULL; - uint32 count=0; + struct lsa_SidArray sid_array; int i; fstring name; - result = rpccli_lsa_enum_sids(pipe_hnd, ctx, pol, &enum_context, - pref_max_length, &count, &sids); + result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx, + pol, + &enum_context, + &sid_array, + pref_max_length); if (!NT_STATUS_IS_OK(result)) return result; d_printf("%s:\n", privilege); - for ( i=0; i Date: Thu, 14 Feb 2008 14:34:10 +0100 Subject: Use rpccli_lsa_AddAccountRights in net and rpcclient. Guenther (This used to be commit e94ded74d6541d1d8954cfbbbd577ca0c83ecd4c) --- source3/utils/net_rpc_rights.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index d8c7462c0d..9ba0eaae00 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -431,6 +431,8 @@ static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + struct lsa_RightSet rights; + int i; DOM_SID sid; @@ -450,8 +452,21 @@ static NTSTATUS rpc_rights_grant_internal(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(result)) return result; - result = rpccli_lsa_add_account_rights(pipe_hnd, mem_ctx, &dom_pol, sid, - argc-1, argv+1); + rights.count = argc-1; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Thu, 14 Feb 2008 15:09:21 +0100 Subject: Use rpccli_lsa_EnumAccountRights in net and rpcclient. Guenther (This used to be commit 6e9195329d9f2b26c959f64485902c032f140ec8) --- source3/utils/net_rpc_rights.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 9ba0eaae00..a0df5d8980 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -152,22 +152,24 @@ static NTSTATUS check_privilege_for_user(struct rpc_pipe_client *pipe_hnd, const char *right) { NTSTATUS result; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; - result = rpccli_lsa_enum_account_rights(pipe_hnd, ctx, pol, sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + pol, + sid, + &rights); if (!NT_STATUS_IS_OK(result)) { return result; } - if (count == 0) { + if (rights.count == 0) { return NT_STATUS_OBJECT_NAME_NOT_FOUND; } - - for (i = 0; i < count; i++) { - if (StrCaseCmp(rights[i], right) == 0) { + + for (i = 0; i < rights.count; i++) { + if (StrCaseCmp(rights.names[i].string, right) == 0) { return NT_STATUS_OK; } } @@ -184,20 +186,23 @@ static NTSTATUS enum_privileges_for_user(struct rpc_pipe_client *pipe_hnd, DOM_SID *sid ) { NTSTATUS result; - uint32 count; - char **rights; + struct lsa_RightSet rights; int i; - result = rpccli_lsa_enum_account_rights(pipe_hnd, ctx, pol, sid, &count, &rights); + result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + pol, + sid, + &rights); if (!NT_STATUS_IS_OK(result)) return result; - if ( count == 0 ) + if (rights.count == 0) { d_printf("No privileges assigned\n"); - - for (i = 0; i < count; i++) { - printf("%s\n", rights[i]); + } + + for (i = 0; i < rights.count; i++) { + printf("%s\n", rights.names[i].string); } return NT_STATUS_OK; -- cgit From f21cdab938a0a94405d595bb80fbda724315d984 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 14 Feb 2008 15:28:26 +0100 Subject: Use rpccli_lsa_RemoveAccountRights() in net and rpcclient. Guenther (This used to be commit 78200d88924bbef3df7185fc3a0e1753160a592f) --- source3/utils/net_rpc_rights.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index a0df5d8980..16d75e57d9 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -502,8 +502,9 @@ static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid, { POLICY_HND dom_pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - + struct lsa_RightSet rights; DOM_SID sid; + int i; if (argc < 2 ) { d_printf("Usage: net rpc rights revoke \n"); @@ -521,8 +522,22 @@ static NTSTATUS rpc_rights_revoke_internal(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(result)) return result; - result = rpccli_lsa_remove_account_rights(pipe_hnd, mem_ctx, &dom_pol, sid, - False, argc-1, argv+1); + rights.count = argc-1; + rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, + rights.count); + if (!rights.names) { + return NT_STATUS_NO_MEMORY; + } + + for (i=0; i Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/utils/net_rpc_rights.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/utils/net_rpc_rights.c') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 16d75e57d9..7857dbcbaf 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -2,6 +2,7 @@ Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility Copyright (C) Gerald (Jerry) Carter 2004 + Copyright (C) Guenther Deschner 2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit