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.
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.
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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
31 #include <smbsrv/smb_inet.h>
32 #include <smbsrv/smb_privilege.h>
33 #include <smbsrv/smb_sid.h>
36 * Don't want <smbsrv/netrauth.h> in here, but
37 * uts/common/fs/smbsrv/smb_authenticate.c
38 * wants this. Todo: cleanup
40 #define NETR_NETWORK_LOGON 0x02
47 * 32-bit opaque buffer (non-null terminated strings)
48 * See also: smb_buf32_xdr()
50 typedef struct smb_buf32
{
58 * An access token identifies a user, the user's privileges and the
59 * list of groups of which the user is a member. This information is
60 * used when access is requested to an object by comparing this
61 * information with the DACL in the object's security descriptor.
63 * There should be one unique token per user per session per client.
67 * SMB_ATF_GUEST Token belongs to guest user
68 * SMB_ATF_ANON Token belongs to anonymous user
69 * and it's only good for IPC Connection.
70 * SMB_ATF_POWERUSER Token belongs to a Power User member
71 * SMB_ATF_BACKUPOP Token belongs to a Power User member
72 * SMB_ATF_ADMIN Token belongs to a Domain Admins member
74 #define SMB_ATF_GUEST 0x00000001
75 #define SMB_ATF_ANON 0x00000002
76 #define SMB_ATF_POWERUSER 0x00000004
77 #define SMB_ATF_BACKUPOP 0x00000008
78 #define SMB_ATF_ADMIN 0x00000010
80 #define SMB_POSIX_GRPS_SIZE(n) \
81 (sizeof (smb_posix_grps_t) + (n - 1) * sizeof (gid_t))
83 * It consists of the primary and supplementary POSIX groups.
84 * See also: smb_posix_grps_xdr()
86 typedef struct smb_posix_grps
{
88 gid_t pg_grps
[ANY_SIZE_ARRAY
];
92 * An NT-style logon "token" (NT terminology)
93 * See also: smb_token_xdr()
95 typedef struct smb_token
{
98 smb_id_t tkn_primary_grp
;
99 smb_ids_t tkn_win_grps
;
100 smb_privset_t
*tkn_privileges
;
101 char *tkn_account_name
;
102 char *tkn_domain_name
;
104 uint32_t tkn_audit_sid
;
105 smb_buf32_t tkn_ssnkey
;
106 smb_posix_grps_t
*tkn_posix_grps
;
110 * Details required to authenticate a user.
111 * See also: smb_logon_xdr()
113 typedef struct smb_logon
{
115 char *lg_username
; /* requested username */
116 char *lg_domain
; /* requested domain */
117 char *lg_e_username
; /* effective username */
118 char *lg_e_domain
; /* effective domain */
119 char *lg_workstation
;
120 smb_inaddr_t lg_clnt_ipaddr
;
121 smb_inaddr_t lg_local_ipaddr
;
122 uint16_t lg_local_port
;
123 smb_buf32_t lg_challenge_key
;
124 smb_buf32_t lg_nt_password
;
125 smb_buf32_t lg_lm_password
;
126 uint32_t lg_ntlm_flags
;
130 uint32_t lg_logon_id
; /* filled in user space */
131 uint32_t lg_domain_type
; /* filled in user space */
132 uint32_t lg_secmode
; /* filled in user space */
133 uint32_t lg_status
; /* filled in user space */
137 * This is the name of the local (AF_UNIX) socket
138 * where the SMB auth. service listens.
140 #define SMB_AUTHSVC_SOCKNAME "/var/smb/lipc/smbauth"
143 * Maximum number of authentcation conversations at one time.
144 * Note this is _NOT_ the max. number of logged on users,
145 * which can be much larger.
147 #define SMB_AUTHSVC_MAXTHREAD 256
150 * Messages to and from the local security authority
153 typedef enum smb_lsa_mtype
{
157 LSA_MTYPE_ES_DONE
, /* ext. sec: authenticated */
158 LSA_MTYPE_ES_CONT
, /* more processing required */
159 LSA_MTYPE_TOKEN
, /* smb_token_t */
162 LSA_MTYPE_OLDREQ
, /* non-ext. sec. session setup */
163 LSA_MTYPE_CLINFO
, /* client info sent at start of ES */
164 LSA_MTYPE_ESFIRST
, /* spnego initial message */
165 LSA_MTYPE_ESNEXT
, /* spnego continuation */
166 LSA_MTYPE_GETTOK
/* after ES auth, get token */
170 * msg: header common to all message types
172 typedef struct smb_lsa_msg_hdr
{
173 uint32_t lmh_msgtype
; /* smb_lsa_mtype_t */
174 uint32_t lmh_msglen
; /* size of what follows */
178 * eresp: error response
179 * msgtype: LSA_MTYPE_ERESP
181 typedef struct smb_lsa_eresp
{
182 uint32_t ler_ntstatus
;
183 uint16_t ler_errclass
;
184 uint16_t ler_errcode
;
188 * Message for LSA_MTYPE_CLINFO
190 typedef struct smb_lsa_clinfo
{
191 smb_inaddr_t lci_clnt_ipaddr
;
192 unsigned char lci_challenge_key
[8];
198 int smb_logon_xdr(struct XDR
*, smb_logon_t
*);
199 int smb_token_xdr(struct XDR
*, smb_token_t
*);
202 void smb_token_free(smb_token_t
*);
204 smb_token_t
*smb_logon(smb_logon_t
*);
205 void smb_logon_abort(void);
206 void smb_token_destroy(smb_token_t
*);
207 uint8_t *smb_token_encode(smb_token_t
*, uint32_t *);
208 void smb_token_log(smb_token_t
*);
209 smb_logon_t
*smb_logon_decode(uint8_t *, uint32_t);
210 void smb_logon_free(smb_logon_t
*);
213 int smb_token_query_privilege(smb_token_t
*token
, int priv_id
);
214 boolean_t
smb_token_valid(smb_token_t
*);
220 #endif /* _SMB_TOKEN_H */