1 /*	$MirOS: src/include/bsd_auth.h,v 1.2 2013/10/31 20:06:07 tg Exp $ */
2 /*	$OpenBSD: bsd_auth.h,v 1.8 2002/08/30 08:50:01 espie Exp $	*/
3 
4 /*-
5  * Copyright © 2013
6  *	Thorsten “mirabilos” Glaser <tg@mirbsd.org>
7  * Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by Berkeley Software Design,
20  *	Inc.
21  * 4. The name of Berkeley Software Design, Inc.  may not be used to endorse
22  *    or promote products derived from this software without specific prior
23  *    written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	BSDI $From: bsd_auth.h,v 2.3 1999/09/08 22:13:08 prb Exp $
38  */
39 
40 #ifndef _BSD_AUTH_H_
41 #define _BSD_AUTH_H_
42 
43 typedef struct auth_session_t auth_session_t;
44 
45 typedef enum {
46 	AUTHV_ALL,
47 	AUTHV_CHALLENGE,
48 	AUTHV_CLASS,
49 	AUTHV_NAME,
50 	AUTHV_SERVICE,
51 	AUTHV_STYLE,
52 	AUTHV_INTERACTIVE
53 } auth_item_t;
54 
55 #include <sys/cdefs.h>
56 __BEGIN_DECLS
57 struct passwd;
58 struct login_cap;
59 
60 char	*auth_getitem(auth_session_t *, auth_item_t);
61 int	 auth_setitem(auth_session_t *, auth_item_t, char *);
62 
63 auth_session_t *auth_open(void);
64 auth_session_t *auth_verify(auth_session_t *, char *, char *, ...)
65 		    __attribute__((__sentinel__));
66 
67 auth_session_t *auth_userchallenge(char *, char *, char *, char **);
68 auth_session_t *auth_usercheck(char *, char *, char *, char *);
69 
70 int	 auth_userresponse(auth_session_t *, char *, int);
71 int	 auth_userokay(char *, char *, char *, char *);
72 int	 auth_approval(auth_session_t *, struct login_cap *, char *, char *);
73 
74 int	 auth_close(auth_session_t *);
75 void	 auth_clean(auth_session_t *);
76 
77 char	*auth_getvalue(auth_session_t *, char *);
78 int	 auth_getstate(auth_session_t *);
79 char	*auth_challenge(auth_session_t *);
80 void	 auth_setenv(auth_session_t *);
81 void	 auth_clrenv(auth_session_t *);
82 
83 void	 auth_setstate(auth_session_t *, int);
84 int	 auth_call(auth_session_t *, char *, ...)
85 	    __attribute__((__sentinel__));
86 
87 int	 auth_setdata(auth_session_t *, void *, size_t);
88 int	 auth_setoption(auth_session_t *, char *, char *);
89 int	 auth_setpwd(auth_session_t *, struct passwd *pwd);
90 void	 auth_set_va_list(auth_session_t *, _BSD_VA_LIST_);
91 
92 struct passwd *auth_getpwd(auth_session_t *);
93 
94 quad_t	 auth_check_expire(auth_session_t *);
95 quad_t	 auth_check_change(auth_session_t *);
96 
97 void	 auth_clroptions(auth_session_t *);
98 void	 auth_clroption(auth_session_t *, char *);
99 
100 char	*auth_mkvalue(char *);
101 void	 auth_checknologin(struct login_cap *);
102 int	 auth_cat(char *);
103 
104 __END_DECLS
105 
106 #endif /* _BSD_AUTH_H_ */
107