2 Samba Unix/Linux SMB client library
3 Distributed SMB/CIFS Server Management Utility
5 Copyright (C) Jeremy Allison (jra@samba.org) 2005
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.
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.
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/>.
22 #include "system/passwd.h"
23 #include "system/filesys.h"
24 #include "utils/net.h"
25 #include "../libcli/security/security.h"
26 #include "lib/util/string_wrappers.h"
27 #include "lib/util/util_file.h"
30 const char *us_errstr
;
31 enum usershare_err us_err
;
34 {N_("Malformed usershare file"), USERSHARE_MALFORMED_FILE
},
35 {N_("Bad version number"), USERSHARE_BAD_VERSION
},
36 {N_("Malformed path entry"), USERSHARE_MALFORMED_PATH
},
37 {N_("Malformed comment entryfile"), USERSHARE_MALFORMED_COMMENT_DEF
},
38 {N_("Malformed acl definition"), USERSHARE_MALFORMED_ACL_DEF
},
39 {N_("Acl parse error"), USERSHARE_ACL_ERR
},
40 {N_("Path not absolute"), USERSHARE_PATH_NOT_ABSOLUTE
},
41 {N_("Path is denied"), USERSHARE_PATH_IS_DENIED
},
42 {N_("Path not allowed"), USERSHARE_PATH_NOT_ALLOWED
},
43 {N_("Path is not a directory"), USERSHARE_PATH_NOT_DIRECTORY
},
44 {N_("System error"), USERSHARE_POSIX_ERR
},
45 {N_("Malformed sharename definition"), USERSHARE_MALFORMED_SHARENAME_DEF
},
46 {N_("Bad sharename (doesn't match filename)"), USERSHARE_BAD_SHARENAME
},
47 {NULL
,(enum usershare_err
)-1}
50 static const char *get_us_error_code(enum usershare_err us_err
)
55 while (us_errs
[idx
].us_errstr
!= NULL
) {
56 if (us_errs
[idx
].us_err
== us_err
) {
57 return us_errs
[idx
].us_errstr
;
62 result
= talloc_asprintf(talloc_tos(), _("Usershare error code (0x%x)"),
63 (unsigned int)us_err
);
64 SMB_ASSERT(result
!= NULL
);
68 /* The help subsystem for the USERSHARE subcommand */
70 static int net_usershare_add_usage(struct net_context
*c
, int argc
, const char **argv
)
72 char chr
= *lp_winbind_separator();
74 "net usershare add [--long] <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>]\n"
75 "\tAdds the specified share name for this user.\n"
76 "\t<sharename> is the new share name.\n"
77 "\t<path> is the path on the filesystem to export.\n"
78 "\t<comment> is the optional comment for the new share.\n"
79 "\t<acl> is an optional share acl in the format \"DOMAIN%cname:X,DOMAIN%cname:X,....\"\n"
80 "\t<guest_ok=y> if present sets \"guest ok = yes\" on this usershare.\n"
81 "\t\t\"X\" represents a permission and can be any one of the characters f, r or d\n"
82 "\t\twhere \"f\" means full control, \"r\" means read-only, \"d\" means deny access.\n"
83 "\t\tname may be a domain user or group. For local users use the local server name "
84 "instead of \"DOMAIN\"\n"
85 "\t\tThe default acl is \"Everyone:r\" which allows everyone read-only access.\n"
86 "\tAdd --long to print the info on the newly added share.\n"),
91 static int net_usershare_delete_usage(struct net_context
*c
, int argc
, const char **argv
)
94 "net usershare delete <sharename>\n"
95 "\tdeletes the specified share name for this user.\n"));
99 static int net_usershare_info_usage(struct net_context
*c
, int argc
, const char **argv
)
102 "net usershare info [--long] [wildcard sharename]\n"
103 "\tPrints out the path, comment and acl elements of shares that match the wildcard.\n"
104 "\tBy default only gives info on shares owned by the current user\n"
105 "\tAdd --long to apply this to all shares\n"
106 "\tOmit the sharename or use a wildcard of '*' to see all shares\n"));
110 static int net_usershare_list_usage(struct net_context
*c
, int argc
, const char **argv
)
113 "net usershare list [--long] [wildcard sharename]\n"
114 "\tLists the names of all shares that match the wildcard.\n"
115 "\tBy default only lists shares owned by the current user\n"
116 "\tAdd --long to apply this to all shares\n"
117 "\tOmit the sharename or use a wildcard of '*' to see all shares\n"));
121 int net_usershare_usage(struct net_context
*c
, int argc
, const char **argv
)
123 d_printf(_("net usershare add <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>] to "
124 "add or change a user defined share.\n"
125 "net usershare delete <sharename> to delete a user defined share.\n"
126 "net usershare info [--long] [wildcard sharename] to print info about a user defined share.\n"
127 "net usershare list [--long] [wildcard sharename] to list user defined shares.\n"
128 "net usershare help\n"
129 "\nType \"net usershare help <option>\" to get more information on that option\n\n"));
131 net_common_flags_usage(c
, argc
, argv
);
135 /***************************************************************************
136 ***************************************************************************/
138 static char *get_basepath(TALLOC_CTX
*ctx
)
140 const struct loadparm_substitution
*lp_sub
=
141 loadparm_s3_global_substitution();
142 char *basepath
= lp_usershare_path(ctx
, lp_sub
);
147 if ((basepath
[0] != '\0') && (basepath
[strlen(basepath
)-1] == '/')) {
148 basepath
[strlen(basepath
)-1] = '\0';
153 /***************************************************************************
154 Delete a single userlevel share.
155 ***************************************************************************/
157 static int net_usershare_delete(struct net_context
*c
, int argc
, const char **argv
)
159 const struct loadparm_substitution
*lp_sub
=
160 loadparm_s3_global_substitution();
164 if (argc
!= 1 || c
->display_usage
) {
165 return net_usershare_delete_usage(c
, argc
, argv
);
168 if ((sharename
= strlower_talloc(talloc_tos(), argv
[0])) == NULL
) {
169 d_fprintf(stderr
, _("strlower_talloc failed\n"));
173 if (!validate_net_name(sharename
, INVALID_SHARENAME_CHARS
, strlen(sharename
))) {
174 d_fprintf(stderr
, _("net usershare delete: share name %s contains "
175 "invalid characters (any of %s)\n"),
176 sharename
, INVALID_SHARENAME_CHARS
);
177 TALLOC_FREE(sharename
);
181 us_path
= talloc_asprintf(talloc_tos(),
183 lp_usershare_path(talloc_tos(), lp_sub
),
186 TALLOC_FREE(sharename
);
190 if (unlink(us_path
) != 0) {
191 d_fprintf(stderr
, _("net usershare delete: unable to remove usershare %s. "
193 us_path
, strerror(errno
));
194 TALLOC_FREE(sharename
);
197 TALLOC_FREE(sharename
);
201 /***************************************************************************
202 Data structures to handle a list of usershare files.
203 ***************************************************************************/
206 struct file_list
*next
, *prev
;
207 const char *pathname
;
210 static struct file_list
*flist
;
212 /***************************************************************************
213 ***************************************************************************/
215 static int get_share_list(TALLOC_CTX
*ctx
, const char *wcard
, bool only_ours
)
219 uid_t myuid
= geteuid();
220 struct file_list
*fl
= NULL
;
221 char *basepath
= get_basepath(ctx
);
226 dp
= opendir(basepath
);
229 _("get_share_list: cannot open usershare directory %s. "
231 basepath
, strerror(errno
) );
235 while((de
= readdir(dp
)) != 0) {
236 SMB_STRUCT_STAT sbuf
;
238 const char *n
= de
->d_name
;
240 /* Ignore . and .. */
242 if ((n
[1] == '\0') || (n
[1] == '.' && n
[2] == '\0')) {
247 if (!validate_net_name(n
, INVALID_SHARENAME_CHARS
, strlen(n
))) {
249 _("get_share_list: ignoring bad share "
253 path
= talloc_asprintf(ctx
,
262 if (sys_lstat(path
, &sbuf
, false) != 0) {
264 _("get_share_list: can't lstat file %s. Error "
266 path
, strerror(errno
) );
270 if (!S_ISREG(sbuf
.st_ex_mode
)) {
272 _("get_share_list: file %s is not a regular "
273 "file. Ignoring.\n"),
278 if (only_ours
&& sbuf
.st_ex_uid
!= myuid
) {
282 if (!unix_wild_match(wcard
, n
)) {
286 /* (Finally) - add to list. */
287 fl
= talloc(ctx
, struct file_list
);
292 fl
->pathname
= talloc_strdup(ctx
, n
);
298 DLIST_ADD(flist
, fl
);
305 enum us_priv_op
{ US_LIST_OP
, US_INFO_OP
};
307 struct us_priv_info
{
310 struct net_context
*c
;
313 /***************************************************************************
314 Call a function for every share on the list.
315 ***************************************************************************/
317 static int process_share_list(int (*fn
)(struct file_list
*, void *), void *priv
)
319 struct file_list
*fl
;
322 for (fl
= flist
; fl
; fl
= fl
->next
) {
323 ret
= (*fn
)(fl
, priv
);
329 /***************************************************************************
331 ***************************************************************************/
333 static int info_fn(struct file_list
*fl
, void *priv
)
335 SMB_STRUCT_STAT sbuf
;
337 struct us_priv_info
*pi
= (struct us_priv_info
*)priv
;
338 TALLOC_CTX
*ctx
= pi
->ctx
;
339 struct net_context
*c
= pi
->c
;
342 struct security_descriptor
*psd
= NULL
;
344 char *sharepath
= NULL
;
345 char *comment
= NULL
;
346 char *cp_sharename
= NULL
;
350 enum usershare_err us_err
;
351 bool guest_ok
= false;
353 sep_str
[0] = *lp_winbind_separator();
356 basepath
= get_basepath(ctx
);
360 basepath
= talloc_asprintf_append(basepath
,
368 fd
= open(basepath
, O_RDONLY
|O_NOFOLLOW
, 0);
370 fd
= open(basepath
, O_RDONLY
, 0);
374 d_fprintf(stderr
, _("info_fn: unable to open %s. %s\n"),
375 basepath
, strerror(errno
) );
380 if (sys_fstat(fd
, &sbuf
, false) != 0) {
382 _("info_fn: can't fstat file %s. Error was %s\n"),
383 basepath
, strerror(errno
) );
388 if (!S_ISREG(sbuf
.st_ex_mode
)) {
390 _("info_fn: file %s is not a regular file. Ignoring.\n"),
396 lines
= fd_lines_load(fd
, &numlines
, 10240, NULL
);
403 /* Ensure it's well formed. */
404 us_err
= parse_usershare_file(ctx
, &sbuf
, fl
->pathname
, -1, lines
, numlines
,
413 if (us_err
!= USERSHARE_OK
) {
415 _("info_fn: file %s is not a well formed usershare "
418 d_fprintf(stderr
, _("info_fn: Error was %s.\n"),
419 get_us_error_code(us_err
) );
423 acl_str
= talloc_strdup(ctx
, "usershare_acl=");
428 for (num_aces
= 0; num_aces
< psd
->dacl
->num_aces
; num_aces
++) {
433 ntstatus
= net_lookup_name_from_sid(c
, ctx
,
434 &psd
->dacl
->aces
[num_aces
].trustee
,
437 if (NT_STATUS_IS_OK(ntstatus
)) {
438 if (domain
&& *domain
) {
439 acl_str
= talloc_asprintf_append(acl_str
,
447 acl_str
= talloc_asprintf_append(acl_str
,
455 struct dom_sid_buf sidstr
;
457 acl_str
= talloc_asprintf_append(
461 &psd
->dacl
->aces
[num_aces
].trustee
,
467 acl_str
= talloc_asprintf_append(acl_str
, ":");
472 if (psd
->dacl
->aces
[num_aces
].type
== SEC_ACE_TYPE_ACCESS_DENIED
) {
473 acl_str
= talloc_asprintf_append(acl_str
, "D,");
478 if (psd
->dacl
->aces
[num_aces
].access_mask
& GENERIC_ALL_ACCESS
) {
479 acl_str
= talloc_asprintf_append(acl_str
, "F,");
481 acl_str
= talloc_asprintf_append(acl_str
, "R,");
489 /* NOTE: This is smb.conf-like output. Do not translate. */
490 if (pi
->op
== US_INFO_OP
) {
491 d_printf("[%s]\n", cp_sharename
);
492 d_printf("path=%s\n", sharepath
);
493 d_printf("comment=%s\n", comment
);
494 d_printf("%s\n", acl_str
);
495 d_printf("guest_ok=%c\n\n", guest_ok
? 'y' : 'n');
496 } else if (pi
->op
== US_LIST_OP
) {
497 d_printf("%s\n", cp_sharename
);
503 /***************************************************************************
504 Print out info (internal detail) on userlevel shares.
505 ***************************************************************************/
507 static int net_usershare_info(struct net_context
*c
, int argc
, const char **argv
)
510 bool only_ours
= true;
512 struct us_priv_info pi
;
517 if (c
->display_usage
)
518 return net_usershare_info_usage(c
, argc
, argv
);
520 if (c
->opt_long_list_entries
) {
528 fstrcpy(wcard
, argv
[0]);
531 return net_usershare_info_usage(c
, argc
, argv
);
534 if (!strlower_m(wcard
)) {
538 ctx
= talloc_init("share_info");
539 ret
= get_share_list(ctx
, wcard
, only_ours
);
548 ret
= process_share_list(info_fn
, &pi
);
553 /***************************************************************************
554 Count the current total number of usershares.
555 ***************************************************************************/
557 static int count_num_usershares(void)
561 int num_usershares
= 0;
562 TALLOC_CTX
*ctx
= talloc_tos();
563 char *basepath
= get_basepath(ctx
);
569 dp
= opendir(basepath
);
572 _("count_num_usershares: cannot open usershare "
573 "directory %s. Error %s\n"),
574 basepath
, strerror(errno
) );
578 while((de
= readdir(dp
)) != 0) {
579 SMB_STRUCT_STAT sbuf
;
581 const char *n
= de
->d_name
;
583 /* Ignore . and .. */
585 if ((n
[1] == '\0') || (n
[1] == '.' && n
[2] == '\0')) {
590 if (!validate_net_name(n
, INVALID_SHARENAME_CHARS
, strlen(n
))) {
592 _("count_num_usershares: ignoring bad share "
596 path
= talloc_asprintf(ctx
,
605 if (sys_lstat(path
, &sbuf
, false) != 0) {
607 _("count_num_usershares: can't lstat file %s. "
609 path
, strerror(errno
) );
613 if (!S_ISREG(sbuf
.st_ex_mode
)) {
615 _("count_num_usershares: file %s is not a "
616 "regular file. Ignoring.\n"),
624 return num_usershares
;
627 /***************************************************************************
628 Add a single userlevel share.
629 ***************************************************************************/
631 static int net_usershare_add(struct net_context
*c
, int argc
, const char **argv
)
633 TALLOC_CTX
*ctx
= talloc_stackframe();
634 SMB_STRUCT_STAT sbuf
;
635 SMB_STRUCT_STAT lsbuf
;
637 const char *cp_sharename
;
641 const char *us_comment
;
650 uid_t myeuid
= geteuid();
651 bool guest_ok
= false;
656 arg_acl
= "S-1-1-0:R";
658 if (c
->display_usage
) {
660 return net_usershare_add_usage(c
, argc
, argv
);
668 return net_usershare_add_usage(c
, argc
, argv
);
670 cp_sharename
= argv
[0];
671 sharename
= strlower_talloc(ctx
, argv
[0]);
675 cp_sharename
= argv
[0];
676 sharename
= strlower_talloc(ctx
, argv
[0]);
678 us_comment
= argv
[2];
681 cp_sharename
= argv
[0];
682 sharename
= strlower_talloc(ctx
, argv
[0]);
684 us_comment
= argv
[2];
688 cp_sharename
= argv
[0];
689 sharename
= strlower_talloc(ctx
, argv
[0]);
691 us_comment
= argv
[2];
693 if (strlen(arg_acl
) == 0) {
694 arg_acl
= "S-1-1-0:R";
696 if (!strnequal(argv
[4], "guest_ok=", 9)) {
698 return net_usershare_add_usage(c
, argc
, argv
);
700 switch (argv
[4][9]) {
711 return net_usershare_add_usage(c
, argc
, argv
);
716 /* Ensure we're under the "usershare max shares" number. Advisory only. */
717 num_usershares
= count_num_usershares();
718 if (num_usershares
>= lp_usershare_max_shares()) {
720 _("net usershare add: maximum number of allowed "
721 "usershares (%d) reached\n"),
722 lp_usershare_max_shares() );
727 if (!validate_net_name(sharename
, INVALID_SHARENAME_CHARS
, strlen(sharename
))) {
728 d_fprintf(stderr
, _("net usershare add: share name %s contains "
729 "invalid characters (any of %s)\n"),
730 sharename
, INVALID_SHARENAME_CHARS
);
735 /* Disallow shares the same as users. */
736 if (getpwnam(sharename
)) {
738 _("net usershare add: share name %s is already a valid "
739 "system user name\n"),
745 /* Construct the full path for the usershare file. */
746 full_path
= get_basepath(ctx
);
751 full_path_tmp
= talloc_asprintf(ctx
,
754 if (!full_path_tmp
) {
759 full_path
= talloc_asprintf_append(full_path
,
767 /* The path *must* be absolute. */
768 if (us_path
[0] != '/') {
770 _("net usershare add: path %s is not an absolute "
777 /* Check the directory to be shared exists. */
778 if (sys_stat(us_path
, &sbuf
, false) != 0) {
780 _("net usershare add: cannot stat path %s to ensure "
781 "this is a directory. Error was %s\n"),
782 us_path
, strerror(errno
) );
787 if (!S_ISDIR(sbuf
.st_ex_mode
)) {
789 _("net usershare add: path %s is not a directory.\n"),
795 /* If we're not root, check if we're restricted to sharing out directories
798 if ((myeuid
!= 0) && lp_usershare_owner_only() && (myeuid
!= sbuf
.st_ex_uid
)) {
799 d_fprintf(stderr
, _("net usershare add: cannot share path %s as "
800 "we are restricted to only sharing directories we own.\n"
801 "\tAsk the administrator to add the line \"usershare owner only = false\" \n"
802 "\tto the [global] section of the smb.conf to allow this.\n"),
808 /* No validation needed on comment. Now go through and validate the
809 acl string. Convert names to SID's as needed. Then run it through
810 parse_usershare_acl to ensure it's valid. */
812 /* Start off the string we'll append to. */
813 us_acl
= talloc_strdup(ctx
, "");
822 /* Add the number of ',' characters to get the number of aces. */
823 num_aces
+= count_chars(pacl
,',');
825 for (i
= 0; i
< num_aces
; i
++) {
827 struct dom_sid_buf buf
;
828 const char *pcolon
= strchr_m(pacl
, ':');
831 if (pcolon
== NULL
) {
833 _("net usershare add: malformed acl %s "
849 _("net usershare add: malformed acl %s "
850 "(access control must be 'r', 'f', "
857 if (pcolon
[2] != ',' && pcolon
[2] != '\0') {
859 _("net usershare add: malformed terminating "
860 "character for acl %s\n"),
867 if ((name
= talloc_strndup(ctx
, pacl
, pcolon
- pacl
)) == NULL
) {
868 d_fprintf(stderr
, _("talloc_strndup failed\n"));
872 if (!string_to_sid(&sid
, name
)) {
873 /* Convert to a SID */
874 NTSTATUS ntstatus
= net_lookup_sid_from_name(c
, ctx
, name
, &sid
);
875 if (!NT_STATUS_IS_OK(ntstatus
)) {
877 _("net usershare add: cannot convert "
878 "name \"%s\" to a SID. %s."),
879 name
, get_friendly_nt_error_msg(ntstatus
) );
880 if (NT_STATUS_EQUAL(ntstatus
, NT_STATUS_CONNECTION_REFUSED
)) {
882 _(" Maybe smbd is not running.\n"));
884 d_fprintf(stderr
, "\n");
890 us_acl
= talloc_asprintf_append(
893 dom_sid_str_buf(&sid
, &buf
),
895 if (us_acl
== NULL
) {
897 _("net usershare add: talloc_asprintf_append() failed\n"));
902 /* Move to the next ACL entry. */
903 if (pcolon
[2] == ',') {
908 /* Remove the last ',' */
909 us_acl
[strlen(us_acl
)-1] = '\0';
911 if (guest_ok
&& !lp_usershare_allow_guests()) {
912 d_fprintf(stderr
, _("net usershare add: guest_ok=y requested "
913 "but the \"usershare allow guests\" parameter is not "
914 "enabled by this server.\n"));
919 /* Create a temporary filename for this share. */
920 mask
= umask(S_IRWXO
| S_IRWXG
);
921 tmpfd
= mkstemp(full_path_tmp
);
926 _("net usershare add: cannot create tmp file %s\n"),
932 /* Ensure we opened the file we thought we did. */
933 if (sys_lstat(full_path_tmp
, &lsbuf
, false) != 0) {
935 _("net usershare add: cannot lstat tmp file %s\n"),
942 /* Check this is the same as the file we opened. */
943 if (sys_fstat(tmpfd
, &sbuf
, false) != 0) {
945 _("net usershare add: cannot fstat tmp file %s\n"),
952 if (!S_ISREG(sbuf
.st_ex_mode
) || sbuf
.st_ex_dev
!= lsbuf
.st_ex_dev
|| sbuf
.st_ex_ino
!= lsbuf
.st_ex_ino
) {
954 _("net usershare add: tmp file %s is not a regular "
962 if (fchmod(tmpfd
, 0644) == -1) {
964 _("net usershare add: failed to fchmod tmp file %s "
972 /* Create the in-memory image of the file. */
973 file_img
= talloc_strdup(ctx
, "#VERSION 2\npath=");
974 if (file_img
== NULL
) {
976 _("net usershare add: talloc_strdup() failed\n"));
981 file_img
= talloc_asprintf_append(file_img
,
982 "%s\ncomment=%s\nusershare_acl=%s\n"
983 "guest_ok=%c\nsharename=%s\n",
987 guest_ok
? 'y' : 'n',
989 if (file_img
== NULL
) {
991 _("net usershare add: talloc_asprintf_append() failed\n"));
997 to_write
= strlen(file_img
);
999 if (write(tmpfd
, file_img
, to_write
) != to_write
) {
1001 _("net usershare add: failed to write %u bytes to "
1002 "file %s. Error was %s\n"),
1003 (unsigned int)to_write
, full_path_tmp
, strerror(errno
));
1004 unlink(full_path_tmp
);
1010 /* Attempt to replace any existing share by this name. */
1011 if (rename(full_path_tmp
, full_path
) != 0) {
1012 unlink(full_path_tmp
);
1014 _("net usershare add: failed to add share %s. Error "
1016 sharename
, strerror(errno
));
1024 if (c
->opt_long_list_entries
) {
1025 const char *my_argv
[2];
1026 my_argv
[0] = sharename
;
1028 net_usershare_info(c
, 1, my_argv
);
1036 /***************************************************************************
1038 ***************************************************************************/
1040 static int list_fn(struct file_list
*fl
, void *priv
)
1042 d_printf("%s\n", fl
->pathname
);
1047 /***************************************************************************
1048 List userlevel shares.
1049 ***************************************************************************/
1051 static int net_usershare_list(struct net_context
*c
, int argc
,
1055 bool only_ours
= true;
1057 struct us_priv_info pi
;
1060 fstrcpy(wcard
, "*");
1062 if (c
->display_usage
)
1063 return net_usershare_list_usage(c
, argc
, argv
);
1065 if (c
->opt_long_list_entries
) {
1073 fstrcpy(wcard
, argv
[0]);
1076 return net_usershare_list_usage(c
, argc
, argv
);
1079 if (!strlower_m(wcard
)) {
1083 ctx
= talloc_init("share_list");
1084 ret
= get_share_list(ctx
, wcard
, only_ours
);
1093 ret
= process_share_list(info_fn
, &pi
);
1094 talloc_destroy(ctx
);
1098 /***************************************************************************
1099 Entry-point for all the USERSHARE functions.
1100 ***************************************************************************/
1102 int net_usershare(struct net_context
*c
, int argc
, const char **argv
)
1104 const struct loadparm_substitution
*lp_sub
=
1105 loadparm_s3_global_substitution();
1108 struct functable func
[] = {
1112 NET_TRANSPORT_LOCAL
,
1113 N_("Add/modify user defined share"),
1114 N_("net usershare add\n"
1115 " Add/modify user defined share")
1119 net_usershare_delete
,
1120 NET_TRANSPORT_LOCAL
,
1121 N_("Delete user defined share"),
1122 N_("net usershare delete\n"
1123 " Delete user defined share")
1128 NET_TRANSPORT_LOCAL
,
1129 N_("Display information about a user defined share"),
1130 N_("net usershare info\n"
1131 " Display information about a user defined share")
1136 NET_TRANSPORT_LOCAL
,
1137 N_("List user defined shares"),
1138 N_("net usershare list\n"
1139 " List user defined shares")
1141 {NULL
, NULL
, 0, NULL
, NULL
}
1144 if (lp_usershare_max_shares() == 0) {
1146 _("net usershare: usershares are currently "
1151 dp
= opendir(lp_usershare_path(talloc_tos(), lp_sub
));
1155 _("net usershare: cannot open usershare directory %s. "
1157 lp_usershare_path(talloc_tos(), lp_sub
), strerror(err
) );
1158 if (err
== EACCES
) {
1160 _("You do not have permission to create a "
1161 "usershare. Ask your administrator to grant "
1162 "you permissions to create a share.\n"));
1163 } else if (err
== ENOENT
) {
1165 _("Please ask your system administrator to "
1166 "enable user sharing.\n"));
1172 return net_run_function(c
, argc
, argv
, "net usershare", func
);