From 655b04e4f8585a952afe226e602995ebbc7d1600 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 11 Apr 2006 15:47:24 +0000 Subject: r15041: Adding rpc client calls to manipulate auditing policies on remote CIFS servers. Also add a new "net rpc audit" tool. The lsa query infolevels were taken from samb4 IDL, the lsa policy flags and categories are partly documented on msdn. I need to cleanup the double lsa_query_info_policy{2}{_new} calls next. Guenther (This used to be commit 0fed66926f4b72444abfc8ffb8c46cca8d0600aa) --- source3/utils/net_rpc_audit.c | 414 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 414 insertions(+) create mode 100644 source3/utils/net_rpc_audit.c (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c new file mode 100644 index 0000000000..5c81fe24d0 --- /dev/null +++ b/source3/utils/net_rpc_audit.c @@ -0,0 +1,414 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + Copyright (C) 2006 Guenther Deschner + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "includes.h" +#include "utils/net.h" + +/******************************************************************** +********************************************************************/ + +static int net_help_audit(int argc, const char **argv) +{ + d_printf("net rpc audit list View configured Auditing policies\n"); + d_printf("net rpc audit enable Enable Auditing\n"); + d_printf("net rpc audit disable Disable Auditing\n"); + d_printf("net rpc audit get View configured Auditing policy setting\n"); + d_printf("net rpc audit set Set Auditing policies\n\n"); + d_printf("\tcategory can be one of: SYSTEM, LOGON, OBJECT, PRIVILEGE, PROCESS, POLICY, SAM, DIRECTORY or ACCOUNT\n"); + d_printf("\tpolicy can be one of: SUCCESS, FAILURE, ALL or NONE\n\n"); + + return -1; +} + +/******************************************************************** +********************************************************************/ + +static void print_auditing_category(const char *policy, const char *value) +{ + fstring padding; + int pad_len, col_len = 30; + + /* calculate padding space for d_printf to look nicer */ + pad_len = col_len - strlen(policy); + padding[pad_len] = 0; + do padding[--pad_len] = ' '; while (pad_len > 0); + + d_printf("\t%s%s%s\n", policy, padding, value); +} + + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + POLICY_HND pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + LSA_INFO_CTR dom; + int i; + + uint32 info_class = 2; + uint32 audit_category; + + if (argc < 1 || argc > 2) { + d_printf("insufficient arguments\n"); + net_help_audit(argc, argv); + return NT_STATUS_INVALID_PARAMETER; + } + + if (!get_audit_category_from_param(argv[0], &audit_category)) { + d_printf("invalid auditing category: %s\n", argv[0]); + return NT_STATUS_INVALID_PARAMETER; + } + + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, + info_class, + &dom); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + for (i=0; i < dom.info.id2.count1; i++) { + + const char *val = NULL, *policy = NULL; + + if (i != audit_category) { + continue; + } + + val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[i]); + policy = audit_description_str(i); + print_auditing_category(policy, val); + } + + done: + if (!NT_STATUS_IS_OK(result)) { + d_printf("failed to get auditing policy: %s\n", nt_errstr(result)); + } + + return result; +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + POLICY_HND pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + LSA_INFO_CTR dom; + + uint32 info_class = 2; + uint32 audit_policy, audit_category; + + if (argc < 2 || argc > 3) { + d_printf("insufficient arguments\n"); + net_help_audit(argc, argv); + return NT_STATUS_INVALID_PARAMETER; + } + + if (!get_audit_category_from_param(argv[0], &audit_category)) { + d_printf("invalid auditing category: %s\n", argv[0]); + return NT_STATUS_INVALID_PARAMETER; + } + + audit_policy = LSA_AUDIT_POLICY_CLEAR; + + if (strequal(argv[1], "Success")) { + audit_policy |= LSA_AUDIT_POLICY_SUCCESS; + } else if (strequal(argv[1], "Failure")) { + audit_policy |= LSA_AUDIT_POLICY_FAILURE; + } else if (strequal(argv[1], "All")) { + audit_policy |= LSA_AUDIT_POLICY_ALL; + } else if (strequal(argv[1], "None")) { + audit_policy = LSA_AUDIT_POLICY_CLEAR; + } else { + d_printf("invalid auditing policy: %s\n", argv[1]); + return NT_STATUS_INVALID_PARAMETER; + } + + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, + info_class, + &dom); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + dom.info.id2.auditsettings[audit_category] = audit_policy; + + result = rpccli_lsa_set_info_policy(pipe_hnd, mem_ctx, &pol, + info_class, + dom); + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, + info_class, + &dom); + + { + const char *val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[audit_category]); + const char *policy = audit_description_str(audit_category); + print_auditing_category(policy, val); + } + + done: + if (!NT_STATUS_IS_OK(result)) { + d_printf("failed to set audit policy: %s\n", nt_errstr(result)); + } + + return result; +} + +static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv, + BOOL enable) +{ + POLICY_HND pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + LSA_INFO_CTR dom; + + uint32 info_class = 2; + + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, + info_class, + &dom); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + dom.info.id2.auditing_enabled = enable; + + result = rpccli_lsa_set_info_policy(pipe_hnd, mem_ctx, &pol, + info_class, + dom); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + done: + if (!NT_STATUS_IS_OK(result)) { + d_printf("failed to %s audit policy: %s\n", enable ? "enable":"disable", + nt_errstr(result)); + } + + return result; +} +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, False); +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, True); +} + +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, + const char *domain_name, + struct cli_state *cli, + struct rpc_pipe_client *pipe_hnd, + TALLOC_CTX *mem_ctx, + int argc, + const char **argv) +{ + POLICY_HND pol; + NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + LSA_INFO_CTR dom; + int i; + + uint32 info_class = 2; + + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + SEC_RIGHTS_MAXIMUM_ALLOWED, + &pol); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, + info_class, + &dom); + + if (!NT_STATUS_IS_OK(result)) { + goto done; + } + + printf("Auditing:\t\t"); + switch (dom.info.id2.auditing_enabled) { + case True: + printf("Enabled"); + break; + case False: + printf("Disabled"); + break; + default: + printf("unknown (%d)", dom.info.id2.auditing_enabled); + break; + } + printf("\n"); + + printf("Auditing categories:\t%d\n", dom.info.id2.count1); + printf("Auditing settings:\n"); + + for (i=0; i < dom.info.id2.count1; i++) { + const char *val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[i]); + const char *policy = audit_description_str(i); + print_auditing_category(policy, val); + } + + done: + if (!NT_STATUS_IS_OK(result)) { + d_printf("failed to list auditing policies: %s\n", nt_errstr(result)); + } + + return result; +} + + + +/******************************************************************** +********************************************************************/ + +static int rpc_audit_get(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_LSARPC, 0, + rpc_audit_get_internal, argc, argv); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_audit_set(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_LSARPC, 0, + rpc_audit_set_internal, argc, argv); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_audit_enable(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_LSARPC, 0, + rpc_audit_enable_internal, argc, argv); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_audit_disable(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_LSARPC, 0, + rpc_audit_disable_internal, argc, argv); +} + +/******************************************************************** +********************************************************************/ + +static int rpc_audit_list(int argc, const char **argv) +{ + return run_rpc_command(NULL, PI_LSARPC, 0, + rpc_audit_list_internal, argc, argv); +} + +/******************************************************************** +********************************************************************/ + +int net_rpc_audit(int argc, const char **argv) +{ + struct functable func[] = { + {"get", rpc_audit_get}, + {"set", rpc_audit_set}, + {"enable", rpc_audit_enable}, + {"disable", rpc_audit_disable}, + {"list", rpc_audit_list}, + {NULL, NULL} + }; + + if (argc) + return net_run_function(argc, argv, func, net_help_audit); + + return net_help_audit(argc, argv); +} -- cgit From e7fc37cf0f4bd2c0f25865fb07d1bff27b239130 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 19 Jun 2006 19:07:39 +0000 Subject: r16360: Fix Klocwork ID 136 520 521 522 523 542 574 575 576 607 in net_rpc.c: 715 716 732 734 735 736 737 738 739 749 in net_rpc_audit.c: 754 755 756 in net_rpc_join.c: 757 in net_rpc_registry: 766 767 in net_rpc_samsync.c: 771 773 in net_sam.c: 797 798 Volker (This used to be commit 3df0bf7d6050fd7c9ace72487d4f74d92e30a584) --- source3/utils/net_rpc_audit.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 5c81fe24d0..981dc93fdd 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -44,6 +44,13 @@ static void print_auditing_category(const char *policy, const char *value) fstring padding; int pad_len, col_len = 30; + if (policy == NULL) { + policy = "Unknown"; + } + if (value == NULL) { + value = "Invalid"; + } + /* calculate padding space for d_printf to look nicer */ pad_len = col_len - strlen(policy); padding[pad_len] = 0; -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/utils/net_rpc_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 981dc93fdd..e2e28f646a 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -5,7 +5,7 @@ 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 - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/utils/net_rpc_audit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index e2e28f646a..5e87470fc5 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + along with this program. If not, see . */ #include "includes.h" #include "utils/net.h" -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/utils/net_rpc_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 5e87470fc5..b7fda2b8e3 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -217,7 +217,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, int argc, const char **argv, - BOOL enable) + bool enable) { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; -- cgit From 662d61e742f89543362a2d96edbf504175ad7e74 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 14 Jan 2008 17:17:20 +0100 Subject: Fix all callers of old rpccli_lsa_set_info_policy() call. Guenther (This used to be commit be8071779fa14d964e86810f5fb16bc52aea4e36) --- source3/utils/net_rpc_audit.c | 84 +++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 39 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index b7fda2b8e3..115f8f6a8e 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -72,7 +72,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LSA_INFO_CTR dom; + union lsa_PolicyInformation info; int i; uint32 info_class = 2; @@ -97,15 +97,16 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, goto done; } - result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, - info_class, - &dom); + result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); if (!NT_STATUS_IS_OK(result)) { goto done; } - for (i=0; i < dom.info.id2.count1; i++) { + for (i=0; i < info.audit_events.count; i++) { const char *val = NULL, *policy = NULL; @@ -113,14 +114,15 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, continue; } - val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[i]); + val = audit_policy_str(mem_ctx, info.audit_events.settings[i]); policy = audit_description_str(i); print_auditing_category(policy, val); } done: if (!NT_STATUS_IS_OK(result)) { - d_printf("failed to get auditing policy: %s\n", nt_errstr(result)); + d_printf("failed to get auditing policy: %s\n", + nt_errstr(result)); } return result; @@ -139,7 +141,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LSA_INFO_CTR dom; + union lsa_PolicyInformation info; uint32 info_class = 2; uint32 audit_policy, audit_category; @@ -178,29 +180,32 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, goto done; } - result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, - info_class, - &dom); + result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); if (!NT_STATUS_IS_OK(result)) { goto done; } - dom.info.id2.auditsettings[audit_category] = audit_policy; + info.audit_events.settings[audit_category] = audit_policy; + + result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); - result = rpccli_lsa_set_info_policy(pipe_hnd, mem_ctx, &pol, - info_class, - dom); if (!NT_STATUS_IS_OK(result)) { goto done; } - result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, - info_class, - &dom); - + result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); { - const char *val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[audit_category]); + const char *val = audit_policy_str(mem_ctx, info.audit_events.settings[audit_category]); const char *policy = audit_description_str(audit_category); print_auditing_category(policy, val); } @@ -221,7 +226,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LSA_INFO_CTR dom; + union lsa_PolicyInformation info; uint32 info_class = 2; @@ -233,19 +238,20 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, goto done; } - result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, - info_class, - &dom); - + result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); if (!NT_STATUS_IS_OK(result)) { goto done; } - dom.info.id2.auditing_enabled = enable; + info.audit_events.auditing_mode = enable; - result = rpccli_lsa_set_info_policy(pipe_hnd, mem_ctx, &pol, - info_class, - dom); + result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -300,7 +306,7 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - LSA_INFO_CTR dom; + union lsa_PolicyInformation info; int i; uint32 info_class = 2; @@ -313,16 +319,16 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, goto done; } - result = rpccli_lsa_query_info_policy_new(pipe_hnd, mem_ctx, &pol, - info_class, - &dom); - + result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, + &pol, + info_class, + &info); if (!NT_STATUS_IS_OK(result)) { goto done; } printf("Auditing:\t\t"); - switch (dom.info.id2.auditing_enabled) { + switch (info.audit_events.auditing_mode) { case True: printf("Enabled"); break; @@ -330,16 +336,16 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, printf("Disabled"); break; default: - printf("unknown (%d)", dom.info.id2.auditing_enabled); + printf("unknown (%d)", info.audit_events.auditing_mode); break; } printf("\n"); - printf("Auditing categories:\t%d\n", dom.info.id2.count1); + printf("Auditing categories:\t%d\n", info.audit_events.count); printf("Auditing settings:\n"); - for (i=0; i < dom.info.id2.count1; i++) { - const char *val = audit_policy_str(mem_ctx, dom.info.id2.auditsettings[i]); + for (i=0; i < info.audit_events.count; i++) { + const char *val = audit_policy_str(mem_ctx, info.audit_events.settings[i]); const char *policy = audit_description_str(i); print_auditing_category(policy, val); } -- cgit From 36a7316bfc9d7582ccd908f2b9d96e0fe983e884 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 14 Jan 2008 18:26:24 +0100 Subject: Some more minor cleanup for "net rpc audit". Guenther (This used to be commit 558ce4ec3eaa93c827316d92c346f35c140fadf0) --- source3/utils/net_rpc_audit.c | 112 ++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 58 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 115f8f6a8e..50bd555f16 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -1,21 +1,21 @@ -/* - Samba Unix/Linux SMB client library - Distributed SMB/CIFS Server Management Utility +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility Copyright (C) 2006 Guenther Deschner 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 the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ - + #include "includes.h" #include "utils/net.h" @@ -54,19 +54,18 @@ static void print_auditing_category(const char *policy, const char *value) pad_len = col_len - strlen(policy); padding[pad_len] = 0; do padding[--pad_len] = ' '; while (pad_len > 0); - + d_printf("\t%s%s%s\n", policy, padding, value); } - /******************************************************************** ********************************************************************/ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -74,9 +73,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; union lsa_PolicyInformation info; int i; - - uint32 info_class = 2; - uint32 audit_category; + uint32_t audit_category; if (argc < 1 || argc > 2) { d_printf("insufficient arguments\n"); @@ -89,7 +86,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, return NT_STATUS_INVALID_PARAMETER; } - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); @@ -99,7 +96,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { @@ -132,19 +129,17 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, ********************************************************************/ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; union lsa_PolicyInformation info; - - uint32 info_class = 2; - uint32 audit_policy, audit_category; + uint32_t audit_policy, audit_category; if (argc < 2 || argc > 3) { d_printf("insufficient arguments\n"); @@ -172,7 +167,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, return NT_STATUS_INVALID_PARAMETER; } - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); @@ -182,7 +177,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { @@ -193,7 +188,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { @@ -202,7 +197,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); { const char *val = audit_policy_str(mem_ctx, info.audit_events.settings[audit_category]); @@ -214,11 +209,14 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, if (!NT_STATUS_IS_OK(result)) { d_printf("failed to set audit policy: %s\n", nt_errstr(result)); } - + return result; } -static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, +/******************************************************************** +********************************************************************/ + +static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *mem_ctx, int argc, const char **argv, @@ -228,9 +226,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; union lsa_PolicyInformation info; - uint32 info_class = 2; - - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); @@ -240,7 +236,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -250,7 +246,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { @@ -259,48 +255,51 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, done: if (!NT_STATUS_IS_OK(result)) { - d_printf("failed to %s audit policy: %s\n", enable ? "enable":"disable", - nt_errstr(result)); + d_printf("failed to %s audit policy: %s\n", + enable ? "enable":"disable", nt_errstr(result)); } return result; } + /******************************************************************** ********************************************************************/ static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { - return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, False); + return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, + false); } /******************************************************************** ********************************************************************/ static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { - return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, True); + return rpc_audit_enable_internal_ext(pipe_hnd, mem_ctx, argc, argv, + true); } /******************************************************************** ********************************************************************/ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, - const char *domain_name, + const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, - TALLOC_CTX *mem_ctx, + TALLOC_CTX *mem_ctx, int argc, const char **argv) { @@ -309,9 +308,7 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, union lsa_PolicyInformation info; int i; - uint32 info_class = 2; - - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, True, + result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, &pol); @@ -321,7 +318,7 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, result = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx, &pol, - info_class, + LSA_POLICY_INFO_AUDIT_EVENTS, &info); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -329,10 +326,10 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, printf("Auditing:\t\t"); switch (info.audit_events.auditing_mode) { - case True: + case true: printf("Enabled"); break; - case False: + case false: printf("Disabled"); break; default: @@ -352,20 +349,19 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, done: if (!NT_STATUS_IS_OK(result)) { - d_printf("failed to list auditing policies: %s\n", nt_errstr(result)); + d_printf("failed to list auditing policies: %s\n", + nt_errstr(result)); } return result; } - - /******************************************************************** ********************************************************************/ static int rpc_audit_get(int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(NULL, PI_LSARPC, 0, rpc_audit_get_internal, argc, argv); } @@ -374,7 +370,7 @@ static int rpc_audit_get(int argc, const char **argv) static int rpc_audit_set(int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(NULL, PI_LSARPC, 0, rpc_audit_set_internal, argc, argv); } @@ -383,7 +379,7 @@ static int rpc_audit_set(int argc, const char **argv) static int rpc_audit_enable(int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(NULL, PI_LSARPC, 0, rpc_audit_enable_internal, argc, argv); } @@ -392,7 +388,7 @@ static int rpc_audit_enable(int argc, const char **argv) static int rpc_audit_disable(int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(NULL, PI_LSARPC, 0, rpc_audit_disable_internal, argc, argv); } @@ -401,14 +397,14 @@ static int rpc_audit_disable(int argc, const char **argv) static int rpc_audit_list(int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(NULL, PI_LSARPC, 0, rpc_audit_list_internal, argc, argv); } /******************************************************************** ********************************************************************/ -int net_rpc_audit(int argc, const char **argv) +int net_rpc_audit(int argc, const char **argv) { struct functable func[] = { {"get", rpc_audit_get}, @@ -418,9 +414,9 @@ int net_rpc_audit(int argc, const char **argv) {"list", rpc_audit_list}, {NULL, NULL} }; - + if (argc) return net_run_function(argc, argv, func, net_help_audit); - + return net_help_audit(argc, argv); } -- cgit From ab38d3dd44f3b9e84ccf03f5293e3f658c31afd2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 8 Feb 2008 02:37:19 +0100 Subject: Fix "net rpc audit" after query info policy idl fix. Guenther (This used to be commit 5c042793ea648849275061e31e3e37d583fe1a47) --- source3/utils/net_rpc_audit.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 50bd555f16..7c2a5b33ca 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -71,7 +71,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - union lsa_PolicyInformation info; + union lsa_PolicyInformation *info = NULL; int i; uint32_t audit_category; @@ -103,7 +103,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, goto done; } - for (i=0; i < info.audit_events.count; i++) { + for (i=0; i < info->audit_events.count; i++) { const char *val = NULL, *policy = NULL; @@ -111,7 +111,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, continue; } - val = audit_policy_str(mem_ctx, info.audit_events.settings[i]); + val = audit_policy_str(mem_ctx, info->audit_events.settings[i]); policy = audit_description_str(i); print_auditing_category(policy, val); } @@ -138,7 +138,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - union lsa_PolicyInformation info; + union lsa_PolicyInformation *info = NULL; uint32_t audit_policy, audit_category; if (argc < 2 || argc > 3) { @@ -184,12 +184,12 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, goto done; } - info.audit_events.settings[audit_category] = audit_policy; + info->audit_events.settings[audit_category] = audit_policy; result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, &pol, LSA_POLICY_INFO_AUDIT_EVENTS, - &info); + info); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -200,7 +200,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, LSA_POLICY_INFO_AUDIT_EVENTS, &info); { - const char *val = audit_policy_str(mem_ctx, info.audit_events.settings[audit_category]); + const char *val = audit_policy_str(mem_ctx, info->audit_events.settings[audit_category]); const char *policy = audit_description_str(audit_category); print_auditing_category(policy, val); } @@ -224,7 +224,7 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - union lsa_PolicyInformation info; + union lsa_PolicyInformation *info = NULL; result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_RIGHTS_MAXIMUM_ALLOWED, @@ -242,12 +242,12 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, goto done; } - info.audit_events.auditing_mode = enable; + info->audit_events.auditing_mode = enable; result = rpccli_lsa_SetInfoPolicy(pipe_hnd, mem_ctx, &pol, LSA_POLICY_INFO_AUDIT_EVENTS, - &info); + info); if (!NT_STATUS_IS_OK(result)) { goto done; @@ -305,7 +305,7 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, { POLICY_HND pol; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; - union lsa_PolicyInformation info; + union lsa_PolicyInformation *info = NULL; int i; result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, @@ -325,7 +325,7 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, } printf("Auditing:\t\t"); - switch (info.audit_events.auditing_mode) { + switch (info->audit_events.auditing_mode) { case true: printf("Enabled"); break; @@ -333,16 +333,16 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, printf("Disabled"); break; default: - printf("unknown (%d)", info.audit_events.auditing_mode); + printf("unknown (%d)", info->audit_events.auditing_mode); break; } printf("\n"); - printf("Auditing categories:\t%d\n", info.audit_events.count); + printf("Auditing categories:\t%d\n", info->audit_events.count); printf("Auditing settings:\n"); - for (i=0; i < info.audit_events.count; i++) { - const char *val = audit_policy_str(mem_ctx, info.audit_events.settings[i]); + for (i=0; i < info->audit_events.count; i++) { + const char *val = audit_policy_str(mem_ctx, info->audit_events.settings[i]); const char *policy = audit_description_str(i); print_auditing_category(policy, val); } -- cgit From 7269a504fdd06fbbe24c2df8e084b41382d71269 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Wed, 27 Feb 2008 19:38:48 +0100 Subject: Add my copyright. Guenther (This used to be commit d078a8757182d84dfd3307a2e1b751cf173aaa97) --- source3/utils/net_rpc_audit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 7c2a5b33ca..a846395bb8 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -1,7 +1,7 @@ /* Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) 2006 Guenther Deschner + Copyright (C) 2006,2008 Guenther Deschner 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 From f5769109447d8da0f09b102d444a816ad97a00dc Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Fri, 9 May 2008 23:22:12 +0200 Subject: net: Remove globals (This used to be commit 1e9319cf88b65a2a8d4f5099a1fe5297e405ed2e) --- source3/utils/net_rpc_audit.c | 47 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index a846395bb8..4ba986464e 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -22,7 +22,7 @@ /******************************************************************** ********************************************************************/ -static int net_help_audit(int argc, const char **argv) +static int net_help_audit(struct net_context *c, int argc, const char **argv) { d_printf("net rpc audit list View configured Auditing policies\n"); d_printf("net rpc audit enable Enable Auditing\n"); @@ -61,7 +61,8 @@ static void print_auditing_category(const char *policy, const char *value) /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_audit_get_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -77,7 +78,7 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, if (argc < 1 || argc > 2) { d_printf("insufficient arguments\n"); - net_help_audit(argc, argv); + net_help_audit(c, argc, argv); return NT_STATUS_INVALID_PARAMETER; } @@ -128,7 +129,8 @@ static NTSTATUS rpc_audit_get_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_audit_set_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -143,7 +145,7 @@ static NTSTATUS rpc_audit_set_internal(const DOM_SID *domain_sid, if (argc < 2 || argc > 3) { d_printf("insufficient arguments\n"); - net_help_audit(argc, argv); + net_help_audit(c, argc, argv); return NT_STATUS_INVALID_PARAMETER; } @@ -265,7 +267,8 @@ static NTSTATUS rpc_audit_enable_internal_ext(struct rpc_pipe_client *pipe_hnd, /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_audit_disable_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -280,7 +283,8 @@ static NTSTATUS rpc_audit_disable_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_audit_enable_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -295,7 +299,8 @@ static NTSTATUS rpc_audit_enable_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, +static NTSTATUS rpc_audit_list_internal(struct net_context *c, + const DOM_SID *domain_sid, const char *domain_name, struct cli_state *cli, struct rpc_pipe_client *pipe_hnd, @@ -359,52 +364,52 @@ static NTSTATUS rpc_audit_list_internal(const DOM_SID *domain_sid, /******************************************************************** ********************************************************************/ -static int rpc_audit_get(int argc, const char **argv) +static int rpc_audit_get(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_get_internal, argc, argv); } /******************************************************************** ********************************************************************/ -static int rpc_audit_set(int argc, const char **argv) +static int rpc_audit_set(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_set_internal, argc, argv); } /******************************************************************** ********************************************************************/ -static int rpc_audit_enable(int argc, const char **argv) +static int rpc_audit_enable(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_enable_internal, argc, argv); } /******************************************************************** ********************************************************************/ -static int rpc_audit_disable(int argc, const char **argv) +static int rpc_audit_disable(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_disable_internal, argc, argv); } /******************************************************************** ********************************************************************/ -static int rpc_audit_list(int argc, const char **argv) +static int rpc_audit_list(struct net_context *c, int argc, const char **argv) { - return run_rpc_command(NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_list_internal, argc, argv); } /******************************************************************** ********************************************************************/ -int net_rpc_audit(int argc, const char **argv) +int net_rpc_audit(struct net_context *c, int argc, const char **argv) { struct functable func[] = { {"get", rpc_audit_get}, @@ -416,7 +421,7 @@ int net_rpc_audit(int argc, const char **argv) }; if (argc) - return net_run_function(argc, argv, func, net_help_audit); + return net_run_function(c, argc, argv, func, net_help_audit); - return net_help_audit(argc, argv); + return net_help_audit(c, argc, argv); } -- cgit From 238c7d0be3a26e27c184ad5666438b77ddc68771 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Wed, 21 May 2008 10:31:14 +0200 Subject: net: Make "net rpc audit" use functable3 (This used to be commit c47ff2bff6d97a5e7654849965253928a825fe6a) --- source3/utils/net_rpc_audit.c | 89 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 11 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 4ba986464e..74e7cc5f0b 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -366,6 +366,13 @@ static NTSTATUS rpc_audit_list_internal(struct net_context *c, static int rpc_audit_get(struct net_context *c, int argc, const char **argv) { + if (c->display_usage) { + d_printf("Usage:\n" + "net rpc audit get\n" + " View configured audit setting\n"); + return 0; + } + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_get_internal, argc, argv); } @@ -375,6 +382,13 @@ static int rpc_audit_get(struct net_context *c, int argc, const char **argv) static int rpc_audit_set(struct net_context *c, int argc, const char **argv) { + if (c->display_usage) { + d_printf("Usage:\n" + "net rpc audit set\n" + " Set audit policies\n"); + return 0; + } + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_set_internal, argc, argv); } @@ -384,6 +398,13 @@ static int rpc_audit_set(struct net_context *c, int argc, const char **argv) static int rpc_audit_enable(struct net_context *c, int argc, const char **argv) { + if (c->display_usage) { + d_printf("Usage:\n" + "net rpc audit enable\n" + " Enable auditing\n"); + return 0; + } + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_enable_internal, argc, argv); } @@ -393,6 +414,13 @@ static int rpc_audit_enable(struct net_context *c, int argc, const char **argv) static int rpc_audit_disable(struct net_context *c, int argc, const char **argv) { + if (c->display_usage) { + d_printf("Usage:\n" + "net rpc audit disable\n" + " Disable auditing\n"); + return 0; + } + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_disable_internal, argc, argv); } @@ -402,6 +430,13 @@ static int rpc_audit_disable(struct net_context *c, int argc, const char **argv) static int rpc_audit_list(struct net_context *c, int argc, const char **argv) { + if (c->display_usage) { + d_printf("Usage:\n" + "net rpc audit list\n" + " List auditing settings\n"); + return 0; + } + return run_rpc_command(c, NULL, PI_LSARPC, 0, rpc_audit_list_internal, argc, argv); } @@ -411,17 +446,49 @@ static int rpc_audit_list(struct net_context *c, int argc, const char **argv) int net_rpc_audit(struct net_context *c, int argc, const char **argv) { - struct functable func[] = { - {"get", rpc_audit_get}, - {"set", rpc_audit_set}, - {"enable", rpc_audit_enable}, - {"disable", rpc_audit_disable}, - {"list", rpc_audit_list}, - {NULL, NULL} + struct functable3 func[] = { + { + "get", + rpc_audit_get, + NET_TRANSPORT_RPC, + "View configured auditing settings", + "net rpc audit get\n" + " View configured auditing settings" + }, + { + "set", + rpc_audit_set, + NET_TRANSPORT_RPC, + "Set auditing policies", + "net rpc audit set\n" + " Set auditing policies" + }, + { + "enable", + rpc_audit_enable, + NET_TRANSPORT_RPC, + "Enable auditing", + "net rpc audit enable\n" + " Enable auditing" + }, + { + "disable", + rpc_audit_disable, + NET_TRANSPORT_RPC, + "Disable auditing", + "net rpc audit disable\n" + " Disable auditing" + }, + { + "list", + rpc_audit_list, + NET_TRANSPORT_RPC, + "List configured auditing settings", + "net rpc audit list\n" + " List configured auditing settings" + }, + {NULL, NULL, 0, NULL, NULL} }; - if (argc) - return net_run_function(c, argc, argv, func, net_help_audit); - - return net_help_audit(c, argc, argv); + return net_run_function3(c, argc, argv, "net rpc audit", func); } -- cgit From 255bdb26025a5025bc60637dd924f6ec71c49ee5 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Sat, 7 Jun 2008 02:25:08 +0200 Subject: net: Rename functable3 to functable, get rid of old functables (This used to be commit bb7c5fc4ec77db4073d3beccf12af12910b6bd07) --- source3/utils/net_rpc_audit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 74e7cc5f0b..5a5110fadc 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -446,7 +446,7 @@ static int rpc_audit_list(struct net_context *c, int argc, const char **argv) int net_rpc_audit(struct net_context *c, int argc, const char **argv) { - struct functable3 func[] = { + struct functable func[] = { { "get", rpc_audit_get, @@ -490,5 +490,5 @@ int net_rpc_audit(struct net_context *c, int argc, const char **argv) {NULL, NULL, 0, NULL, NULL} }; - return net_run_function3(c, argc, argv, "net rpc audit", func); + return net_run_function(c, argc, argv, "net rpc audit", func); } -- cgit From f23567fcb9d626c29603430a9cedd899e56ded32 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 Jul 2008 18:36:31 +0200 Subject: Refactoring: run_rpc_command uses ndr_syntax_id instead of pipe_idx (This used to be commit 850166ec0d17eb85a0c921dc3b966fac0677af4a) --- source3/utils/net_rpc_audit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source3/utils/net_rpc_audit.c') diff --git a/source3/utils/net_rpc_audit.c b/source3/utils/net_rpc_audit.c index 5a5110fadc..dc4c796c17 100644 --- a/source3/utils/net_rpc_audit.c +++ b/source3/utils/net_rpc_audit.c @@ -373,7 +373,7 @@ static int rpc_audit_get(struct net_context *c, int argc, const char **argv) return 0; } - return run_rpc_command(c, NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0, rpc_audit_get_internal, argc, argv); } @@ -389,7 +389,7 @@ static int rpc_audit_set(struct net_context *c, int argc, const char **argv) return 0; } - return run_rpc_command(c, NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0, rpc_audit_set_internal, argc, argv); } @@ -405,7 +405,7 @@ static int rpc_audit_enable(struct net_context *c, int argc, const char **argv) return 0; } - return run_rpc_command(c, NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0, rpc_audit_enable_internal, argc, argv); } @@ -421,7 +421,7 @@ static int rpc_audit_disable(struct net_context *c, int argc, const char **argv) return 0; } - return run_rpc_command(c, NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0, rpc_audit_disable_internal, argc, argv); } @@ -437,7 +437,7 @@ static int rpc_audit_list(struct net_context *c, int argc, const char **argv) return 0; } - return run_rpc_command(c, NULL, PI_LSARPC, 0, + return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0, rpc_audit_list_internal, argc, argv); } -- cgit