Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
[bbaumbach/samba-autobuild/.git] / source3 / utils / net_share.c
1 /*
2    Samba Unix/Linux SMB client library
3    net share commands
4    Copyright (C) 2002  Andrew Tridgell  (tridge@samba.org)
5    Copyright (C) 2008  Kai Blin  (kai@samba.org)
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "utils/net.h"
23
24 int net_share_usage(struct net_context *c, int argc, const char **argv)
25 {
26         d_printf(_(
27          "\nnet [<method>] share [misc. options] [targets] \n"
28          "\tenumerates all exported resources (network shares) "
29          "on target server\n\n"
30          "net [<method>] share ADD <name=serverpath> [misc. options] [targets]"
31         "\n\tadds a share from a server (makes the export active)\n\n"
32         "net [<method>] share DELETE <sharename> [misc. options] [targets]"
33         "\n\tdeletes a share from a server (makes the export inactive)\n\n"
34         "net [<method>] share ALLOWEDUSERS [<filename>] "
35         "[misc. options] [targets]"
36         "\n\tshows a list of all shares together with all users allowed to"
37         "\n\taccess them. This needs the output of 'net usersidlist' on"
38         "\n\tstdin or in <filename>.\n\n"
39          "net [<method>] share MIGRATE FILES <sharename> [misc. options] [targets]"
40          "\n\tMigrates files from remote to local server\n\n"
41          "net [<method>] share MIGRATE SHARES <sharename> [misc. options] [targets]"
42          "\n\tMigrates shares from remote to local server\n\n"
43          "net [<method>] share MIGRATE SECURITY <sharename> [misc. options] [targets]"
44          "\n\tMigrates share-ACLs from remote to local server\n\n"
45          "net [<method>] share MIGRATE ALL <sharename> [misc. options] [targets]"
46          "\n\tMigrates shares (including directories, files) from remote\n"
47          "\tto local server\n\n"
48          ));
49         net_common_methods_usage(c, argc, argv);
50         net_common_flags_usage(c, argc, argv);
51         d_printf(_(
52          "\t-C or --comment=<comment>\tdescriptive comment (for add only)\n"
53          "\t-M or --maxusers=<num>\t\tmax users allowed for share\n"
54          "\t      --acls\t\t\tcopies ACLs as well\n"
55          "\t      --attrs\t\t\tcopies DOS Attributes as well\n"
56          "\t      --timestamps\t\tpreserve timestamps while copying files\n"
57          "\t      --destination\t\tmigration target server (default: localhost)\n"
58          "\t-e or --exclude\t\t\tlist of shares to be excluded from mirroring\n"
59          "\t-v or --verbose\t\t\tgive verbose output\n"));
60         return -1;
61 }
62
63 int net_share(struct net_context *c, int argc, const char **argv)
64 {
65         if (argc > 0 && strcasecmp_m(argv[0], "HELP") == 0) {
66                         net_share_usage(c, argc, argv);
67                         return 0;
68         }
69
70         if (net_rpc_check(c, 0))
71                 return net_rpc_share(c, argc, argv);
72         return net_rap_share(c, argc, argv);
73 }
74