author | natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM> |
Tue, 28 Oct 2008 03:34:04 -0700 | |
changeset 7961 | 4b5e3051f38b |
parent 7348 | 73b61202d5d6 |
child 8334 | 5f1c6a3b0fad |
permissions | -rw-r--r-- |
5331 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
5 |
* Common Development and Distribution License (the "License"). |
|
6 |
* You may not use this file except in compliance with the License. |
|
7 |
* |
|
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
22 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
5331 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <sys/types.h> |
|
27 |
#include <stdarg.h> |
|
28 |
#include <unistd.h> |
|
29 |
#include <stdlib.h> |
|
30 |
#include <time.h> |
|
31 |
#include <synch.h> |
|
32 |
#include <syslog.h> |
|
33 |
#include <string.h> |
|
34 |
#include <strings.h> |
|
35 |
#include <errno.h> |
|
36 |
#include <net/if.h> |
|
37 |
#include <netdb.h> |
|
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
38 |
#include <netinet/in.h> |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
39 |
#include <arpa/nameser.h> |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
40 |
#include <resolv.h> |
5331 | 41 |
#include <sys/sockio.h> |
42 |
#include <smbsrv/smbinfo.h> |
|
43 |
#include <smbsrv/netbios.h> |
|
44 |
#include <smbsrv/libsmb.h> |
|
45 |
||
46 |
static smb_ntdomain_t smbpdc_cache; |
|
47 |
static mutex_t smbpdc_mtx; |
|
48 |
static cond_t smbpdc_cv; |
|
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
49 |
static mutex_t seqnum_mtx; |
5331 | 50 |
|
51 |
extern int getdomainname(char *, int); |
|
52 |
||
5521
cf62335046cd
6575640 rename/rmdir/remove on mixed file systems work incorrectly for mangled names
as200622
parents:
5331
diff
changeset
|
53 |
/* |
5331 | 54 |
* smb_getdomaininfo |
55 |
* |
|
56 |
* Returns a pointer to the cached domain data. The caller can specify |
|
57 |
* whether or not he is prepared to wait if the cache is not yet valid |
|
58 |
* and for how long. The specified timeout is in seconds. |
|
59 |
*/ |
|
60 |
smb_ntdomain_t * |
|
61 |
smb_getdomaininfo(uint32_t timeout) |
|
62 |
{ |
|
63 |
timestruc_t to; |
|
64 |
int err; |
|
65 |
||
66 |
if (timeout != 0) { |
|
67 |
(void) mutex_lock(&smbpdc_mtx); |
|
68 |
while (smbpdc_cache.ipaddr == 0) { |
|
69 |
to.tv_sec = timeout; |
|
70 |
to.tv_nsec = 0; |
|
71 |
err = cond_reltimedwait(&smbpdc_cv, &smbpdc_mtx, &to); |
|
72 |
if (err == ETIME) |
|
73 |
break; |
|
74 |
} |
|
75 |
(void) mutex_unlock(&smbpdc_mtx); |
|
76 |
} |
|
77 |
||
78 |
if (smbpdc_cache.ipaddr != 0) |
|
79 |
return (&smbpdc_cache); |
|
80 |
else |
|
81 |
return (0); |
|
82 |
} |
|
83 |
||
84 |
void |
|
85 |
smb_logdomaininfo(smb_ntdomain_t *di) |
|
86 |
{ |
|
87 |
char ipstr[16]; |
|
88 |
||
89 |
(void) inet_ntop(AF_INET, (const void *)&di->ipaddr, ipstr, |
|
90 |
sizeof (ipstr)); |
|
91 |
syslog(LOG_DEBUG, "smbd: %s (%s:%s)", di->domain, di->server, ipstr); |
|
92 |
} |
|
93 |
||
94 |
/* |
|
95 |
* smb_setdomaininfo |
|
96 |
* |
|
97 |
* Set the information for the specified domain. If the information is |
|
98 |
* non-null, the notification event is raised to wakeup any threads |
|
99 |
* blocking on the cache. |
|
100 |
*/ |
|
101 |
void |
|
102 |
smb_setdomaininfo(char *domain, char *server, uint32_t ipaddr) |
|
103 |
{ |
|
104 |
char *p; |
|
105 |
||
7348
73b61202d5d6
6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents:
6600
diff
changeset
|
106 |
(void) mutex_lock(&smbpdc_mtx); |
5331 | 107 |
bzero(&smbpdc_cache, sizeof (smb_ntdomain_t)); |
108 |
if (domain && server && ipaddr) { |
|
109 |
(void) strlcpy(smbpdc_cache.domain, domain, SMB_PI_MAX_DOMAIN); |
|
110 |
(void) strlcpy(smbpdc_cache.server, server, SMB_PI_MAX_DOMAIN); |
|
111 |
||
112 |
/* |
|
113 |
* Remove DNS domain name extension |
|
114 |
* to avoid confusing NetBIOS. |
|
115 |
*/ |
|
116 |
if ((p = strchr(smbpdc_cache.domain, '.')) != 0) |
|
117 |
*p = '\0'; |
|
118 |
||
119 |
if ((p = strchr(smbpdc_cache.server, '.')) != 0) |
|
120 |
*p = '\0'; |
|
121 |
||
122 |
smbpdc_cache.ipaddr = ipaddr; |
|
123 |
(void) cond_broadcast(&smbpdc_cv); |
|
124 |
} |
|
7348
73b61202d5d6
6584155 Confusing 'No such object' message is logged when a share is successfully published.
jose borrego <Jose.Borrego@Sun.COM>
parents:
6600
diff
changeset
|
125 |
(void) mutex_unlock(&smbpdc_mtx); |
5331 | 126 |
} |
127 |
||
128 |
void |
|
129 |
smb_load_kconfig(smb_kmod_cfg_t *kcfg) |
|
130 |
{ |
|
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
131 |
int64_t citem; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
132 |
|
5331 | 133 |
bzero(kcfg, sizeof (smb_kmod_cfg_t)); |
134 |
||
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
135 |
(void) smb_config_getnum(SMB_CI_MAX_WORKERS, &citem); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
136 |
kcfg->skc_maxworkers = (uint32_t)citem; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
137 |
(void) smb_config_getnum(SMB_CI_KEEPALIVE, &citem); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
138 |
kcfg->skc_keepalive = (uint32_t)citem; |
5331 | 139 |
if ((kcfg->skc_keepalive != 0) && |
140 |
(kcfg->skc_keepalive < SMB_PI_KEEP_ALIVE_MIN)) |
|
141 |
kcfg->skc_keepalive = SMB_PI_KEEP_ALIVE_MIN; |
|
142 |
||
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
143 |
(void) smb_config_getnum(SMB_CI_MAX_CONNECTIONS, &citem); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
144 |
kcfg->skc_maxconnections = (uint32_t)citem; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
145 |
kcfg->skc_restrict_anon = smb_config_getbool(SMB_CI_RESTRICT_ANON); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
146 |
kcfg->skc_signing_enable = smb_config_getbool(SMB_CI_SIGNING_ENABLE); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
147 |
kcfg->skc_signing_required = smb_config_getbool(SMB_CI_SIGNING_REQD); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
148 |
kcfg->skc_oplock_enable = smb_config_getbool(SMB_CI_OPLOCK_ENABLE); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
149 |
kcfg->skc_sync_enable = smb_config_getbool(SMB_CI_SYNC_ENABLE); |
5331 | 150 |
kcfg->skc_secmode = smb_config_get_secmode(); |
7961
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
151 |
(void) smb_getdomainname(kcfg->skc_nbdomain, |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
152 |
sizeof (kcfg->skc_nbdomain)); |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
153 |
(void) smb_getfqdomainname(kcfg->skc_fqdn, |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
154 |
sizeof (kcfg->skc_fqdn)); |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
155 |
(void) smb_getnetbiosname(kcfg->skc_hostname, |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
156 |
sizeof (kcfg->skc_hostname)); |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
157 |
(void) smb_config_getstr(SMB_CI_SYS_CMNT, kcfg->skc_system_comment, |
5331 | 158 |
sizeof (kcfg->skc_system_comment)); |
159 |
} |
|
160 |
||
161 |
/* |
|
162 |
* Get the current system NetBIOS name. The hostname is truncated at |
|
163 |
* the first `.` or 15 bytes, whichever occurs first, and converted |
|
164 |
* to uppercase (by smb_gethostname). Text that appears after the |
|
165 |
* first '.' is considered to be part of the NetBIOS scope. |
|
166 |
* |
|
167 |
* Returns 0 on success, otherwise -1 to indicate an error. |
|
168 |
*/ |
|
169 |
int |
|
170 |
smb_getnetbiosname(char *buf, size_t buflen) |
|
171 |
{ |
|
172 |
if (smb_gethostname(buf, buflen, 1) != 0) |
|
173 |
return (-1); |
|
174 |
||
175 |
if (buflen >= NETBIOS_NAME_SZ) |
|
176 |
buf[NETBIOS_NAME_SZ - 1] = '\0'; |
|
177 |
||
178 |
return (0); |
|
179 |
} |
|
180 |
||
181 |
/* |
|
7961
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
182 |
* Get the SAM account of the current system. |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
183 |
* Returns 0 on success, otherwise, -1 to indicate an error. |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
184 |
*/ |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
185 |
int |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
186 |
smb_getsamaccount(char *buf, size_t buflen) |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
187 |
{ |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
188 |
if (smb_getnetbiosname(buf, buflen - 1) != 0) |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
189 |
return (-1); |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
190 |
|
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
191 |
(void) strlcat(buf, "$", buflen); |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
192 |
return (0); |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
193 |
} |
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
194 |
|
4b5e3051f38b
6751647 TRANS2_FIND_NEXT continuation by filename restarts search at beginning of directory
natalie li - Sun Microsystems - Irvine United States <Natalie.Li@Sun.COM>
parents:
7348
diff
changeset
|
195 |
/* |
5331 | 196 |
* Get the current system node name. The returned name is guaranteed |
197 |
* to be null-terminated (gethostname may not null terminate the name). |
|
198 |
* If the hostname has been fully-qualified for some reason, the domain |
|
199 |
* part will be removed. If the caller would like the name in upper |
|
200 |
* case, it is folded to uppercase. |
|
201 |
* |
|
202 |
* If gethostname fails, the returned buffer will contain an empty |
|
203 |
* string. |
|
204 |
*/ |
|
205 |
int |
|
206 |
smb_gethostname(char *buf, size_t buflen, int upcase) |
|
207 |
{ |
|
208 |
char *p; |
|
209 |
||
210 |
if (buf == NULL || buflen == 0) |
|
211 |
return (-1); |
|
212 |
||
213 |
if (gethostname(buf, buflen) != 0) { |
|
214 |
*buf = '\0'; |
|
215 |
return (-1); |
|
216 |
} |
|
217 |
||
218 |
buf[buflen - 1] = '\0'; |
|
219 |
||
220 |
if ((p = strchr(buf, '.')) != NULL) |
|
221 |
*p = '\0'; |
|
222 |
||
223 |
if (upcase) |
|
224 |
(void) utf8_strupr(buf); |
|
225 |
||
226 |
return (0); |
|
227 |
} |
|
228 |
||
229 |
/* |
|
230 |
* Obtain the fully-qualified name for this machine. If the |
|
231 |
* hostname is fully-qualified, accept it. Otherwise, try to |
|
232 |
* find an appropriate domain name to append to the hostname. |
|
233 |
*/ |
|
234 |
int |
|
235 |
smb_getfqhostname(char *buf, size_t buflen) |
|
236 |
{ |
|
237 |
char hostname[MAXHOSTNAMELEN]; |
|
238 |
char domain[MAXHOSTNAMELEN]; |
|
239 |
||
240 |
hostname[0] = '\0'; |
|
241 |
domain[0] = '\0'; |
|
242 |
||
243 |
if (smb_gethostname(hostname, MAXHOSTNAMELEN, 0) != 0) |
|
244 |
return (-1); |
|
245 |
||
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
246 |
if (smb_getfqdomainname(domain, MAXHOSTNAMELEN) != 0) |
5331 | 247 |
return (-1); |
248 |
||
249 |
if (hostname[0] == '\0') |
|
250 |
return (-1); |
|
251 |
||
252 |
if (domain[0] == '\0') { |
|
253 |
(void) strlcpy(buf, hostname, buflen); |
|
254 |
return (0); |
|
255 |
} |
|
256 |
||
257 |
(void) snprintf(buf, buflen, "%s.%s", hostname, domain); |
|
258 |
return (0); |
|
259 |
} |
|
260 |
||
261 |
/* |
|
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
262 |
* smb_resolve_netbiosname |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
263 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
264 |
* Convert the fully-qualified domain name (i.e. fqdn) to a NETBIOS name. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
265 |
* Upon success, the NETBIOS name will be returned via buf parameter. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
266 |
* Returns 0 upon success. Otherwise, returns -1. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
267 |
*/ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
268 |
int |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
269 |
smb_resolve_netbiosname(char *fqdn, char *buf, size_t buflen) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
270 |
{ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
271 |
char *p; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
272 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
273 |
if (!buf) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
274 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
275 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
276 |
*buf = '\0'; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
277 |
if (!fqdn) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
278 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
279 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
280 |
(void) strlcpy(buf, fqdn, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
281 |
if ((p = strchr(buf, '.')) != NULL) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
282 |
*p = 0; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
283 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
284 |
if (strlen(buf) >= NETBIOS_NAME_SZ) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
285 |
buf[NETBIOS_NAME_SZ - 1] = '\0'; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
286 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
287 |
return (0); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
288 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
289 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
290 |
/* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
291 |
* smb_getdomainname |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
292 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
293 |
* Returns NETBIOS name of the domain if the system is in domain |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
294 |
* mode. Or returns workgroup name if the system is in workgroup |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
295 |
* mode. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
296 |
*/ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
297 |
int |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
298 |
smb_getdomainname(char *buf, size_t buflen) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
299 |
{ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
300 |
char domain[MAXHOSTNAMELEN]; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
301 |
int rc; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
302 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
303 |
if (buf == NULL || buflen == 0) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
304 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
305 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
306 |
*buf = '\0'; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
307 |
rc = smb_config_getstr(SMB_CI_DOMAIN_NAME, domain, |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
308 |
sizeof (domain)); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
309 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
310 |
if ((rc != SMBD_SMF_OK) || (*domain == '\0')) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
311 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
312 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
313 |
(void) smb_resolve_netbiosname(domain, buf, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
314 |
return (0); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
315 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
316 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
317 |
/* |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
318 |
* smb_getdomainsid |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
319 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
320 |
* Returns the domain SID if the system is in domain mode. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
321 |
* Otherwise returns NULL. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
322 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
323 |
* Note: Callers are responsible for freeing a returned SID. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
324 |
*/ |
6432
98715880dd9e
6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents:
6139
diff
changeset
|
325 |
smb_sid_t * |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
326 |
smb_getdomainsid(void) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
327 |
{ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
328 |
char buf[MAXHOSTNAMELEN]; |
6432
98715880dd9e
6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents:
6139
diff
changeset
|
329 |
smb_sid_t *sid; |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
330 |
int security_mode; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
331 |
int rc; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
332 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
333 |
security_mode = smb_config_get_secmode(); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
334 |
if (security_mode != SMB_SECMODE_DOMAIN) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
335 |
return (NULL); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
336 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
337 |
*buf = '\0'; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
338 |
rc = smb_config_getstr(SMB_CI_DOMAIN_SID, buf, MAXHOSTNAMELEN); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
339 |
if ((rc != SMBD_SMF_OK) || (*buf == '\0')) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
340 |
return (NULL); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
341 |
|
6432
98715880dd9e
6666802 Cannot copy >1023 byte readonly file from Vista client to Solaris CIFS share
as200622
parents:
6139
diff
changeset
|
342 |
if ((sid = smb_sid_fromstr(buf)) == NULL) |
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
343 |
return (NULL); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
344 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
345 |
return (sid); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
346 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
347 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
348 |
/* |
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
349 |
* smb_resolve_fqdn |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
350 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
351 |
* Converts the NETBIOS name of the domain (i.e. nbt_domain) to a fully |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
352 |
* qualified domain name. The domain from either the domain field or |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
353 |
* search list field of the /etc/resolv.conf will be returned via the |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
354 |
* buf parameter if the first label of the domain matches the given |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
355 |
* NETBIOS name. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
356 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
357 |
* Returns -1 upon error. If a match is found, returns 1. Otherwise, |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
358 |
* returns 0. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
359 |
*/ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
360 |
int |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
361 |
smb_resolve_fqdn(char *nbt_domain, char *buf, size_t buflen) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
362 |
{ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
363 |
struct __res_state res_state; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
364 |
int i, found = 0; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
365 |
char *p; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
366 |
int dlen; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
367 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
368 |
if (!buf) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
369 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
370 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
371 |
*buf = '\0'; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
372 |
if (!nbt_domain) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
373 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
374 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
375 |
bzero(&res_state, sizeof (struct __res_state)); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
376 |
if (res_ninit(&res_state)) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
377 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
378 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
379 |
if (*nbt_domain == '\0') { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
380 |
if (*res_state.defdname == '\0') { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
381 |
res_ndestroy(&res_state); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
382 |
return (0); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
383 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
384 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
385 |
(void) strlcpy(buf, res_state.defdname, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
386 |
res_ndestroy(&res_state); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
387 |
return (1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
388 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
389 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
390 |
dlen = strlen(nbt_domain); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
391 |
if (!strncasecmp(nbt_domain, res_state.defdname, dlen)) { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
392 |
(void) strlcpy(buf, res_state.defdname, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
393 |
res_ndestroy(&res_state); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
394 |
return (1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
395 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
396 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
397 |
for (i = 0; (p = res_state.dnsrch[i]) != NULL; i++) { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
398 |
if (!strncasecmp(nbt_domain, p, dlen)) { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
399 |
(void) strlcpy(buf, p, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
400 |
found = 1; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
401 |
break; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
402 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
403 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
404 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
405 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
406 |
res_ndestroy(&res_state); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
407 |
return (found); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
408 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
409 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
410 |
/* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
411 |
* smb_getfqdomainname |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
412 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
413 |
* If the domain_name property value is FQDN, it will be returned. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
414 |
* In domain mode, the domain from either the domain field or |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
415 |
* search list field of the /etc/resolv.conf will be returned via the |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
416 |
* buf parameter if the first label of the domain matches the |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
417 |
* domain_name property. In workgroup mode, it returns the local |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
418 |
* domain. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
419 |
* |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
420 |
* Returns 0 upon success. Otherwise, returns -1. |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
421 |
*/ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
422 |
int |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
423 |
smb_getfqdomainname(char *buf, size_t buflen) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
424 |
{ |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
425 |
char domain[MAXHOSTNAMELEN]; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
426 |
int rc = 0; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
427 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
428 |
if (buf == NULL || buflen == 0) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
429 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
430 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
431 |
*buf = '\0'; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
432 |
if (smb_config_get_secmode() == SMB_SECMODE_DOMAIN) { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
433 |
rc = smb_config_getstr(SMB_CI_DOMAIN_NAME, domain, |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
434 |
sizeof (domain)); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
435 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
436 |
if ((rc != SMBD_SMF_OK) || (*domain == '\0')) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
437 |
return (-1); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
438 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
439 |
if (strchr(domain, '.') == NULL) { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
440 |
if (smb_resolve_fqdn(domain, buf, buflen) != 1) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
441 |
rc = -1; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
442 |
} else { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
443 |
(void) strlcpy(buf, domain, buflen); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
444 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
445 |
} else { |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
446 |
if (smb_resolve_fqdn("", buf, buflen) != 1) |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
447 |
rc = -1; |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
448 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
449 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
450 |
return (rc); |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
451 |
} |
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
452 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
453 |
|
6139
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
454 |
/* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
455 |
* smb_set_machine_passwd |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
456 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
457 |
* This function should be used when setting the machine password property. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
458 |
* The associated sequence number is incremented. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
459 |
*/ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
460 |
static int |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
461 |
smb_set_machine_passwd(char *passwd) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
462 |
{ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
463 |
int64_t num; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
464 |
int rc = -1; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
465 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
466 |
if (smb_config_set(SMB_CI_MACHINE_PASSWD, passwd) != SMBD_SMF_OK) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
467 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
468 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
469 |
(void) mutex_lock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
470 |
(void) smb_config_getnum(SMB_CI_KPASSWD_SEQNUM, &num); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
471 |
if (smb_config_setnum(SMB_CI_KPASSWD_SEQNUM, ++num) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
472 |
== SMBD_SMF_OK) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
473 |
rc = 0; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
474 |
(void) mutex_unlock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
475 |
return (rc); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
476 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
477 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
478 |
/* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
479 |
* smb_match_netlogon_seqnum |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
480 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
481 |
* A sequence number is associated with each machine password property |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
482 |
* update and the netlogon credential chain setup. If the |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
483 |
* sequence numbers don't match, a NETLOGON credential chain |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
484 |
* establishment is required. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
485 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
486 |
* Returns 0 if kpasswd_seqnum equals to netlogon_seqnum. Otherwise, |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
487 |
* returns -1. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
488 |
*/ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
489 |
boolean_t |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
490 |
smb_match_netlogon_seqnum(void) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
491 |
{ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
492 |
int64_t setpasswd_seqnum; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
493 |
int64_t netlogon_seqnum; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
494 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
495 |
(void) mutex_lock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
496 |
(void) smb_config_getnum(SMB_CI_KPASSWD_SEQNUM, &setpasswd_seqnum); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
497 |
(void) smb_config_getnum(SMB_CI_NETLOGON_SEQNUM, &netlogon_seqnum); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
498 |
(void) mutex_unlock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
499 |
return (setpasswd_seqnum == netlogon_seqnum); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
500 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
501 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
502 |
/* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
503 |
* smb_setdomainprops |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
504 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
505 |
* This function should be called after joining an AD to |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
506 |
* set all the domain related SMF properties. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
507 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
508 |
* The kpasswd_domain property is the AD domain to which the system |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
509 |
* is joined via kclient. If this function is invoked by the SMB |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
510 |
* daemon, fqdn should be set to NULL. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
511 |
*/ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
512 |
int |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
513 |
smb_setdomainprops(char *fqdn, char *server, char *passwd) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
514 |
{ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
515 |
if (server == NULL || passwd == NULL) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
516 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
517 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
518 |
if ((*server == '\0') || (*passwd == '\0')) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
519 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
520 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
521 |
if (fqdn && (smb_config_set(SMB_CI_KPASSWD_DOMAIN, fqdn) != 0)) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
522 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
523 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
524 |
if (smb_config_set(SMB_CI_KPASSWD_SRV, server) != 0) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
525 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
526 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
527 |
if (smb_set_machine_passwd(passwd) != 0) { |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
528 |
syslog(LOG_ERR, "smb_setdomainprops: failed to set" |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
529 |
" machine account password"); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
530 |
return (-1); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
531 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
532 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
533 |
/* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
534 |
* If we successfully create a trust account, we mark |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
535 |
* ourselves as a domain member in the environment so |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
536 |
* that we use the SAMLOGON version of the NETLOGON |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
537 |
* PDC location protocol. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
538 |
*/ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
539 |
(void) smb_config_setbool(SMB_CI_DOMAIN_MEMB, B_TRUE); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
540 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
541 |
return (0); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
542 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
543 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
544 |
/* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
545 |
* smb_update_netlogon_seqnum |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
546 |
* |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
547 |
* This function should only be called upon a successful netlogon |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
548 |
* credential chain establishment to set the sequence number of the |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
549 |
* netlogon to match with that of the kpasswd. |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
550 |
*/ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
551 |
void |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
552 |
smb_update_netlogon_seqnum(void) |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
553 |
{ |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
554 |
int64_t num; |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
555 |
|
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
556 |
(void) mutex_lock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
557 |
(void) smb_config_getnum(SMB_CI_KPASSWD_SEQNUM, &num); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
558 |
(void) smb_config_setnum(SMB_CI_NETLOGON_SEQNUM, num); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
559 |
(void) mutex_unlock(&seqnum_mtx); |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
560 |
} |
5c743b207bf9
6541120 Configuration is not propagated to SMB kernel module
jb150015
parents:
6030
diff
changeset
|
561 |
|
5772
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
562 |
|
237ac22142fe
6560095 SNAS shows SIDs for Built-in Groups members instead of name
as200622
parents:
5521
diff
changeset
|
563 |
/* |
5331 | 564 |
* Temporary fbt for dtrace until user space sdt enabled. |
565 |
*/ |
|
566 |
void |
|
567 |
smb_tracef(const char *fmt, ...) |
|
568 |
{ |
|
569 |
va_list ap; |
|
570 |
char buf[128]; |
|
571 |
||
572 |
va_start(ap, fmt); |
|
573 |
(void) vsnprintf(buf, 128, fmt, ap); |
|
574 |
va_end(ap); |
|
575 |
||
576 |
smb_trace(buf); |
|
577 |
} |
|
578 |
||
579 |
/* |
|
580 |
* Temporary fbt for dtrace until user space sdt enabled. |
|
581 |
*/ |
|
582 |
void |
|
583 |
smb_trace(const char *s) |
|
584 |
{ |
|
585 |
syslog(LOG_DEBUG, "%s", s); |
|
586 |
} |
|
6030
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
587 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
588 |
/* |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
589 |
* smb_tonetbiosname |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
590 |
* |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
591 |
* Creates a NetBIOS name based on the given name and suffix. |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
592 |
* NetBIOS name is 15 capital characters, padded with space if needed |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
593 |
* and the 16th byte is the suffix. |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
594 |
*/ |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
595 |
void |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
596 |
smb_tonetbiosname(char *name, char *nb_name, char suffix) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
597 |
{ |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
598 |
char tmp_name[NETBIOS_NAME_SZ]; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
599 |
mts_wchar_t wtmp_name[NETBIOS_NAME_SZ]; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
600 |
unsigned int cpid; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
601 |
int len; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
602 |
size_t rc; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
603 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
604 |
len = 0; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
605 |
rc = mts_mbstowcs(wtmp_name, (const char *)name, NETBIOS_NAME_SZ); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
606 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
607 |
if (rc != (size_t)-1) { |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
608 |
wtmp_name[NETBIOS_NAME_SZ - 1] = 0; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
609 |
cpid = oem_get_smb_cpid(); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
610 |
rc = unicodestooems(tmp_name, wtmp_name, NETBIOS_NAME_SZ, cpid); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
611 |
if (rc > 0) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
612 |
len = strlen(tmp_name); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
613 |
} |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
614 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
615 |
(void) memset(nb_name, ' ', NETBIOS_NAME_SZ - 1); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
616 |
if (len) { |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
617 |
(void) utf8_strupr(tmp_name); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
618 |
(void) memcpy(nb_name, tmp_name, len); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
619 |
} |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
620 |
nb_name[NETBIOS_NAME_SZ - 1] = suffix; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
621 |
} |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
622 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
623 |
int |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
624 |
smb_get_nameservers(struct in_addr *ips, int sz) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
625 |
{ |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
626 |
union res_sockaddr_union set[MAXNS]; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
627 |
int i, cnt; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
628 |
struct __res_state res_state; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
629 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
630 |
if (ips == NULL) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
631 |
return (0); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
632 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
633 |
bzero(&res_state, sizeof (struct __res_state)); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
634 |
if (res_ninit(&res_state) < 0) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
635 |
return (0); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
636 |
|
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
637 |
cnt = res_getservers(&res_state, set, MAXNS); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
638 |
for (i = 0; i < cnt; i++) { |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
639 |
if (i >= sz) |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
640 |
break; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
641 |
ips[i] = set[i].sin.sin_addr; |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
642 |
syslog(LOG_DEBUG, "NS Found %s name server\n", |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
643 |
inet_ntoa(ips[i])); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
644 |
} |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
645 |
syslog(LOG_DEBUG, "NS Found %d name servers\n", i); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
646 |
res_ndestroy(&res_state); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
647 |
return (i); |
6bebab7d43d5
6653315 Want smb interface to associate hostname with network interfaces
jb150015
parents:
5772
diff
changeset
|
648 |
} |