xref: /openbsd-src/libexec/login_token/tokendb.h (revision 6d9ddefdb9a303040bcc79c287a7353965029bc9)
1*6d9ddefdSjmc /*	$OpenBSD: tokendb.h,v 1.6 2022/12/26 20:06:43 jmc Exp $	*/
227b8cbb6Smillert 
327b8cbb6Smillert /*-
4fafad76dSmillert  * Copyright (c) 1995 Migration Associates Corp. All Rights Reserved
527b8cbb6Smillert  *
627b8cbb6Smillert  * Redistribution and use in source and binary forms, with or without
727b8cbb6Smillert  * modification, are permitted provided that the following conditions
827b8cbb6Smillert  * are met:
927b8cbb6Smillert  * 1. Redistributions of source code must retain the above copyright
1027b8cbb6Smillert  *    notice, this list of conditions and the following disclaimer.
1127b8cbb6Smillert  * 2. Redistributions in binary form must reproduce the above copyright
1227b8cbb6Smillert  *    notice, this list of conditions and the following disclaimer in the
1327b8cbb6Smillert  *    documentation and/or other materials provided with the distribution.
1427b8cbb6Smillert  * 3. All advertising materials mentioning features or use of this software
1527b8cbb6Smillert  *    must display the following acknowledgement:
1627b8cbb6Smillert  *      This product includes software developed by Berkeley Software Design,
1727b8cbb6Smillert  *      Inc.
1827b8cbb6Smillert  * 4. The name of Berkeley Software Design, Inc.  may not be used to endorse
1927b8cbb6Smillert  *    or promote products derived from this software without specific prior
2027b8cbb6Smillert  *    written permission.
2127b8cbb6Smillert  *
2227b8cbb6Smillert  * THIS SOFTWARE IS PROVIDED BY BERKELEY SOFTWARE DESIGN, INC. ``AS IS'' AND
2327b8cbb6Smillert  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2427b8cbb6Smillert  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2527b8cbb6Smillert  * ARE DISCLAIMED.  IN NO EVENT SHALL BERKELEY SOFTWARE DESIGN, INC. BE LIABLE
2627b8cbb6Smillert  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2727b8cbb6Smillert  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2827b8cbb6Smillert  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2927b8cbb6Smillert  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3027b8cbb6Smillert  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3127b8cbb6Smillert  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3227b8cbb6Smillert  * SUCH DAMAGE.
3327b8cbb6Smillert  *
3427b8cbb6Smillert  *	BSDI $From: tokendb.h,v 1.1 1996/08/26 20:13:11 prb Exp $
3527b8cbb6Smillert  */
3627b8cbb6Smillert 
3727b8cbb6Smillert /*
3827b8cbb6Smillert  * Structure defining a record for a user.  All fields
3927b8cbb6Smillert  * stored in ascii to facilitate backup/reconstruction.
4027b8cbb6Smillert  * A null byte is required after the share secret field.
4127b8cbb6Smillert  */
4227b8cbb6Smillert 
4327b8cbb6Smillert typedef	struct	{
44d05a8106Sderaadt 	char	uname[LOGIN_NAME_MAX];	/* user login name	*/
4527b8cbb6Smillert 	char	secret[16];		/* token shared secret	*/
4627b8cbb6Smillert 	unsigned flags;			/* record flags		*/
4727b8cbb6Smillert 	unsigned mode;			/* token mode flags	*/
4827b8cbb6Smillert 	time_t	lock_time;		/* time of record lock	*/
4927b8cbb6Smillert 	u_char	rim[8];			/* reduced input mode 	*/
5027b8cbb6Smillert 	char	reserved_char1[8];
5127b8cbb6Smillert 	char	reserved_char2[80];
5227b8cbb6Smillert } TOKENDB_Rec;
5327b8cbb6Smillert 
5427b8cbb6Smillert /*
5527b8cbb6Smillert  * Record flag values
5627b8cbb6Smillert  */
5727b8cbb6Smillert 
5827b8cbb6Smillert #define	TOKEN_LOCKED	0x1		/* record locked for updating	*/
5927b8cbb6Smillert #define	TOKEN_ENABLED	0x2		/* user login method enabled	*/
6027b8cbb6Smillert #define	TOKEN_LOGIN	0x4		/* login in progress lock	*/
6127b8cbb6Smillert #define	TOKEN_USEMODES	0x8		/* use the mode field		*/
6227b8cbb6Smillert 
6327b8cbb6Smillert #define	TOKEN_DECMODE	0x1		/* allow decimal results */
6427b8cbb6Smillert #define	TOKEN_HEXMODE	0x2		/* allow hex results */
6527b8cbb6Smillert #define	TOKEN_PHONEMODE	0x4		/* allow phone book results */
66*6d9ddefdSjmc #define	TOKEN_RIM	0x8		/* reduced input mode */
6727b8cbb6Smillert 
6886b130fbSmillert #define	TOKEN_GROUP	"_token"	/* group that owns token database */
6915904bd8Smillert 
7027b8cbb6Smillert /*
7127b8cbb6Smillert  * Function prototypes for routines which manipulate the
7227b8cbb6Smillert  * database for the token.  These routines have no knowledge
7327b8cbb6Smillert  * of DES or encryption.  However, they will manipulate the
7427b8cbb6Smillert  * flags field of the database record with complete abandon.
7527b8cbb6Smillert  */
7627b8cbb6Smillert 
7727b8cbb6Smillert extern	int	tokendb_delrec(char *);
7827b8cbb6Smillert extern	int	tokendb_getrec(char *, TOKENDB_Rec *);
7927b8cbb6Smillert extern	int	tokendb_putrec(char *, TOKENDB_Rec *);
8027b8cbb6Smillert extern	int	tokendb_firstrec(int, TOKENDB_Rec *);
8127b8cbb6Smillert extern	int	tokendb_nextrec(int, TOKENDB_Rec *);
8227b8cbb6Smillert extern	int	tokendb_lockrec(char *, TOKENDB_Rec *, unsigned);
83