1 | /*
|
---|
2 | Samba Unix/Linux SMB client library
|
---|
3 | net help commands
|
---|
4 | Copyright (C) 2002 Jim McDonough (jmcd@us.ibm.com)
|
---|
5 |
|
---|
6 | This program is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 3 of the License, or
|
---|
9 | (at your option) any later version.
|
---|
10 |
|
---|
11 | This program is distributed in the hope that it will be useful,
|
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | GNU General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | #include "includes.h"
|
---|
21 | #include "utils/net.h"
|
---|
22 |
|
---|
23 | int net_common_methods_usage(int argc, const char**argv)
|
---|
24 | {
|
---|
25 | d_printf("Valid methods: (auto-detected if not specified)\n");
|
---|
26 | d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
|
---|
27 | d_printf("\trpc\t\t\t\tDCE-RPC\n");
|
---|
28 | d_printf("\trap\t\t\t\tRAP (older systems)\n");
|
---|
29 | d_printf("\n");
|
---|
30 | return 0;
|
---|
31 | }
|
---|
32 |
|
---|
33 | int net_common_flags_usage(int argc, const char **argv)
|
---|
34 | {
|
---|
35 | d_printf("Valid targets: choose one (none defaults to localhost)\n");
|
---|
36 | d_printf("\t-S or --server=<server>\t\tserver name\n");
|
---|
37 | d_printf("\t-I or --ipaddress=<ipaddr>\taddress of target server\n");
|
---|
38 | d_printf("\t-w or --workgroup=<wg>\t\ttarget workgroup or domain\n");
|
---|
39 |
|
---|
40 | d_printf("\n");
|
---|
41 | d_printf("Valid miscellaneous options are:\n"); /* misc options */
|
---|
42 | d_printf("\t-p or --port=<port>\t\tconnection port on target\n");
|
---|
43 | d_printf("\t-W or --myworkgroup=<wg>\tclient workgroup\n");
|
---|
44 | d_printf("\t-d or --debuglevel=<level>\tdebug level (0-10)\n");
|
---|
45 | d_printf("\t-n or --myname=<name>\t\tclient name\n");
|
---|
46 | d_printf("\t-U or --user=<name>\t\tuser name\n");
|
---|
47 | d_printf("\t-s or --configfile=<path>\tpathname of smb.conf file\n");
|
---|
48 | d_printf("\t-l or --long\t\t\tDisplay full information\n");
|
---|
49 | d_printf("\t-V or --version\t\t\tPrint samba version information\n");
|
---|
50 | d_printf("\t-P or --machine-pass\t\tAuthenticate as machine account\n");
|
---|
51 | d_printf("\t-e or --encrypt\t\t\tEncrypt SMB transport (UNIX extended servers only)\n");
|
---|
52 | d_printf("\t--request-timeout\t\tThe timeout for smb and rpc requests in seconds\n");
|
---|
53 | return -1;
|
---|
54 | }
|
---|
55 |
|
---|
56 | static int help_usage(int argc, const char **argv)
|
---|
57 | {
|
---|
58 | d_printf(
|
---|
59 | "\n"\
|
---|
60 | "Usage: net help <function>\n"\
|
---|
61 | "\n"\
|
---|
62 | "Valid functions are:\n"\
|
---|
63 | " RPC RAP ADS FILE SHARE SESSION SERVER DOMAIN PRINTQ USER GROUP VALIDATE\n"\
|
---|
64 | " GROUPMEMBER ADMIN SERVICE PASSWORD TIME LOOKUP GETLOCALSID SETLOCALSID\n"\
|
---|
65 | " GETDOMAINSID SETDOMAINSID CHANGESCRETPW LOOKUP SAM\n");
|
---|
66 | return -1;
|
---|
67 | }
|
---|
68 |
|
---|
69 | int net_help_user(int argc, const char **argv)
|
---|
70 | {
|
---|
71 | d_printf("\nnet [<method>] user [misc. options] [targets]"\
|
---|
72 | "\n\tList users\n\n");
|
---|
73 | d_printf("net [<method>] user DELETE <name> [misc. options] [targets]"\
|
---|
74 | "\n\tDelete specified user\n");
|
---|
75 | d_printf("\nnet [<method>] user INFO <name> [misc. options] [targets]"\
|
---|
76 | "\n\tList the domain groups of the specified user\n");
|
---|
77 | d_printf("\nnet [<method>] user ADD <name> [password] [-c container] "\
|
---|
78 | "[-F user flags] [misc. options]"\
|
---|
79 | " [targets]\n\tAdd specified user\n");
|
---|
80 | d_printf("\nnet [<method>] user RENAME <oldusername> <newusername>"\
|
---|
81 | " [targets]\n\tRename specified user\n\n");
|
---|
82 |
|
---|
83 |
|
---|
84 | net_common_methods_usage(argc, argv);
|
---|
85 | net_common_flags_usage(argc, argv);
|
---|
86 | d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
|
---|
87 | d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
|
---|
88 | return -1;
|
---|
89 | }
|
---|
90 |
|
---|
91 | int net_help_group(int argc, const char **argv)
|
---|
92 | {
|
---|
93 | d_printf("net [<method>] group [misc. options] [targets]"\
|
---|
94 | "\n\tList user groups\n\n");
|
---|
95 | d_printf("net rpc group LIST [global|local|builtin]* [misc. options]"\
|
---|
96 | "\n\tList specific user groups\n\n");
|
---|
97 | d_printf("net [<method>] group DELETE <name> "\
|
---|
98 | "[misc. options] [targets]"\
|
---|
99 | "\n\tDelete specified group\n");
|
---|
100 | d_printf("\nnet [<method>] group ADD <name> [-C comment] [-c container]"\
|
---|
101 | " [misc. options] [targets]\n\tCreate specified group\n");
|
---|
102 | d_printf("\nnet rpc group MEMBERS <name>\n\tList Group Members\n\n");
|
---|
103 | d_printf("\nnet rpc group ADDMEM <group> <member>\n\tAdd Group Members\n\n");
|
---|
104 | d_printf("\nnet rpc group DELMEM <group> <member>\n\tDelete Group Members\n\n");
|
---|
105 | net_common_methods_usage(argc, argv);
|
---|
106 | net_common_flags_usage(argc, argv);
|
---|
107 | d_printf("\t-C or --comment=<comment>\tdescriptive comment (for add only)\n");
|
---|
108 | d_printf("\t-c or --container=<container>\tLDAP container, defaults to cn=Users (for add in ADS only)\n");
|
---|
109 | d_printf("\t-L or --localgroup\t\tWhen adding groups, create a local group (alias)\n");
|
---|
110 | return -1;
|
---|
111 | }
|
---|
112 |
|
---|
113 | int net_help_join(int argc, const char **argv)
|
---|
114 | {
|
---|
115 | d_printf("\nnet [<method>] join [misc. options]\n"
|
---|
116 | "\tjoins this server to a domain\n");
|
---|
117 | d_printf("Valid methods: (auto-detected if not specified)\n");
|
---|
118 | d_printf("\tads\t\t\t\tActive Directory (LDAP/Kerberos)\n");
|
---|
119 | d_printf("\trpc\t\t\t\tDCE-RPC\n");
|
---|
120 | net_common_flags_usage(argc, argv);
|
---|
121 | return -1;
|
---|
122 | }
|
---|
123 |
|
---|
124 | int net_help_share(int argc, const char **argv)
|
---|
125 | {
|
---|
126 | d_printf(
|
---|
127 | "\nnet [<method>] share [misc. options] [targets] \n"
|
---|
128 | "\tenumerates all exported resources (network shares) "
|
---|
129 | "on target server\n\n"
|
---|
130 | "net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
|
---|
131 | "\n\tadds a share from a server (makes the export active)\n\n"
|
---|
132 | "net [<method>] share DELETE <sharename> [misc. options] [targets]"
|
---|
133 | "\n\tdeletes a share from a server (makes the export inactive)\n\n"
|
---|
134 | "net [<method>] share ALLOWEDUSERS [<filename>] "
|
---|
135 | "[misc. options] [targets]"
|
---|
136 | "\n\tshows a list of all shares together with all users allowed to"
|
---|
137 | "\n\taccess them. This needs the output of 'net usersidlist' on"
|
---|
138 | "\n\tstdin or in <filename>.\n\n"
|
---|
139 | "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
|
---|
140 | "\n\tMigrates files from remote to local server\n\n"
|
---|
141 | "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
|
---|
142 | "\n\tMigrates shares from remote to local server\n\n"
|
---|
143 | "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
|
---|
144 | "\n\tMigrates share-ACLs from remote to local server\n\n"
|
---|
145 | "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
|
---|
146 | "\n\tMigrates shares (including directories, files) from remote\n"
|
---|
147 | "\tto local server\n\n"
|
---|
148 | );
|
---|
149 | net_common_methods_usage(argc, argv);
|
---|
150 | net_common_flags_usage(argc, argv);
|
---|
151 | d_printf(
|
---|
152 | "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
|
---|
153 | "\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
|
---|
154 | "\t --acls\t\t\tcopies ACLs as well\n"
|
---|
155 | "\t --attrs\t\t\tcopies DOS Attributes as well\n"
|
---|
156 | "\t --timestamps\t\tpreserve timestamps while copying files\n"
|
---|
157 | "\t --destination\t\tmigration target server (default: localhost)\n"
|
---|
158 | "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
|
---|
159 | "\t-v or --verbose\t\t\tgive verbose output\n");
|
---|
160 | return -1;
|
---|
161 | }
|
---|
162 |
|
---|
163 | int net_help_file(int argc, const char **argv)
|
---|
164 | {
|
---|
165 | d_printf("net [<method>] file [misc. options] [targets]\n"\
|
---|
166 | "\tlists all open files on file server\n\n");
|
---|
167 | d_printf("net [<method>] file USER <username> "\
|
---|
168 | "[misc. options] [targets]"\
|
---|
169 | "\n\tlists all files opened by username on file server\n\n");
|
---|
170 | d_printf("net [<method>] file CLOSE <id> [misc. options] [targets]\n"\
|
---|
171 | "\tcloses specified file on target server\n\n");
|
---|
172 | d_printf("net [rap] file INFO <id> [misc. options] [targets]\n"\
|
---|
173 | "\tdisplays information about the specified open file\n");
|
---|
174 |
|
---|
175 | net_common_methods_usage(argc, argv);
|
---|
176 | net_common_flags_usage(argc, argv);
|
---|
177 | return -1;
|
---|
178 | }
|
---|
179 |
|
---|
180 | int net_help_printer(int argc, const char **argv)
|
---|
181 | {
|
---|
182 | d_printf("net rpc printer LIST [printer] [misc. options] [targets]\n"\
|
---|
183 | "\tlists all printers on print-server\n\n");
|
---|
184 | d_printf("net rpc printer DRIVER [printer] [misc. options] [targets]\n"\
|
---|
185 | "\tlists all printer-drivers on print-server\n\n");
|
---|
186 | d_printf("net rpc printer PUBLISH action [printer] [misc. options] [targets]\n"\
|
---|
187 | "\tpublishes printer settings in Active Directory\n"
|
---|
188 | "\taction can be one of PUBLISH, UPDATE, UNPUBLISH or LIST\n\n");
|
---|
189 | d_printf("net rpc printer MIGRATE PRINTERS [printer] [misc. options] [targets]"\
|
---|
190 | "\n\tmigrates printers from remote to local server\n\n");
|
---|
191 | d_printf("net rpc printer MIGRATE SETTINGS [printer] [misc. options] [targets]"\
|
---|
192 | "\n\tmigrates printer-settings from remote to local server\n\n");
|
---|
193 | d_printf("net rpc printer MIGRATE DRIVERS [printer] [misc. options] [targets]"\
|
---|
194 | "\n\tmigrates printer-drivers from remote to local server\n\n");
|
---|
195 | d_printf("net rpc printer MIGRATE FORMS [printer] [misc. options] [targets]"\
|
---|
196 | "\n\tmigrates printer-forms from remote to local server\n\n");
|
---|
197 | d_printf("net rpc printer MIGRATE SECURITY [printer] [misc. options] [targets]"\
|
---|
198 | "\n\tmigrates printer-ACLs from remote to local server\n\n");
|
---|
199 | d_printf("net rpc printer MIGRATE ALL [printer] [misc. options] [targets]"\
|
---|
200 | "\n\tmigrates drivers, forms, queues, settings and acls from\n"\
|
---|
201 | "\tremote to local print-server\n\n");
|
---|
202 | net_common_methods_usage(argc, argv);
|
---|
203 | net_common_flags_usage(argc, argv);
|
---|
204 | d_printf(
|
---|
205 | "\t-v or --verbose\t\t\tgive verbose output\n"
|
---|
206 | "\t --destination\t\tmigration target server (default: localhost)\n");
|
---|
207 |
|
---|
208 | return -1;
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | int net_help_status(int argc, const char **argv)
|
---|
213 | {
|
---|
214 | d_printf(" net status sessions [parseable] "
|
---|
215 | "Show list of open sessions\n");
|
---|
216 | d_printf(" net status shares [parseable] "
|
---|
217 | "Show list of open shares\n");
|
---|
218 | return -1;
|
---|
219 | }
|
---|
220 |
|
---|
221 | static int net_usage(int argc, const char **argv)
|
---|
222 | {
|
---|
223 | d_printf(" net time\t\tto view or set time information\n"\
|
---|
224 | " net lookup\t\tto lookup host name or ip address\n"\
|
---|
225 | " net user\t\tto manage users\n"\
|
---|
226 | " net group\t\tto manage groups\n"\
|
---|
227 | " net sam\t\tto edit the local user database directly\n"\
|
---|
228 | " net lookup\t\tto look up various things\n"\
|
---|
229 | " net groupmap\t\tto manage group mappings\n"\
|
---|
230 | " net join\t\tto join a domain\n"\
|
---|
231 | " net cache\t\tto operate on cache tdb file\n"\
|
---|
232 | " net getlocalsid [NAME]\tto get the SID for local machine name\n"\
|
---|
233 | " net setlocalsid SID\tto set the local machine SID\n"\
|
---|
234 | " net getdomainsid the machine SID and the domain SID on the local server\n"\
|
---|
235 | " net setdomainsid SID\tto set the domain SID on member servers\n"\
|
---|
236 | " net changesecretpw\tto change the machine password in the local secrets database only\n"\
|
---|
237 | " \tthis requires the -f flag as a safety barrier\n"\
|
---|
238 | " net status\t\tShow server status\n"\
|
---|
239 | " net usersidlist\tto get a list of all users with their SIDs\n"
|
---|
240 | " net usershare\t\tto add, delete and list locally user-modifiable shares\n"
|
---|
241 | " net conf\t\tto view and edit samba's registry based configuration\n"
|
---|
242 | "\n"\
|
---|
243 | " net ads <command>\tto run ADS commands\n"\
|
---|
244 | " net rap <command>\tto run RAP (pre-RPC) commands\n"\
|
---|
245 | " net rpc <command>\tto run RPC commands\n"\
|
---|
246 | "\n"\
|
---|
247 | "Type \"net help <option>\" to get more information on that option\n");
|
---|
248 | net_common_flags_usage(argc, argv);
|
---|
249 | return -1;
|
---|
250 | }
|
---|
251 |
|
---|
252 | /*
|
---|
253 | handle "net help *" subcommands
|
---|
254 | */
|
---|
255 | int net_help(int argc, const char **argv)
|
---|
256 | {
|
---|
257 | struct functable func[] = {
|
---|
258 | {"ADS", net_ads_help},
|
---|
259 | {"RAP", net_rap_help},
|
---|
260 | {"RPC", net_rpc_help},
|
---|
261 |
|
---|
262 | {"FILE", net_help_file},
|
---|
263 | {"SHARE", net_help_share},
|
---|
264 | {"SESSION", net_rap_session_usage},
|
---|
265 | {"SERVER", net_rap_server_usage},
|
---|
266 | {"DOMAIN", net_rap_domain_usage},
|
---|
267 | {"PRINTQ", net_rap_printq_usage},
|
---|
268 | {"USER", net_help_user},
|
---|
269 | {"GROUP", net_help_group},
|
---|
270 | {"GROUPMAP", net_help_groupmap},
|
---|
271 | {"JOIN", net_help_join},
|
---|
272 | {"DOM", net_help_dom},
|
---|
273 | {"VALIDATE", net_rap_validate_usage},
|
---|
274 | {"GROUPMEMBER", net_rap_groupmember_usage},
|
---|
275 | {"ADMIN", net_rap_admin_usage},
|
---|
276 | {"SERVICE", net_rap_service_usage},
|
---|
277 | {"PASSWORD", net_rap_password_usage},
|
---|
278 | {"TIME", net_time_usage},
|
---|
279 | {"LOOKUP", net_lookup_usage},
|
---|
280 | {"USERSHARE", net_usershare_usage},
|
---|
281 | {"USERSIDLIST", net_usersidlist_usage},
|
---|
282 | #ifdef WITH_FAKE_KASERVER
|
---|
283 | {"AFS", net_help_afs},
|
---|
284 | #endif
|
---|
285 |
|
---|
286 | {"HELP", help_usage},
|
---|
287 | {NULL, NULL}};
|
---|
288 |
|
---|
289 | return net_run_function(argc, argv, func, net_usage);
|
---|
290 | }
|
---|