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"
28 const char *us_errstr
;
29 enum usershare_err us_err
;
32 {N_("Malformed usershare file"), USERSHARE_MALFORMED_FILE
},
33 {N_("Bad version number"), USERSHARE_BAD_VERSION
},
34 {N_("Malformed path entry"), USERSHARE_MALFORMED_PATH
},
35 {N_("Malformed comment entryfile"), USERSHARE_MALFORMED_COMMENT_DEF
},
36 {N_("Malformed acl definition"), USERSHARE_MALFORMED_ACL_DEF
},
37 {N_("Acl parse error"), USERSHARE_ACL_ERR
},
38 {N_("Path not absolute"), USERSHARE_PATH_NOT_ABSOLUTE
},
39 {N_("Path is denied"), USERSHARE_PATH_IS_DENIED
},
40 {N_("Path not allowed"), USERSHARE_PATH_NOT_ALLOWED
},
41 {N_("Path is not a directory"), USERSHARE_PATH_NOT_DIRECTORY
},
42 {N_("System error"), USERSHARE_POSIX_ERR
},
43 {N_("Malformed sharename definition"), USERSHARE_MALFORMED_SHARENAME_DEF
},
44 {N_("Bad sharename (doesn't match filename)"), USERSHARE_BAD_SHARENAME
},
45 {NULL
,(enum usershare_err
)-1}
48 static const char *get_us_error_code(enum usershare_err us_err
)
53 while (us_errs
[idx
].us_errstr
!= NULL
) {
54 if (us_errs
[idx
].us_err
== us_err
) {
55 return us_errs
[idx
].us_errstr
;
60 result
= talloc_asprintf(talloc_tos(), _("Usershare error code (0x%x)"),
61 (unsigned int)us_err
);
62 SMB_ASSERT(result
!= NULL
);
66 /* The help subsystem for the USERSHARE subcommand */
68 static int net_usershare_add_usage(struct net_context
*c
, int argc
, const char **argv
)
70 char chr
= *lp_winbind_separator();
72 "net usershare add [-l|--long] <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>]\n"
73 "\tAdds the specified share name for this user.\n"
74 "\t<sharename> is the new share name.\n"
75 "\t<path> is the path on the filesystem to export.\n"
76 "\t<comment> is the optional comment for the new share.\n"
77 "\t<acl> is an optional share acl in the format \"DOMAIN%cname:X,DOMAIN%cname:X,....\"\n"
78 "\t<guest_ok=y> if present sets \"guest ok = yes\" on this usershare.\n"
79 "\t\t\"X\" represents a permission and can be any one of the characters f, r or d\n"
80 "\t\twhere \"f\" means full control, \"r\" means read-only, \"d\" means deny access.\n"
81 "\t\tname may be a domain user or group. For local users use the local server name "
82 "instead of \"DOMAIN\"\n"
83 "\t\tThe default acl is \"Everyone:r\" which allows everyone read-only access.\n"
84 "\tAdd -l or --long to print the info on the newly added share.\n"),
89 static int net_usershare_delete_usage(struct net_context
*c
, int argc
, const char **argv
)
92 "net usershare delete <sharename>\n"
93 "\tdeletes the specified share name for this user.\n"));
97 static int net_usershare_info_usage(struct net_context
*c
, int argc
, const char **argv
)
100 "net usershare info [-l|--long] [wildcard sharename]\n"
101 "\tPrints out the path, comment and acl elements of shares that match the wildcard.\n"
102 "\tBy default only gives info on shares owned by the current user\n"
103 "\tAdd -l or --long to apply this to all shares\n"
104 "\tOmit the sharename or use a wildcard of '*' to see all shares\n"));
108 static int net_usershare_list_usage(struct net_context
*c
, int argc
, const char **argv
)
111 "net usershare list [-l|--long] [wildcard sharename]\n"
112 "\tLists the names of all shares that match the wildcard.\n"
113 "\tBy default only lists shares owned by the current user\n"
114 "\tAdd -l or --long to apply this to all shares\n"
115 "\tOmit the sharename or use a wildcard of '*' to see all shares\n"));
119 int net_usershare_usage(struct net_context
*c
, int argc
, const char **argv
)
121 d_printf(_("net usershare add <sharename> <path> [<comment>] [<acl>] [<guest_ok=[y|n]>] to "
122 "add or change a user defined share.\n"
123 "net usershare delete <sharename> to delete a user defined share.\n"
124 "net usershare info [-l|--long] [wildcard sharename] to print info about a user defined share.\n"
125 "net usershare list [-l|--long] [wildcard sharename] to list user defined shares.\n"
126 "net usershare help\n"
127 "\nType \"net usershare help <option>\" to get more information on that option\n\n"));
129 net_common_flags_usage(c
, argc
, argv
);
133 /***************************************************************************
134 ***************************************************************************/
136 static char *get_basepath(TALLOC_CTX
*ctx
)
138 char *basepath
= lp_usershare_path(ctx
);
143 if ((basepath
[0] != '\0') && (basepath
[strlen(basepath
)-1] == '/')) {
144 basepath
[strlen(basepath
)-1] = '\0';
149 /***************************************************************************
150 Delete a single userlevel share.
151 ***************************************************************************/
153 static int net_usershare_delete(struct net_context
*c
, int argc
, const char **argv
)
158 if (argc
!= 1 || c
->display_usage
) {
159 return net_usershare_delete_usage(c
, argc
, argv
);
162 if ((sharename
= strlower_talloc(talloc_tos(), argv
[0])) == NULL
) {
163 d_fprintf(stderr
, _("strlower_talloc failed\n"));
167 if (!validate_net_name(sharename
, INVALID_SHARENAME_CHARS
, strlen(sharename
))) {
168 d_fprintf(stderr
, _("net usershare delete: share name %s contains "
169 "invalid characters (any of %s)\n"),
170 sharename
, INVALID_SHARENAME_CHARS
);
171 TALLOC_FREE(sharename
);
175 us_path
= talloc_asprintf(talloc_tos(),
177 lp_usershare_path(talloc_tos()),
180 TALLOC_FREE(sharename
);
184 if (unlink(us_path
) != 0) {
185 d_fprintf(stderr
, _("net usershare delete: unable to remove usershare %s. "
187 us_path
, strerror(errno
));
188 TALLOC_FREE(sharename
);
191 TALLOC_FREE(sharename
);
195 /***************************************************************************
196 Data structures to handle a list of usershare files.
197 ***************************************************************************/
200 struct file_list
*next
, *prev
;
201 const char *pathname
;
204 static struct file_list
*flist
;
206 /***************************************************************************
207 ***************************************************************************/
209 static int get_share_list(TALLOC_CTX
*ctx
, const char *wcard
, bool only_ours
)
213 uid_t myuid
= geteuid();
214 struct file_list
*fl
= NULL
;
215 char *basepath
= get_basepath(ctx
);
220 dp
= opendir(basepath
);
223 _("get_share_list: cannot open usershare directory %s. "
225 basepath
, strerror(errno
) );
229 while((de
= readdir(dp
)) != 0) {
230 SMB_STRUCT_STAT sbuf
;
232 const char *n
= de
->d_name
;
234 /* Ignore . and .. */
236 if ((n
[1] == '\0') || (n
[1] == '.' && n
[2] == '\0')) {
241 if (!validate_net_name(n
, INVALID_SHARENAME_CHARS
, strlen(n
))) {
243 _("get_share_list: ignoring bad share "
247 path
= talloc_asprintf(ctx
,
256 if (sys_lstat(path
, &sbuf
, false) != 0) {
258 _("get_share_list: can't lstat file %s. Error "
260 path
, strerror(errno
) );
264 if (!S_ISREG(sbuf
.st_ex_mode
)) {
266 _("get_share_list: file %s is not a regular "
267 "file. Ignoring.\n"),
272 if (only_ours
&& sbuf
.st_ex_uid
!= myuid
) {
276 if (!unix_wild_match(wcard
, n
)) {
280 /* (Finally) - add to list. */
281 fl
= talloc(ctx
, struct file_list
);
286 fl
->pathname
= talloc_strdup(ctx
, n
);
292 DLIST_ADD(flist
, fl
);
299 enum us_priv_op
{ US_LIST_OP
, US_INFO_OP
};
301 struct us_priv_info
{
304 struct net_context
*c
;
307 /***************************************************************************
308 Call a function for every share on the list.
309 ***************************************************************************/
311 static int process_share_list(int (*fn
)(struct file_list
*, void *), void *priv
)
313 struct file_list
*fl
;
316 for (fl
= flist
; fl
; fl
= fl
->next
) {
317 ret
= (*fn
)(fl
, priv
);
323 /***************************************************************************
325 ***************************************************************************/
327 static int info_fn(struct file_list
*fl
, void *priv
)
329 SMB_STRUCT_STAT sbuf
;
331 struct us_priv_info
*pi
= (struct us_priv_info
*)priv
;
332 TALLOC_CTX
*ctx
= pi
->ctx
;
333 struct net_context
*c
= pi
->c
;
336 struct security_descriptor
*psd
= NULL
;
338 char *sharepath
= NULL
;
339 char *comment
= NULL
;
340 char *cp_sharename
= NULL
;
344 enum usershare_err us_err
;
345 bool guest_ok
= false;
347 sep_str
[0] = *lp_winbind_separator();
350 basepath
= get_basepath(ctx
);
354 basepath
= talloc_asprintf_append(basepath
,
362 fd
= open(basepath
, O_RDONLY
|O_NOFOLLOW
, 0);
364 fd
= open(basepath
, O_RDONLY
, 0);
368 d_fprintf(stderr
, _("info_fn: unable to open %s. %s\n"),
369 basepath
, strerror(errno
) );
374 if (sys_fstat(fd
, &sbuf
, false) != 0) {
376 _("info_fn: can't fstat file %s. Error was %s\n"),
377 basepath
, strerror(errno
) );
382 if (!S_ISREG(sbuf
.st_ex_mode
)) {
384 _("info_fn: file %s is not a regular file. Ignoring.\n"),
390 lines
= fd_lines_load(fd
, &numlines
, 10240, NULL
);
397 /* Ensure it's well formed. */
398 us_err
= parse_usershare_file(ctx
, &sbuf
, fl
->pathname
, -1, lines
, numlines
,
407 if (us_err
!= USERSHARE_OK
) {
409 _("info_fn: file %s is not a well formed usershare "
412 d_fprintf(stderr
, _("info_fn: Error was %s.\n"),
413 get_us_error_code(us_err
) );
417 acl_str
= talloc_strdup(ctx
, "usershare_acl=");
422 for (num_aces
= 0; num_aces
< psd
->dacl
->num_aces
; num_aces
++) {
427 ntstatus
= net_lookup_name_from_sid(c
, ctx
,
428 &psd
->dacl
->aces
[num_aces
].trustee
,
431 if (NT_STATUS_IS_OK(ntstatus
)) {
432 if (domain
&& *domain
) {
433 acl_str
= talloc_asprintf_append(acl_str
,
441 acl_str
= talloc_asprintf_append(acl_str
,
450 sid_to_fstring(sidstr
,
451 &psd
->dacl
->aces
[num_aces
].trustee
);
452 acl_str
= talloc_asprintf_append(acl_str
,
459 acl_str
= talloc_asprintf_append(acl_str
, ":");
464 if (psd
->dacl
->aces
[num_aces
].type
== SEC_ACE_TYPE_ACCESS_DENIED
) {
465 acl_str
= talloc_asprintf_append(acl_str
, "D,");
470 if (psd
->dacl
->aces
[num_aces
].access_mask
& GENERIC_ALL_ACCESS
) {
471 acl_str
= talloc_asprintf_append(acl_str
, "F,");
473 acl_str
= talloc_asprintf_append(acl_str
, "R,");
481 /* NOTE: This is smb.conf-like output. Do not translate. */
482 if (pi
->op
== US_INFO_OP
) {
483 d_printf("[%s]\n", cp_sharename
);
484 d_printf("path=%s\n", sharepath
);
485 d_printf("comment=%s\n", comment
);
486 d_printf("%s\n", acl_str
);
487 d_printf("guest_ok=%c\n\n", guest_ok
? 'y' : 'n');
488 } else if (pi
->op
== US_LIST_OP
) {
489 d_printf("%s\n", cp_sharename
);
495 /***************************************************************************
496 Print out info (internal detail) on userlevel shares.
497 ***************************************************************************/
499 static int net_usershare_info(struct net_context
*c
, int argc
, const char **argv
)
502 bool only_ours
= true;
504 struct us_priv_info pi
;
509 if (c
->display_usage
)
510 return net_usershare_info_usage(c
, argc
, argv
);
512 if (c
->opt_long_list_entries
) {
520 fstrcpy(wcard
, argv
[0]);
523 return net_usershare_info_usage(c
, argc
, argv
);
526 if (!strlower_m(wcard
)) {
530 ctx
= talloc_init("share_info");
531 ret
= get_share_list(ctx
, wcard
, only_ours
);
540 ret
= process_share_list(info_fn
, &pi
);
545 /***************************************************************************
546 Count the current total number of usershares.
547 ***************************************************************************/
549 static int count_num_usershares(void)
553 int num_usershares
= 0;
554 TALLOC_CTX
*ctx
= talloc_tos();
555 char *basepath
= get_basepath(ctx
);
561 dp
= opendir(basepath
);
564 _("count_num_usershares: cannot open usershare "
565 "directory %s. Error %s\n"),
566 basepath
, strerror(errno
) );
570 while((de
= readdir(dp
)) != 0) {
571 SMB_STRUCT_STAT sbuf
;
573 const char *n
= de
->d_name
;
575 /* Ignore . and .. */
577 if ((n
[1] == '\0') || (n
[1] == '.' && n
[2] == '\0')) {
582 if (!validate_net_name(n
, INVALID_SHARENAME_CHARS
, strlen(n
))) {
584 _("count_num_usershares: ignoring bad share "
588 path
= talloc_asprintf(ctx
,
597 if (sys_lstat(path
, &sbuf
, false) != 0) {
599 _("count_num_usershares: can't lstat file %s. "
601 path
, strerror(errno
) );
605 if (!S_ISREG(sbuf
.st_ex_mode
)) {
607 _("count_num_usershares: file %s is not a "
608 "regular file. Ignoring.\n"),
616 return num_usershares
;
619 /***************************************************************************
620 Add a single userlevel share.
621 ***************************************************************************/
623 static int net_usershare_add(struct net_context
*c
, int argc
, const char **argv
)
625 TALLOC_CTX
*ctx
= talloc_stackframe();
626 SMB_STRUCT_STAT sbuf
;
627 SMB_STRUCT_STAT lsbuf
;
629 const char *cp_sharename
;
633 const char *us_comment
;
642 uid_t myeuid
= geteuid();
643 bool guest_ok
= false;
647 arg_acl
= "S-1-1-0:R";
649 if (c
->display_usage
)
650 return net_usershare_add_usage(c
, argc
, argv
);
656 return net_usershare_add_usage(c
, argc
, argv
);
658 cp_sharename
= argv
[0];
659 sharename
= strlower_talloc(ctx
, argv
[0]);
663 cp_sharename
= argv
[0];
664 sharename
= strlower_talloc(ctx
, argv
[0]);
666 us_comment
= argv
[2];
669 cp_sharename
= argv
[0];
670 sharename
= strlower_talloc(ctx
, argv
[0]);
672 us_comment
= argv
[2];
676 cp_sharename
= argv
[0];
677 sharename
= strlower_talloc(ctx
, argv
[0]);
679 us_comment
= argv
[2];
681 if (strlen(arg_acl
) == 0) {
682 arg_acl
= "S-1-1-0:R";
684 if (!strnequal(argv
[4], "guest_ok=", 9)) {
686 return net_usershare_add_usage(c
, argc
, argv
);
688 switch (argv
[4][9]) {
699 return net_usershare_add_usage(c
, argc
, argv
);
704 /* Ensure we're under the "usershare max shares" number. Advisory only. */
705 num_usershares
= count_num_usershares();
706 if (num_usershares
>= lp_usershare_max_shares()) {
708 _("net usershare add: maximum number of allowed "
709 "usershares (%d) reached\n"),
710 lp_usershare_max_shares() );
715 if (!validate_net_name(sharename
, INVALID_SHARENAME_CHARS
, strlen(sharename
))) {
716 d_fprintf(stderr
, _("net usershare add: share name %s contains "
717 "invalid characters (any of %s)\n"),
718 sharename
, INVALID_SHARENAME_CHARS
);
723 /* Disallow shares the same as users. */
724 if (getpwnam(sharename
)) {
726 _("net usershare add: share name %s is already a valid "
727 "system user name\n"),
733 /* Construct the full path for the usershare file. */
734 full_path
= get_basepath(ctx
);
739 full_path_tmp
= talloc_asprintf(ctx
,
742 if (!full_path_tmp
) {
747 full_path
= talloc_asprintf_append(full_path
,
755 /* The path *must* be absolute. */
756 if (us_path
[0] != '/') {
758 _("net usershare add: path %s is not an absolute "
765 /* Check the directory to be shared exists. */
766 if (sys_stat(us_path
, &sbuf
, false) != 0) {
768 _("net usershare add: cannot stat path %s to ensure "
769 "this is a directory. Error was %s\n"),
770 us_path
, strerror(errno
) );
775 if (!S_ISDIR(sbuf
.st_ex_mode
)) {
777 _("net usershare add: path %s is not a directory.\n"),
783 /* If we're not root, check if we're restricted to sharing out directories
786 if ((myeuid
!= 0) && lp_usershare_owner_only() && (myeuid
!= sbuf
.st_ex_uid
)) {
787 d_fprintf(stderr
, _("net usershare add: cannot share path %s as "
788 "we are restricted to only sharing directories we own.\n"
789 "\tAsk the administrator to add the line \"usershare owner only = false\" \n"
790 "\tto the [global] section of the smb.conf to allow this.\n"),
796 /* No validation needed on comment. Now go through and validate the
797 acl string. Convert names to SID's as needed. Then run it through
798 parse_usershare_acl to ensure it's valid. */
800 /* Start off the string we'll append to. */
801 us_acl
= talloc_strdup(ctx
, "");
810 /* Add the number of ',' characters to get the number of aces. */
811 num_aces
+= count_chars(pacl
,',');
813 for (i
= 0; i
< num_aces
; i
++) {
815 const char *pcolon
= strchr_m(pacl
, ':');
818 if (pcolon
== NULL
) {
820 _("net usershare add: malformed acl %s "
836 _("net usershare add: malformed acl %s "
837 "(access control must be 'r', 'f', "
844 if (pcolon
[2] != ',' && pcolon
[2] != '\0') {
846 _("net usershare add: malformed terminating "
847 "character for acl %s\n"),
854 if ((name
= talloc_strndup(ctx
, pacl
, pcolon
- pacl
)) == NULL
) {
855 d_fprintf(stderr
, _("talloc_strndup failed\n"));
859 if (!string_to_sid(&sid
, name
)) {
860 /* Convert to a SID */
861 NTSTATUS ntstatus
= net_lookup_sid_from_name(c
, ctx
, name
, &sid
);
862 if (!NT_STATUS_IS_OK(ntstatus
)) {
864 _("net usershare add: cannot convert "
865 "name \"%s\" to a SID. %s."),
866 name
, get_friendly_nt_error_msg(ntstatus
) );
867 if (NT_STATUS_EQUAL(ntstatus
, NT_STATUS_CONNECTION_REFUSED
)) {
869 _(" Maybe smbd is not running.\n"));
871 d_fprintf(stderr
, "\n");
877 us_acl
= talloc_asprintf_append(
878 us_acl
, "%s:%c,", sid_string_tos(&sid
), pcolon
[1]);
880 /* Move to the next ACL entry. */
881 if (pcolon
[2] == ',') {
886 /* Remove the last ',' */
887 us_acl
[strlen(us_acl
)-1] = '\0';
889 if (guest_ok
&& !lp_usershare_allow_guests()) {
890 d_fprintf(stderr
, _("net usershare add: guest_ok=y requested "
891 "but the \"usershare allow guests\" parameter is not "
892 "enabled by this server.\n"));
897 /* Create a temporary filename for this share. */
898 tmpfd
= mkstemp(full_path_tmp
);
902 _("net usershare add: cannot create tmp file %s\n"),
908 /* Ensure we opened the file we thought we did. */
909 if (sys_lstat(full_path_tmp
, &lsbuf
, false) != 0) {
911 _("net usershare add: cannot lstat tmp file %s\n"),
918 /* Check this is the same as the file we opened. */
919 if (sys_fstat(tmpfd
, &sbuf
, false) != 0) {
921 _("net usershare add: cannot fstat tmp file %s\n"),
928 if (!S_ISREG(sbuf
.st_ex_mode
) || sbuf
.st_ex_dev
!= lsbuf
.st_ex_dev
|| sbuf
.st_ex_ino
!= lsbuf
.st_ex_ino
) {
930 _("net usershare add: tmp file %s is not a regular "
938 if (fchmod(tmpfd
, 0644) == -1) {
940 _("net usershare add: failed to fchmod tmp file %s "
948 /* Create the in-memory image of the file. */
949 file_img
= talloc_strdup(ctx
, "#VERSION 2\npath=");
950 file_img
= talloc_asprintf_append(file_img
,
951 "%s\ncomment=%s\nusershare_acl=%s\n"
952 "guest_ok=%c\nsharename=%s\n",
956 guest_ok
? 'y' : 'n',
959 to_write
= strlen(file_img
);
961 if (write(tmpfd
, file_img
, to_write
) != to_write
) {
963 _("net usershare add: failed to write %u bytes to "
964 "file %s. Error was %s\n"),
965 (unsigned int)to_write
, full_path_tmp
, strerror(errno
));
966 unlink(full_path_tmp
);
972 /* Attempt to replace any existing share by this name. */
973 if (rename(full_path_tmp
, full_path
) != 0) {
974 unlink(full_path_tmp
);
976 _("net usershare add: failed to add share %s. Error "
978 sharename
, strerror(errno
));
986 if (c
->opt_long_list_entries
) {
987 const char *my_argv
[2];
988 my_argv
[0] = sharename
;
990 net_usershare_info(c
, 1, my_argv
);
998 /***************************************************************************
1000 ***************************************************************************/
1002 static int list_fn(struct file_list
*fl
, void *priv
)
1004 d_printf("%s\n", fl
->pathname
);
1009 /***************************************************************************
1010 List userlevel shares.
1011 ***************************************************************************/
1013 static int net_usershare_list(struct net_context
*c
, int argc
,
1017 bool only_ours
= true;
1019 struct us_priv_info pi
;
1022 fstrcpy(wcard
, "*");
1024 if (c
->display_usage
)
1025 return net_usershare_list_usage(c
, argc
, argv
);
1027 if (c
->opt_long_list_entries
) {
1035 fstrcpy(wcard
, argv
[0]);
1038 return net_usershare_list_usage(c
, argc
, argv
);
1041 if (!strlower_m(wcard
)) {
1045 ctx
= talloc_init("share_list");
1046 ret
= get_share_list(ctx
, wcard
, only_ours
);
1055 ret
= process_share_list(info_fn
, &pi
);
1056 talloc_destroy(ctx
);
1060 /***************************************************************************
1061 Entry-point for all the USERSHARE functions.
1062 ***************************************************************************/
1064 int net_usershare(struct net_context
*c
, int argc
, const char **argv
)
1068 struct functable func
[] = {
1072 NET_TRANSPORT_LOCAL
,
1073 N_("Add/modify user defined share"),
1074 N_("net usershare add\n"
1075 " Add/modify user defined share")
1079 net_usershare_delete
,
1080 NET_TRANSPORT_LOCAL
,
1081 N_("Delete user defined share"),
1082 N_("net usershare delete\n"
1083 " Delete user defined share")
1088 NET_TRANSPORT_LOCAL
,
1089 N_("Display information about a user defined share"),
1090 N_("net usershare info\n"
1091 " Display information about a user defined share")
1096 NET_TRANSPORT_LOCAL
,
1097 N_("List user defined shares"),
1098 N_("net usershare list\n"
1099 " List user defined shares")
1101 {NULL
, NULL
, 0, NULL
, NULL
}
1104 if (lp_usershare_max_shares() == 0) {
1106 _("net usershare: usershares are currently "
1111 dp
= opendir(lp_usershare_path(talloc_tos()));
1115 _("net usershare: cannot open usershare directory %s. "
1117 lp_usershare_path(talloc_tos()), strerror(err
) );
1118 if (err
== EACCES
) {
1120 _("You do not have permission to create a "
1121 "usershare. Ask your administrator to grant "
1122 "you permissions to create a share.\n"));
1123 } else if (err
== ENOENT
) {
1125 _("Please ask your system administrator to "
1126 "enable user sharing.\n"));
1132 return net_run_function(c
, argc
, argv
, "net usershare", func
);