From 1b9c519dc964791273186cced8d17fd9c7793ce9 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 31 May 2002 17:03:48 +0000 Subject: Enable net rpc share and net rpc file commands (list subcommands only), and autoselect for this subcommand when appropriate. (This used to be commit 77418256d3162b41a672a25f7e512999f1193926) --- source3/utils/net.c | 26 ++++-- source3/utils/net.h | 3 + source3/utils/net_help.c | 56 ++++++++++--- source3/utils/net_rap.c | 39 ++------- source3/utils/net_rpc.c | 200 ++++++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 271 insertions(+), 53 deletions(-) (limited to 'source3/utils') diff --git a/source3/utils/net.c b/source3/utils/net.c index b6998efdf7..e132b8d6e3 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -297,10 +297,8 @@ static int net_group(int argc, const char **argv) if (net_ads_check() == 0) return net_ads_group(argc, argv); - - /* if server is not specified, default to PDC? */ - /* not implemented yet if (net_rpc_check(NET_FLAGS_PDC)) - return net_rpc_group(argc, argv); */ + if (argc == 0 && net_rpc_check(NET_FLAGS_PDC)) + return net_rpc_group(argc, argv); return net_rap_group(argc, argv); } @@ -316,6 +314,22 @@ static int net_join(int argc, const char **argv) return net_rpc_join(argc, argv); } +static int net_share(int argc, const char **argv) +{ + /* only share list is implemented in RPC */ + if (argc == 0 && net_rpc_check(0)) + return net_rpc_share(argc, argv); + return net_rap_share(argc, argv); +} + +static int net_file(int argc, const char **argv) +{ + /* only file list is implemented in RPC */ + if (argc == 0 && net_rpc_check(0)) + return net_rpc_file(argc, argv); + return net_rap_file(argc, argv); +} + /* main function table */ static struct functable net_func[] = { {"RPC", net_rpc}, @@ -323,8 +337,8 @@ static struct functable net_func[] = { {"ADS", net_ads}, /* eventually these should auto-choose the transport ... */ - {"FILE", net_rap_file}, - {"SHARE", net_rap_share}, + {"FILE", net_file}, + {"SHARE", net_share}, {"SESSION", net_rap_session}, {"SERVER", net_rap_server}, {"DOMAIN", net_rap_domain}, diff --git a/source3/utils/net.h b/source3/utils/net.h index af6f153f7b..5a53740679 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -49,3 +49,6 @@ extern char *opt_host; extern char *opt_user_name; extern char *opt_password; extern BOOL opt_user_specified; + +extern const char *share_type[]; + diff --git a/source3/utils/net_help.c b/source3/utils/net_help.c index 31065a26b8..18a89a9cb7 100644 --- a/source3/utils/net_help.c +++ b/source3/utils/net_help.c @@ -63,12 +63,12 @@ static int help_usage(int argc, const char **argv) int net_help_user(int argc, const char **argv) { - d_printf("\nnet [method] user [misc. options] [targets]\n\tList users\n"); - d_printf("\nnet [method] user DELETE [misc. options] [targets]"\ + d_printf("\nnet user [misc. options] [targets]\n\tList users\n"); + d_printf("\nnet user DELETE [misc. options] [targets]"\ "\n\tDelete specified user\n"); - d_printf("\nnet [method] user INFO [misc. options] [targets]"\ + d_printf("\nnet user INFO [misc. options] [targets]"\ "\n\tList the domain groups of the specified user\n"); - d_printf("\nnet [method] user ADD [-F user flags] [misc. options]"\ + d_printf("\nnet user ADD [password] [-F user flags] [misc. options]"\ " [targets]\n\tAdd specified user\n"); net_common_methods_usage(argc, argv); @@ -80,11 +80,11 @@ int net_help_user(int argc, const char **argv) int net_help_group(int argc, const char **argv) { - d_printf("net [method] group [misc. options] [targets]"\ + d_printf("net group [misc. options] [targets]"\ "\n\tList user groups\n\n"); - d_printf("net [method] group DELETE [misc. options] [targets]"\ + d_printf("net group DELETE [misc. options] [targets]"\ "\n\tDelete specified group\n"); - d_printf("\nnet [method] group ADD [-C comment]"\ + d_printf("\nnet group ADD [-C comment]"\ " [misc. options] [targets]\n\tCreate specified group\n"); net_common_methods_usage(argc, argv); net_common_flags_usage(argc, argv); @@ -93,6 +93,38 @@ int net_help_group(int argc, const char **argv) return -1; } +int net_help_share(int argc, const char **argv) +{ + d_printf( + "\nnet share [misc. options] [targets] \n" + "\tenumerates all exported resources (network shares) " + "on target server\n" + "\nnet [rap] share ADD [misc. options] [targets]" + "\n\tAdds a share from a server (makes the export active)\n" + "\nnet [rap] share DELETE [misc. options] [targets]\n" + "\n\tDeletes a share from a server (makes the export inactive)\n"); + net_common_methods_usage(argc, argv); + net_common_flags_usage(argc, argv); + d_printf( + "\t-C or --comment=\tdescriptive comment (for add only)\n" + "\t-M or --maxusers=\t\tmax users allowed for share\n"); + return -1; +} + +int net_help_file(int argc, const char **argv) +{ + d_printf("net file [misc. options] [targets]\n"\ + "\tlists all open files on file server\n\n"); + d_printf("net [rap] file USER [misc. options] [targets]\n"\ + "\tlists all files opened by username on file server\n\n"); + d_printf("net [rap] file CLOSE [misc. options] [targets]\n"\ + "\tcloses specified file on target server\n"); + + net_common_methods_usage(argc, argv); + net_common_flags_usage(argc, argv); + return -1; +} + static int net_usage(int argc, const char **argv) { d_printf(" net time\t\tto view or set time information\n"\ @@ -101,9 +133,9 @@ static int net_usage(int argc, const char **argv) " net group\t\tto manage groups\n"\ " net join\t\tto join a domain\n"\ "\n"\ - " net ads [command]\tto run ADS commands\n"\ - " net rap [command]\tto run RAP (pre-RPC) commands\n"\ - " net rpc [command]\tto run RPC commands\n"\ + " net ads \tto run ADS commands\n"\ + " net rap \tto run RAP (pre-RPC) commands\n"\ + " net rpc \tto run RPC commands\n"\ "\n"\ "Type \"net help