From 10d03317544a070bf91c3249b45acea9e5fa8836 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 19 Oct 2001 16:51:26 +0000 Subject: Add command-line remote management utility (This used to be commit 50c243518aa7996e697876096073598a3b5a8d3a) --- source3/utils/net.c | 1510 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1510 insertions(+) create mode 100644 source3/utils/net.c (limited to 'source3/utils/net.c') diff --git a/source3/utils/net.c b/source3/utils/net.c new file mode 100644 index 0000000000..93214dda5a --- /dev/null +++ b/source3/utils/net.c @@ -0,0 +1,1510 @@ +/* + Samba Unix/Linux SMB client library + Version 3.0 + Distributed SMB/CIFS Server Management Utility + Copyright (C) 2001 Steve French (sfrench@us.ibm.com) + Copyright (C) 2001 Jim McDonough (jmcd@us.ibm.com) + + connect_to_ipc based on similar routine + Copyright (C) Andrew Tridgell 1994-1998 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/*****************************************************/ +/* */ +/* Distributed SMB/CIFS Server Management Utility */ +/* */ +/* The intent was to make the syntax similar */ +/* to the NET utility (first developed in DOS */ +/* with additional interesting & useful functions */ +/* added in later SMB server network operating */ +/* systems). */ +/* */ +/*****************************************************/ + +#include +#include + +/***********************************************************************/ +/* Beginning of internationalization section. Translatable constants */ +/* should be kept in this area and referenced in the rest of the code. */ +/* */ +/* No functions, outside of Samba or LSB (Linux Standards Base) should */ +/* be used (if possible). */ +/***********************************************************************/ + +typedef struct _functable { + int func; + char funcname[12]; +} functable; + +/* functions available */ +#define FILEF 1 +#define SHAREF 2 +#define SESSIONF 3 +#define SERVERF 4 +#define DOMAINF 5 +#define PRINTQF 6 +#define USERF 7 +#define GROUPF 8 +#define VALIDATEF 9 +#define GROUPMEMBERF 10 +#define HELPF 11 + +const functable net_func[] = { + { FILEF, "FILE"}, + { SHAREF, "SHARE"}, + { SESSIONF, "SESSION"}, + { SERVERF, "SERVER"}, + { DOMAINF, "DOMAIN"}, + { PRINTQF, "PRINTQ"}, + { USERF, "USER"}, + { GROUPF, "GROUP"}, + { VALIDATEF, "VALIDATE"}, + { GROUPMEMBERF, "GROUPMEMBER"}, + { HELPF, "HELP"} +}; + +/* subfunctions available */ +#define OTHER_SF 0 +#define LIST_SF 1 /* enumerate */ +#define ADD_SF 2 /* also used for create and start */ +#define DELETE_SF 3 /* also used for close and stop */ +#define INFO_SF 4 /* get information */ + +const functable net_subfunc[] = { + { LIST_SF, "LIST" }, + { LIST_SF, "ENUMERATE" }, + { ADD_SF, "ADD" }, + { ADD_SF, "CREATE" }, + { DELETE_SF, "CLOSE" }, + { DELETE_SF, "DELETE" } +}; + +const char share_type[][6] = { + "Disk", + "Print", + "Dev", + "IPC" +}; + +#define PASSWORD_PROMPT "Password: " +#define YES_STRING "Yes" +#define NO_STRING "No" + +#define NET_USAGE \ + "\nUsage: \n"\ + " net domain \tto list domains \n"\ + " net file \tto list open files on a server \n"\ + " net group \tto list user groups \n"\ + " net groupmember to list users in a group \n"\ + " net printq \tto list the print queues on a server\n"\ + " net server \tto list servers in a domain\n"\ + " net session \tto list clients with open sessions to a server\n"\ + " net share \tto list shares exported by a server\n"\ + " net user \tto list users\n"\ + " net validate \tto check whether a user and the corresponding password are valid\n"\ + " net help\n"\ + "\nType \"net help