xref: /onnv-gate/usr/src/uts/common/smbsrv/smb_token.h (revision 11963:061945695ce1)
15331Samw /*
25331Samw  * CDDL HEADER START
35331Samw  *
45331Samw  * The contents of this file are subject to the terms of the
55331Samw  * Common Development and Distribution License (the "License").
65331Samw  * You may not use this file except in compliance with the License.
75331Samw  *
85331Samw  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95331Samw  * or http://www.opensolaris.org/os/licensing.
105331Samw  * See the License for the specific language governing permissions
115331Samw  * and limitations under the License.
125331Samw  *
135331Samw  * When distributing Covered Code, include this CDDL HEADER in each
145331Samw  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155331Samw  * If applicable, add the following below this CDDL HEADER, with the
165331Samw  * fields enclosed by brackets "[]" replaced with your own identifying
175331Samw  * information: Portions Copyright [yyyy] [name of copyright owner]
185331Samw  *
195331Samw  * CDDL HEADER END
205331Samw  */
215331Samw /*
22*11963SAfshin.Ardakani@Sun.COM  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
235331Samw  * Use is subject to license terms.
245331Samw  */
255331Samw 
265331Samw #ifndef _SMB_TOKEN_H
275331Samw #define	_SMB_TOKEN_H
285331Samw 
295331Samw #include <smbsrv/netrauth.h>
305331Samw #include <smbsrv/smb_privilege.h>
316432Sas200622 #include <smbsrv/smb_sid.h>
328670SJose.Borrego@Sun.COM #include <smbsrv/smb_xdr.h>
335331Samw 
345331Samw #ifdef __cplusplus
355331Samw extern "C" {
365331Samw #endif
375331Samw 
385331Samw /*
395331Samw  * User Session Key
405331Samw  *
415331Samw  * This is part of the MAC key which is required for signing SMB messages.
425331Samw  */
435331Samw typedef struct smb_session_key {
445331Samw 	uint8_t data[16];
455331Samw } smb_session_key_t;
465331Samw 
475331Samw /*
485331Samw  * Access Token
495331Samw  *
505331Samw  * An access token identifies a user, the user's privileges and the
515331Samw  * list of groups of which the user is a member. This information is
525331Samw  * used when access is requested to an object by comparing this
535331Samw  * information with the DACL in the object's security descriptor.
545331Samw  *
558670SJose.Borrego@Sun.COM  * There should be one unique token per user per session per client.
568670SJose.Borrego@Sun.COM  *
575331Samw  * Access Token Flags
585331Samw  *
595331Samw  * SMB_ATF_GUEST	Token belongs to guest user
605331Samw  * SMB_ATF_ANON		Token belongs to anonymous user
615331Samw  * 			and it's only good for IPC Connection.
625331Samw  * SMB_ATF_POWERUSER	Token belongs to a Power User member
635331Samw  * SMB_ATF_BACKUPOP	Token belongs to a Power User member
645331Samw  * SMB_ATF_ADMIN	Token belongs to a Domain Admins member
655331Samw  */
665331Samw #define	SMB_ATF_GUEST		0x00000001
675331Samw #define	SMB_ATF_ANON		0x00000002
685331Samw #define	SMB_ATF_POWERUSER	0x00000004
695331Samw #define	SMB_ATF_BACKUPOP	0x00000008
705331Samw #define	SMB_ATF_ADMIN		0x00000010
715331Samw 
725331Samw #define	SMB_POSIX_GRPS_SIZE(n) \
735331Samw 	(sizeof (smb_posix_grps_t) + (n - 1) * sizeof (gid_t))
745331Samw /*
755331Samw  * It consists of the primary and supplementary POSIX groups.
765331Samw  */
775331Samw typedef struct smb_posix_grps {
788670SJose.Borrego@Sun.COM 	uint32_t	pg_ngrps;
798670SJose.Borrego@Sun.COM 	gid_t		pg_grps[ANY_SIZE_ARRAY];
805331Samw } smb_posix_grps_t;
815331Samw 
825331Samw typedef struct smb_token {
838670SJose.Borrego@Sun.COM 	smb_id_t	tkn_user;
848670SJose.Borrego@Sun.COM 	smb_id_t	tkn_owner;
858670SJose.Borrego@Sun.COM 	smb_id_t	tkn_primary_grp;
868670SJose.Borrego@Sun.COM 	smb_ids_t	tkn_win_grps;
878670SJose.Borrego@Sun.COM 	smb_privset_t	*tkn_privileges;
888670SJose.Borrego@Sun.COM 	char		*tkn_account_name;
898670SJose.Borrego@Sun.COM 	char		*tkn_domain_name;
908670SJose.Borrego@Sun.COM 	uint32_t	tkn_flags;
918670SJose.Borrego@Sun.COM 	uint32_t	tkn_audit_sid;
925331Samw 	smb_session_key_t *tkn_session_key;
935331Samw 	smb_posix_grps_t *tkn_posix_grps;
945331Samw } smb_token_t;
955331Samw 
96*11963SAfshin.Ardakani@Sun.COM /*
97*11963SAfshin.Ardakani@Sun.COM  * Details required to authenticate a user.
98*11963SAfshin.Ardakani@Sun.COM  */
99*11963SAfshin.Ardakani@Sun.COM typedef struct smb_logon {
100*11963SAfshin.Ardakani@Sun.COM 	uint16_t	lg_level;
101*11963SAfshin.Ardakani@Sun.COM 	char		*lg_username;	/* requested username */
102*11963SAfshin.Ardakani@Sun.COM 	char		*lg_domain;	/* requested domain */
103*11963SAfshin.Ardakani@Sun.COM 	char		*lg_e_username;	/* effective username */
104*11963SAfshin.Ardakani@Sun.COM 	char		*lg_e_domain;	/* effective domain */
105*11963SAfshin.Ardakani@Sun.COM 	char		*lg_workstation;
106*11963SAfshin.Ardakani@Sun.COM 	smb_inaddr_t	lg_clnt_ipaddr;
107*11963SAfshin.Ardakani@Sun.COM 	smb_inaddr_t	lg_local_ipaddr;
108*11963SAfshin.Ardakani@Sun.COM 	uint16_t	lg_local_port;
109*11963SAfshin.Ardakani@Sun.COM 	smb_buf32_t	lg_challenge_key;
110*11963SAfshin.Ardakani@Sun.COM 	smb_buf32_t	lg_nt_password;
111*11963SAfshin.Ardakani@Sun.COM 	smb_buf32_t	lg_lm_password;
112*11963SAfshin.Ardakani@Sun.COM 	int		lg_native_os;
113*11963SAfshin.Ardakani@Sun.COM 	int		lg_native_lm;
114*11963SAfshin.Ardakani@Sun.COM 	uint32_t	lg_flags;
115*11963SAfshin.Ardakani@Sun.COM 	uint32_t	lg_logon_id;	/* filled in user space */
116*11963SAfshin.Ardakani@Sun.COM 	uint32_t	lg_domain_type;	/* filled in user space */
117*11963SAfshin.Ardakani@Sun.COM 	uint32_t	lg_secmode;	/* filled in user space */
118*11963SAfshin.Ardakani@Sun.COM 	uint32_t	lg_status;	/* filled in user space */
119*11963SAfshin.Ardakani@Sun.COM } smb_logon_t;
1205331Samw 
121*11963SAfshin.Ardakani@Sun.COM bool_t smb_logon_xdr();
122*11963SAfshin.Ardakani@Sun.COM bool_t smb_token_xdr();
1235331Samw 
1245331Samw #ifndef _KERNEL
125*11963SAfshin.Ardakani@Sun.COM smb_token_t *smb_logon(smb_logon_t *);
126*11963SAfshin.Ardakani@Sun.COM void smb_logon_abort(void);
127*11963SAfshin.Ardakani@Sun.COM void smb_token_destroy(smb_token_t *);
128*11963SAfshin.Ardakani@Sun.COM uint8_t *smb_token_encode(smb_token_t *, uint32_t *);
129*11963SAfshin.Ardakani@Sun.COM void smb_token_log(smb_token_t *);
130*11963SAfshin.Ardakani@Sun.COM smb_logon_t *smb_logon_decode(uint8_t *, uint32_t);
131*11963SAfshin.Ardakani@Sun.COM void smb_logon_free(smb_logon_t *);
1325331Samw #else /* _KERNEL */
133*11963SAfshin.Ardakani@Sun.COM void smb_token_free(smb_token_t *);
1345331Samw #endif /* _KERNEL */
1355331Samw 
1365331Samw int smb_token_query_privilege(smb_token_t *token, int priv_id);
137*11963SAfshin.Ardakani@Sun.COM boolean_t smb_token_valid(smb_token_t *);
1385331Samw 
1395331Samw #ifdef __cplusplus
1405331Samw }
1415331Samw #endif
1425331Samw 
1435331Samw 
1445331Samw #endif /* _SMB_TOKEN_H */
145