xref: /onnv-gate/usr/src/head/shadow.h (revision 7422:257a114e1831)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7422SJohn.Sonnenschein@Sun.COM  * Common Development and Distribution License (the "License").
6*7422SJohn.Sonnenschein@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*7422SJohn.Sonnenschein@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
270Sstevel@tonic-gate /*	  All Rights Reserved  	*/
280Sstevel@tonic-gate 
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef	_SHADOW_H
310Sstevel@tonic-gate #define	_SHADOW_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate 
340Sstevel@tonic-gate #ifdef	__cplusplus
350Sstevel@tonic-gate extern "C" {
360Sstevel@tonic-gate #endif
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #define	PASSWD 		"/etc/passwd"
390Sstevel@tonic-gate #define	SHADOW		"/etc/shadow"
400Sstevel@tonic-gate #define	OPASSWD		"/etc/opasswd"
410Sstevel@tonic-gate #define	OSHADOW 	"/etc/oshadow"
420Sstevel@tonic-gate #define	PASSTEMP	"/etc/ptmp"
430Sstevel@tonic-gate #define	SHADTEMP	"/etc/stmp"
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #define	DAY		(24L * 60 * 60) /* 1 day in seconds */
460Sstevel@tonic-gate #define	DAY_NOW		(time_t)time((time_t *)0) / DAY
470Sstevel@tonic-gate 			/* The above timezone variable is set by a call to */
480Sstevel@tonic-gate 			/* any ctime(3c) routine.  Programs using the DAY_NOW */
490Sstevel@tonic-gate 			/* macro must call one of the ctime routines, */
500Sstevel@tonic-gate 			/* e.g. tzset(), BEFORE referencing DAY_NOW */
510Sstevel@tonic-gate 
520Sstevel@tonic-gate #define	LOCKSTRING	"*LK*"	/* prefix to/string in sp_pwdp to lock acct */
530Sstevel@tonic-gate #define	NOLOGINSTRING	"NP"	/* sp_pwdp for no-login accounts */
54*7422SJohn.Sonnenschein@Sun.COM #define	NOPWDRTR	"*NP*"	/* password is not retrievable */
550Sstevel@tonic-gate /*
560Sstevel@tonic-gate  * The spwd structure is used in the retreval of information from
570Sstevel@tonic-gate  * /etc/shadow.  It is used by routines in the libos library.
580Sstevel@tonic-gate  */
590Sstevel@tonic-gate struct spwd {
600Sstevel@tonic-gate 	char *sp_namp;	/* user name */
610Sstevel@tonic-gate 	char *sp_pwdp;	/* user password */
620Sstevel@tonic-gate 	int sp_lstchg;	/* password lastchanged date */
630Sstevel@tonic-gate 	int sp_min;	/* minimum number of days between password changes */
640Sstevel@tonic-gate 	int sp_max;	/* number of days password is valid */
650Sstevel@tonic-gate 	int sp_warn;	/* number of days to warn user to change passwd */
660Sstevel@tonic-gate 	int sp_inact;	/* number of days the login may be inactive */
670Sstevel@tonic-gate 	int sp_expire;	/* date when the login is no longer valid */
680Sstevel@tonic-gate 	unsigned int sp_flag;	/* currently low 4 bits are used */
690Sstevel@tonic-gate 
700Sstevel@tonic-gate 	/* low 4 bits of sp_flag for counting failed login attempts */
710Sstevel@tonic-gate #define	FAILCOUNT_MASK 0xF
720Sstevel@tonic-gate };
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #if defined(__STDC__)
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #ifndef _STDIO_H
770Sstevel@tonic-gate #include <stdio.h>
780Sstevel@tonic-gate #endif
790Sstevel@tonic-gate 
800Sstevel@tonic-gate /* Declare all shadow password functions */
810Sstevel@tonic-gate 
820Sstevel@tonic-gate extern struct spwd *getspnam_r(const char *,  struct spwd *, char *, int);
830Sstevel@tonic-gate extern struct spwd *getspent_r(struct spwd *, char *, int);
840Sstevel@tonic-gate extern struct spwd *fgetspent_r(FILE *, struct spwd *, char *, int);
850Sstevel@tonic-gate 
860Sstevel@tonic-gate extern void	setspent(void);
870Sstevel@tonic-gate extern void	endspent(void);
880Sstevel@tonic-gate extern struct spwd	*getspent(void);			/* MT-unsafe */
890Sstevel@tonic-gate extern struct spwd	*fgetspent(FILE *);			/* MT-unsafe */
900Sstevel@tonic-gate extern struct spwd	*getspnam(const char *);	/* MT-unsafe */
910Sstevel@tonic-gate 
920Sstevel@tonic-gate extern int	putspent(const struct spwd *, FILE *);
930Sstevel@tonic-gate extern int	lckpwdf(void);
940Sstevel@tonic-gate extern int	ulckpwdf(void);
950Sstevel@tonic-gate 
960Sstevel@tonic-gate #else
970Sstevel@tonic-gate 
980Sstevel@tonic-gate /* Declare all shadow password functions */
990Sstevel@tonic-gate 
1000Sstevel@tonic-gate struct spwd	*getspent_r(), *fgetspent_r(), *getspnam_r();
1010Sstevel@tonic-gate void		setspent(), endspent();
1020Sstevel@tonic-gate struct spwd	*getspent(), *fgetspent(), *getspnam(); /* MT-unsafe */
1030Sstevel@tonic-gate int		putspent(), lckpwdf(), ulckpwdf();
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate #endif
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate #ifdef	__cplusplus
1080Sstevel@tonic-gate }
1090Sstevel@tonic-gate #endif
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate #endif	/* _SHADOW_H */
112