From 8055bc82b0949473e3defa3cd419713525967424 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 18 Jan 2011 16:37:05 +0100 Subject: s3-net: use status variable in "net rpc rights". Guenther --- source3/utils/net_rpc_rights.c | 190 ++++++++++++++++++++--------------------- 1 file changed, 95 insertions(+), 95 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net_rpc_rights.c b/source3/utils/net_rpc_rights.c index 5d962dea31..d1eb405c8f 100644 --- a/source3/utils/net_rpc_rights.c +++ b/source3/utils/net_rpc_rights.c @@ -34,18 +34,18 @@ static NTSTATUS sid_to_name(struct rpc_pipe_client *pipe_hnd, { struct policy_handle pol; enum lsa_SidType *sid_types = NULL; - NTSTATUS result; + NTSTATUS status; char **domains = NULL, **names = NULL; - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, + status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_FLAG_MAXIMUM_ALLOWED, &pol); - if ( !NT_STATUS_IS_OK(result) ) - return result; + if ( !NT_STATUS_IS_OK(status) ) + return status; - result = rpccli_lsa_lookup_sids(pipe_hnd, mem_ctx, &pol, 1, sid, &domains, &names, &sid_types); + status = rpccli_lsa_lookup_sids(pipe_hnd, mem_ctx, &pol, 1, sid, &domains, &names, &sid_types); - if ( NT_STATUS_IS_OK(result) ) { + if ( NT_STATUS_IS_OK(status) ) { if ( *domains[0] ) fstr_sprintf( name, "%s\\%s", domains[0], names[0] ); else @@ -53,7 +53,7 @@ static NTSTATUS sid_to_name(struct rpc_pipe_client *pipe_hnd, } rpccli_lsa_Close(pipe_hnd, mem_ctx, &pol); - return result; + return status; } /******************************************************************** @@ -65,7 +65,7 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *pipe_hnd, { struct policy_handle pol; enum lsa_SidType *sid_types; - NTSTATUS result; + NTSTATUS status; struct dom_sid *sids; /* maybe its a raw SID */ @@ -73,20 +73,20 @@ static NTSTATUS name_to_sid(struct rpc_pipe_client *pipe_hnd, return NT_STATUS_OK; } - result = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, + status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true, SEC_FLAG_MAXIMUM_ALLOWED, &pol); - if ( !NT_STATUS_IS_OK(result) ) - return result; + if ( !NT_STATUS_IS_OK(status) ) + return status; - result = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &pol, 1, &name, + status = rpccli_lsa_lookup_names(pipe_hnd, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types); - if ( NT_STATUS_IS_OK(result) ) + if ( NT_STATUS_IS_OK(status) ) sid_copy( sid, &sids[0] ); rpccli_lsa_Close(pipe_hnd, mem_ctx, &pol); - return result; + return status; } /******************************************************************** @@ -96,7 +96,7 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, TALLOC_CTX *ctx, struct policy_handle *pol ) { - NTSTATUS result; + NTSTATUS status; uint32 enum_context = 0; uint32 pref_max_length=0x1000; int i; @@ -106,14 +106,14 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, struct lsa_StringLarge *description = NULL; struct lsa_PrivArray priv_array; - result = rpccli_lsa_EnumPrivs(pipe_hnd, ctx, + status = rpccli_lsa_EnumPrivs(pipe_hnd, ctx, pol, &enum_context, &priv_array, pref_max_length); - if ( !NT_STATUS_IS_OK(result) ) - return result; + if ( !NT_STATUS_IS_OK(status) ) + return status; /* Print results */ @@ -128,7 +128,7 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, init_lsa_String(&lsa_name, priv_array.privs[i].name.string); - result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, ctx, + status = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, ctx, pol, &lsa_name, lang_id, @@ -136,7 +136,7 @@ static NTSTATUS enum_privileges(struct rpc_pipe_client *pipe_hnd, &description, &lang_id_desc); - if (!NT_STATUS_IS_OK(result)) { + if (!NT_STATUS_IS_OK(status)) { d_printf("??????\n"); continue; } @@ -156,17 +156,17 @@ static NTSTATUS check_privilege_for_user(struct rpc_pipe_client *pipe_hnd, struct dom_sid *sid, const char *right) { - NTSTATUS result; + NTSTATUS status; struct lsa_RightSet rights; int i; - result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + status = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, pol, sid, &rights); - if (!NT_STATUS_IS_OK(result)) { - return result; + if (!NT_STATUS_IS_OK(status)) { + return status; } if (rights.count == 0) { @@ -190,17 +190,17 @@ static NTSTATUS enum_privileges_for_user(struct rpc_pipe_client *pipe_hnd, struct policy_handle *pol, struct dom_sid *sid ) { - NTSTATUS result; + NTSTATUS status; struct lsa_RightSet rights; int i; - result = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, + status = rpccli_lsa_EnumAccountRights(pipe_hnd, ctx, pol, sid, &rights); - if (!NT_STATUS_IS_OK(result)) - return result; + if (!NT_STATUS_IS_OK(status)) + return status; if (rights.count == 0) { d_printf(_("No privileges assigned\n")); @@ -221,41 +221,41 @@ static NTSTATUS enum_accounts_for_privilege(struct rpc_pipe_client *pipe_hnd, struct policy_handle *pol, const char *privilege) { - NTSTATUS result; + NTSTATUS status; uint32 enum_context=0; uint32 pref_max_length=0x1000; struct lsa_SidArray sid_array; int i; fstring name; - result = rpccli_lsa_EnumAccounts(pipe_hnd, ctx, + status = rpccli_lsa_EnumAccounts(pipe_hnd, ctx, pol, &enum_context, &sid_array, pref_max_length); - if (!NT_STATUS_IS_OK(result)) - return result; + if (!NT_STATUS_IS_OK(status)) + return status; d_printf("%s:\n", privilege); for ( i=0; i 1) { d_printf("%s net rpc rights list [[accounts|privileges] " "[name|SID]]\n", _("Usage:")); - result = NT_STATUS_OK; + status = NT_STATUS_OK; goto done; } - result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); - if (!NT_STATUS_IS_OK(result)) { + status = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); + if (!NT_STATUS_IS_OK(status)) { goto done; } - result = enum_privileges_for_user(pipe_hnd, mem_ctx, &pol, &sid ); + status = enum_privileges_for_user(pipe_hnd, mem_ctx, &pol, &sid ); done: rpccli_lsa_Close(pipe_hnd, mem_ctx, &pol); - return result; + return status; } /******************************************************************** @@ -447,7 +447,7 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c, const char **argv ) { struct policy_handle dom_pol; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct lsa_RightSet rights; int i; @@ -460,19 +460,19 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c, return NT_STATUS_OK; } - result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); - if (NT_STATUS_EQUAL(result, NT_STATUS_NONE_MAPPED)) - result = NT_STATUS_NO_SUCH_USER; + status = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); + if (NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) + status = NT_STATUS_NO_SUCH_USER; - if (!NT_STATUS_IS_OK(result)) + if (!NT_STATUS_IS_OK(status)) goto done; - result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, + status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_FLAG_MAXIMUM_ALLOWED, &dom_pol); - if (!NT_STATUS_IS_OK(result)) - return result; + if (!NT_STATUS_IS_OK(status)) + return status; rights.count = argc-1; rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, @@ -485,25 +485,25 @@ static NTSTATUS rpc_rights_grant_internal(struct net_context *c, init_lsa_StringLarge(&rights.names[i], argv[i+1]); } - result = rpccli_lsa_AddAccountRights(pipe_hnd, mem_ctx, + status = rpccli_lsa_AddAccountRights(pipe_hnd, mem_ctx, &dom_pol, &sid, &rights); - if (!NT_STATUS_IS_OK(result)) + if (!NT_STATUS_IS_OK(status)) goto done; d_printf(_("Successfully granted rights.\n")); done: - if ( !NT_STATUS_IS_OK(result) ) { + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr, _("Failed to grant privileges for %s (%s)\n"), - argv[0], nt_errstr(result)); + argv[0], nt_errstr(status)); } rpccli_lsa_Close(pipe_hnd, mem_ctx, &dom_pol); - return result; + return status; } /******************************************************************** @@ -519,7 +519,7 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c, const char **argv ) { struct policy_handle dom_pol; - NTSTATUS result = NT_STATUS_UNSUCCESSFUL; + NTSTATUS status = NT_STATUS_UNSUCCESSFUL; struct lsa_RightSet rights; struct dom_sid sid; int i; @@ -531,16 +531,16 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c, return NT_STATUS_OK; } - result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); - if (!NT_STATUS_IS_OK(result)) - return result; + status = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[0]); + if (!NT_STATUS_IS_OK(status)) + return status; - result = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, + status = rpccli_lsa_open_policy2(pipe_hnd, mem_ctx, true, SEC_FLAG_MAXIMUM_ALLOWED, &dom_pol); - if (!NT_STATUS_IS_OK(result)) - return result; + if (!NT_STATUS_IS_OK(status)) + return status; rights.count = argc-1; rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge, @@ -553,26 +553,26 @@ static NTSTATUS rpc_rights_revoke_internal(struct net_context *c, init_lsa_StringLarge(&rights.names[i], argv[i+1]); } - result = rpccli_lsa_RemoveAccountRights(pipe_hnd, mem_ctx, + status = rpccli_lsa_RemoveAccountRights(pipe_hnd, mem_ctx, &dom_pol, &sid, false, &rights); - if (!NT_STATUS_IS_OK(result)) + if (!NT_STATUS_IS_OK(status)) goto done; d_printf(_("Successfully revoked rights.\n")); done: - if ( !NT_STATUS_IS_OK(result) ) { + if ( !NT_STATUS_IS_OK(status) ) { d_fprintf(stderr,_("Failed to revoke privileges for %s (%s)\n"), - argv[0], nt_errstr(result)); + argv[0], nt_errstr(status)); } rpccli_lsa_Close(pipe_hnd, mem_ctx, &dom_pol); - return result; + return status; } -- cgit