summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-01-18 16:37:05 +0100
committerGünther Deschner <gd@samba.org>2011-02-02 19:03:20 +0100
commit8055bc82b0949473e3defa3cd419713525967424 (patch)
treecd25fd4e783ef340811ec29acfd5099fe6f990e5 /source3
parent32064346f08ee936f41a6114c2226664055e036e (diff)
downloadsamba-8055bc82b0949473e3defa3cd419713525967424.tar.gz
samba-8055bc82b0949473e3defa3cd419713525967424.tar.bz2
samba-8055bc82b0949473e3defa3cd419713525967424.zip
s3-net: use status variable in "net rpc rights".
Guenther
Diffstat (limited to 'source3')
-rw-r--r--source3/utils/net_rpc_rights.c190
1 files changed, 95 insertions, 95 deletions
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<sid_array.num_sids; i++ ) {
- result = check_privilege_for_user(pipe_hnd, ctx, pol,
+ status = check_privilege_for_user(pipe_hnd, ctx, pol,
sid_array.sids[i].sid,
privilege);
- if ( ! NT_STATUS_IS_OK(result)) {
- if ( ! NT_STATUS_EQUAL(result, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
- return result;
+ if ( ! NT_STATUS_IS_OK(status)) {
+ if ( ! NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
+ return status;
}
continue;
}
/* try to convert the SID to a name. Fall back to
printing the raw SID if necessary */
- result = sid_to_name( pipe_hnd, ctx, sid_array.sids[i].sid, name );
- if ( !NT_STATUS_IS_OK (result) )
+ status = sid_to_name( pipe_hnd, ctx, sid_array.sids[i].sid, name );
+ if ( !NT_STATUS_IS_OK (status) )
sid_to_fstring(name, sid_array.sids[i].sid);
d_printf(" %s\n", name);
@@ -271,37 +271,37 @@ static NTSTATUS enum_privileges_for_accounts(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;
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;
for ( i=0; i<sid_array.num_sids; i++ ) {
/* try to convert the SID to a name. Fall back to
printing the raw SID if necessary */
- result = sid_to_name(pipe_hnd, ctx, sid_array.sids[i].sid, name);
- if ( !NT_STATUS_IS_OK (result) )
+ status = sid_to_name(pipe_hnd, ctx, sid_array.sids[i].sid, name);
+ if ( !NT_STATUS_IS_OK (status) )
sid_to_fstring(name, sid_array.sids[i].sid);
d_printf("%s\n", name);
- result = enum_privileges_for_user(pipe_hnd, ctx, pol,
+ status = enum_privileges_for_user(pipe_hnd, ctx, pol,
sid_array.sids[i].sid);
- if ( !NT_STATUS_IS_OK(result) )
- return result;
+ if ( !NT_STATUS_IS_OK(status) )
+ return status;
d_printf("\n");
}
@@ -322,7 +322,7 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
const char **argv )
{
struct policy_handle pol;
- NTSTATUS result;
+ NTSTATUS status;
struct dom_sid sid;
fstring privname;
struct lsa_String lsa_name;
@@ -331,16 +331,16 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
uint16 lang_id_sys = 0;
uint16 lang_id_desc;
- 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;
/* backwards compatibility; just list available privileges if no arguement */
if (argc == 0) {
- result = enum_privileges(pipe_hnd, mem_ctx, &pol );
+ status = enum_privileges(pipe_hnd, mem_ctx, &pol );
goto done;
}
@@ -348,7 +348,7 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
int i = 1;
if (argv[1] == NULL) {
- result = enum_privileges(pipe_hnd, mem_ctx, &pol );
+ status = enum_privileges(pipe_hnd, mem_ctx, &pol );
goto done;
}
@@ -358,7 +358,7 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
i++;
/* verify that this is a valid privilege for error reporting */
- result = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, mem_ctx,
+ status = rpccli_lsa_LookupPrivDisplayName(pipe_hnd, mem_ctx,
&pol,
&lsa_name,
lang_id,
@@ -366,23 +366,23 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
&description,
&lang_id_desc);
- if ( !NT_STATUS_IS_OK(result) ) {
- if ( NT_STATUS_EQUAL( result, NT_STATUS_NO_SUCH_PRIVILEGE ) )
+ if ( !NT_STATUS_IS_OK(status) ) {
+ if ( NT_STATUS_EQUAL( status, NT_STATUS_NO_SUCH_PRIVILEGE ) )
d_fprintf(stderr, _("No such privilege "
"exists: %s.\n"), privname);
else
d_fprintf(stderr, _("Error resolving "
"privilege display name "
"[%s].\n"),
- nt_errstr(result));
+ nt_errstr(status));
continue;
}
- result = enum_accounts_for_privilege(pipe_hnd, mem_ctx, &pol, privname);
- if (!NT_STATUS_IS_OK(result)) {
+ status = enum_accounts_for_privilege(pipe_hnd, mem_ctx, &pol, privname);
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, _("Error enumerating "
"accounts for privilege %s [%s].\n"),
- privname, nt_errstr(result));
+ privname, nt_errstr(status));
continue;
}
}
@@ -395,17 +395,17 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
int i = 1;
if (argv[1] == NULL) {
- result = enum_privileges_for_accounts(pipe_hnd, mem_ctx, &pol);
+ status = enum_privileges_for_accounts(pipe_hnd, mem_ctx, &pol);
goto done;
}
while (argv[i] != NULL) {
- result = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[i]);
- if (!NT_STATUS_IS_OK(result)) {
+ status = name_to_sid(pipe_hnd, mem_ctx, &sid, argv[i]);
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
}
- result = enum_privileges_for_user(pipe_hnd, mem_ctx, &pol, &sid);
- if (!NT_STATUS_IS_OK(result)) {
+ status = enum_privileges_for_user(pipe_hnd, mem_ctx, &pol, &sid);
+ if (!NT_STATUS_IS_OK(status)) {
goto done;
}
i++;
@@ -418,20 +418,20 @@ static NTSTATUS rpc_rights_list_internal(struct net_context *c,
if (argc > 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;
}