Refactoring: net_sh_run uses ndr_syntax_id instead of pipe_idx
[kai/samba.git] / source3 / utils / net_rpc_rights.c
index 7a969a7a634844e9ba5253fc29b3f21903fc2e25..2bc5efe3cf6066a53c9d2d7c3a92ce092db4e319 100644 (file)
@@ -564,7 +564,15 @@ done:
 
 static int rpc_rights_list(struct net_context *c, int argc, const char **argv )
 {
-       return run_rpc_command(c, NULL, PI_LSARPC, 0,
+       if (c->display_usage) {
+               d_printf("Usage:\n"
+                        "net rpc rights list [{accounts|privileges} "
+                        "[name|SID]]\n"
+                        "    View available/assigned privileges\n");
+               return 0;
+       }
+
+       return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
                rpc_rights_list_internal, argc, argv );
 }
 
@@ -573,7 +581,19 @@ static int rpc_rights_list(struct net_context *c, int argc, const char **argv )
 
 static int rpc_rights_grant(struct net_context *c, int argc, const char **argv )
 {
-       return run_rpc_command(c, NULL, PI_LSARPC, 0,
+       if (c->display_usage) {
+               d_printf("Usage:\n"
+                        "net rpc rights grant <name|SID> <right>\n"
+                        "    Assign privilege[s]\n");
+               d_printf("For example:\n");
+               d_printf("    net rpc rights grant 'VALE\\biddle' "
+                        "SePrintOperatorPrivilege SeDiskOperatorPrivilege\n");
+               d_printf("    would grant the printer admin and disk manager "
+                        "rights to the user 'VALE\\biddle'\n");
+               return 0;
+       }
+
+       return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
                rpc_rights_grant_internal, argc, argv );
 }
 
@@ -582,25 +602,20 @@ static int rpc_rights_grant(struct net_context *c, int argc, const char **argv )
 
 static int rpc_rights_revoke(struct net_context *c, int argc, const char **argv)
 {
-       return run_rpc_command(c, NULL, PI_LSARPC, 0,
-               rpc_rights_revoke_internal, argc, argv );
-}
-
-/********************************************************************
-********************************************************************/
-
-static int net_help_rights(struct net_context *c, int argc, const char **argv )
-{
-       d_printf("net rpc rights list [{accounts|privileges} [name|SID]]   View available or assigned privileges\n");
-       d_printf("net rpc rights grant <name|SID> <right>                  Assign privilege[s]\n");
-       d_printf("net rpc rights revoke <name|SID> <right>                 Revoke privilege[s]\n");
-
-       d_printf("\nBoth 'grant' and 'revoke' require a SID and a list of privilege names.\n");
-       d_printf("For example\n");
-       d_printf("\n  net rpc rights grant 'VALE\\biddle' SePrintOperatorPrivilege SeDiskOperatorPrivilege\n");
-       d_printf("\nwould grant the printer admin and disk manager rights to the user 'VALE\\biddle'\n\n");
+       if (c->display_usage) {
+               d_printf("Usage:\n"
+                        "net rpc rights revoke <name|SID> <right>\n"
+                        "    Revoke privilege[s]\n");
+               d_printf("For example:\n");
+               d_printf("    net rpc rights revoke 'VALE\\biddle' "
+                        "SePrintOperatorPrivilege SeDiskOperatorPrivilege\n");
+               d_printf("    would revoke the printer admin and disk manager "
+                        "rights from the user 'VALE\\biddle'\n");
+               return 0;
+       }
 
-       return -1;
+       return run_rpc_command(c, NULL, &ndr_table_lsarpc.syntax_id, 0,
+               rpc_rights_revoke_internal, argc, argv );
 }
 
 /********************************************************************
@@ -609,16 +624,34 @@ static int net_help_rights(struct net_context *c, int argc, const char **argv )
 int net_rpc_rights(struct net_context *c, int argc, const char **argv)
 {
        struct functable func[] = {
-               {"list", rpc_rights_list},
-               {"grant", rpc_rights_grant},
-               {"revoke", rpc_rights_revoke},
-               {NULL, NULL}
+               {
+                       "list",
+                       rpc_rights_list,
+                       NET_TRANSPORT_RPC,
+                       "View available/assigned privileges",
+                       "net rpc rights list\n"
+                       "    View available/assigned privileges"
+               },
+               {
+                       "grant",
+                       rpc_rights_grant,
+                       NET_TRANSPORT_RPC,
+                       "Assign privilege[s]",
+                       "net rpc rights grant\n"
+                       "    Assign privilege[s]"
+               },
+               {
+                       "revoke",
+                       rpc_rights_revoke,
+                       NET_TRANSPORT_RPC,
+                       "Revoke privilege[s]",
+                       "net rpc rights revoke\n"
+                       "    Revoke privilege[s]"
+               },
+               {NULL, NULL, 0, NULL, NULL}
        };
 
-       if ( argc )
-               return net_run_function(c, argc, argv, func, net_help_rights );
-
-       return net_help_rights(c, argc, argv );
+       return net_run_function(c, argc, argv, "net rpc rights", func);
 }
 
 static NTSTATUS rpc_sh_rights_list(struct net_context *c,
@@ -658,13 +691,13 @@ struct rpc_sh_cmd *net_rpc_rights_cmds(struct net_context *c, TALLOC_CTX *mem_ct
 {
        static struct rpc_sh_cmd cmds[] = {
 
-       { "list", NULL, PI_LSARPC, rpc_sh_rights_list,
+       { "list", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_list,
          "View available or assigned privileges" },
 
-       { "grant", NULL, PI_LSARPC, rpc_sh_rights_grant,
+       { "grant", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_grant,
          "Assign privilege[s]" },
 
-       { "revoke", NULL, PI_LSARPC, rpc_sh_rights_revoke,
+       { "revoke", NULL, &ndr_table_lsarpc.syntax_id, rpc_sh_rights_revoke,
          "Revoke privilege[s]" },
 
        { NULL, NULL, 0, NULL, NULL }