xref: /illumos-gate/usr/src/cmd/smbsrv/smbd/smbd_authsvc.h (revision 5a342f146a946ddf6f5f5afd4a5dd5baf11d7dd4)
1 /*
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
5  * 1.0 of the CDDL.
6  *
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.
10  */
11 
12 /*
13  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
14  */
15 
16 #ifndef _SMBD_AUTHSVC_H
17 #define	_SMBD_AUTHSVC_H
18 
19 /*
20  * Declarations shared with authsvc modules.
21  */
22 
23 #include <sys/types.h>
24 #include <smbsrv/libsmb.h>
25 
26 /*
27  * This is the common authsvc_context shared by all back-ends.
28  * Note that ctx_mech_oid is really SPNEGO_MECH_OID, and the
29  * ctx_itoken, ctx_otoken members are SPNEGO_TOKEN_HANDLE,
30  * but this is using the underlying types so as to avoid
31  * dragging in spnego.h here.
32  */
33 typedef struct authsvc_context {
34 	int			ctx_socket;
35 	int 			ctx_mech_oid;
36 	int (*ctx_mh_work)(struct authsvc_context *);
37 	void (*ctx_mh_fini)(struct authsvc_context *);
38 	int			ctx_itoktype;
39 	int			ctx_negresult;
40 
41 	/* (in,out) SPNEGO token handles */
42 	void			*ctx_itoken;
43 	void			*ctx_otoken;
44 
45 	/* (in,out) raw (buf,len,type) */
46 	void			*ctx_irawbuf;
47 	uint_t			ctx_irawlen;
48 	int			ctx_irawtype;
49 	void			*ctx_orawbuf;
50 	uint_t			ctx_orawlen;
51 	int			ctx_orawtype;
52 
53 	/* (in,out) body (buf,len) */
54 	void			*ctx_ibodybuf;
55 	uint_t			ctx_ibodylen;
56 	void			*ctx_obodybuf;
57 	uint_t			ctx_obodylen;
58 
59 	/* who is the client */
60 	smb_lsa_clinfo_t	ctx_clinfo;
61 
62 	/* final authentication token */
63 	struct smb_token	*ctx_token;
64 
65 	/* private data for the back-end */
66 	void			*ctx_backend;
67 } authsvc_context_t;
68 
69 int smbd_krb5ssp_init(authsvc_context_t *);
70 int smbd_krb5ssp_work(authsvc_context_t *);
71 void smbd_krb5ssp_fini(authsvc_context_t *);
72 
73 int smbd_ntlmssp_init(authsvc_context_t *);
74 int smbd_ntlmssp_work(authsvc_context_t *);
75 void smbd_ntlmssp_fini(authsvc_context_t *);
76 
77 /* Exposed for unit tests. */
78 int smbd_authsvc_dispatch(authsvc_context_t *);
79 authsvc_context_t *smbd_authctx_create(void);
80 void smbd_authctx_destroy(authsvc_context_t *);
81 
82 #endif /* _SMBD_AUTHSVC_H */
83