2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
17 * Replace the smb_shr_load() function in libmlsvc, because
18 * fksmbd doesn't want the real shares known by libshare,
19 * instead preferring its own (fake) list of shares.
22 #include <sys/types.h>
34 #include <smbsrv/libsmb.h>
35 #include <smbsrv/libsmbns.h>
36 #include <smbsrv/libmlsvc.h>
37 #include <smbsrv/smb_share.h>
38 #include <smbsrv/smb.h>
41 new_share(char *name
, char *path
, char *comment
, int flags
)
45 bzero(&si
, sizeof (si
));
46 (void) strlcpy(si
.shr_name
, name
, MAXNAMELEN
);
47 (void) strlcpy(si
.shr_path
, path
, MAXPATHLEN
);
48 (void) strlcpy(si
.shr_cmnt
, comment
, SMB_SHARE_CMNT_MAX
);
50 if (smb_shr_add(&si
) != 0) {
51 syslog(LOG_ERR
, "failed to add test share: %s",
57 * This function loads a list of shares from a text file, where
58 * each line of the file contains:
61 * This is only for fksmbd, for testing.
64 shr_load_file(char *shr_file
)
69 char *name
, *path
, *comment
;
71 fp
= fopen(shr_file
, "r");
77 while ((p
= fgets(linebuf
, sizeof (linebuf
), fp
)) != NULL
) {
80 p
= strpbrk(p
, " \t\n");
86 p
= strpbrk(p
, " \t\n");
97 new_share(name
, path
, comment
, 0);
104 smb_shr_load(void *args
)
107 _NOTE(ARGUNUSED(args
))
110 * Not loading the real shares in fksmbd because that
111 * tries to enable the network/smb/server service.
112 * Also, we won't generally have access to everything
113 * in the real shares, because fksmbd runs (only) with
114 * the credentials of the user who runs it.
116 new_share("test", "/var/smb/test", "fksmbd test share",
119 /* Allow creating lots of shares for testing. */
120 shr_file
= getenv("FKSMBD_SHARE_FILE");
121 if (shr_file
!= NULL
)
122 shr_load_file(shr_file
);