summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-01-14 18:26:24 +0100
committerGünther Deschner <gd@samba.org>2008-01-14 18:39:15 +0100
commit36a7316bfc9d7582ccd908f2b9d96e0fe983e884 (patch)
tree0d93729b8cf0ad84a8a18bdfc9ef88d267e166c7 /source3
parenta32cca7f372217e483ffda059e7775e3327982cc (diff)
downloadsamba-36a7316bfc9d7582ccd908f2b9d96e0fe983e884.tar.gz
samba-36a7316bfc9d7582ccd908f2b9d96e0fe983e884.tar.bz2
samba-36a7316bfc9d7582ccd908f2b9d96e0fe983e884.zip
Some more minor cleanup for "net rpc audit".
Guenther (This used to be commit 558ce4ec3eaa93c827316d92c346f35c140fadf0)
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_rpc_audit.c112
1 files changed, 54 insertions, 58 deletions
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 <http://www.gnu.org/licenses/>. */
-
+
#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);
}