xref: /netbsd-src/lib/libc/compat/include/pwd.h (revision 461a86f9bdbf4658bc4b37796e978427095f94a7)
1*461a86f9Schristos /*	$NetBSD: pwd.h,v 1.2 2009/01/11 02:46:25 christos Exp $	*/
2*461a86f9Schristos 
3*461a86f9Schristos #ifndef _COMPAT_PWD_H_
4*461a86f9Schristos #define	_COMPAT_PWD_H_
5*461a86f9Schristos 
6*461a86f9Schristos #include <sys/cdefs.h>
7*461a86f9Schristos #include <sys/featuretest.h>
8*461a86f9Schristos #include <sys/types.h>
9*461a86f9Schristos 
10*461a86f9Schristos struct passwd;
11*461a86f9Schristos struct passwd50 {
12*461a86f9Schristos 	__aconst char *pw_name;		/* user name */
13*461a86f9Schristos 	__aconst char *pw_passwd;	/* encrypted password */
14*461a86f9Schristos 	uid_t	       pw_uid;		/* user uid */
15*461a86f9Schristos 	gid_t	       pw_gid;		/* user gid */
16*461a86f9Schristos 	int32_t	       pw_change;	/* password change time */
17*461a86f9Schristos 	__aconst char *pw_class;	/* user login class */
18*461a86f9Schristos 	__aconst char *pw_gecos;	/* general information */
19*461a86f9Schristos 	__aconst char *pw_dir;		/* home directory */
20*461a86f9Schristos 	__aconst char *pw_shell;	/* default shell */
21*461a86f9Schristos 	int32_t        pw_expire;	/* account expiration */
22*461a86f9Schristos };
23*461a86f9Schristos 
24*461a86f9Schristos __BEGIN_DECLS
25*461a86f9Schristos static __inline void
passwd_to_passwd50(const struct passwd * p,struct passwd50 * q)26*461a86f9Schristos passwd_to_passwd50(const struct passwd *p, struct passwd50 *q)
27*461a86f9Schristos {
28*461a86f9Schristos 	q->pw_name = p->pw_name;
29*461a86f9Schristos 	q->pw_passwd = p->pw_passwd;
30*461a86f9Schristos 	q->pw_uid = p->pw_uid;
31*461a86f9Schristos 	q->pw_gid = p->pw_gid;
32*461a86f9Schristos 	q->pw_change = (int32_t)p->pw_change;
33*461a86f9Schristos 	q->pw_class = p->pw_class;
34*461a86f9Schristos 	q->pw_gecos = p->pw_gecos;
35*461a86f9Schristos 	q->pw_dir = p->pw_dir;
36*461a86f9Schristos 	q->pw_shell = p->pw_shell;
37*461a86f9Schristos 	q->pw_expire = (int32_t)p->pw_expire;
38*461a86f9Schristos }
39*461a86f9Schristos 
40*461a86f9Schristos static __inline void
passwd50_to_passwd(const struct passwd50 * p,struct passwd * q)41*461a86f9Schristos passwd50_to_passwd(const struct passwd50 *p, struct passwd *q)
42*461a86f9Schristos {
43*461a86f9Schristos 	q->pw_name = p->pw_name;
44*461a86f9Schristos 	q->pw_passwd = p->pw_passwd;
45*461a86f9Schristos 	q->pw_uid = p->pw_uid;
46*461a86f9Schristos 	q->pw_gid = p->pw_gid;
47*461a86f9Schristos 	q->pw_change = p->pw_change;
48*461a86f9Schristos 	q->pw_class = p->pw_class;
49*461a86f9Schristos 	q->pw_gecos = p->pw_gecos;
50*461a86f9Schristos 	q->pw_dir = p->pw_dir;
51*461a86f9Schristos 	q->pw_shell = p->pw_shell;
52*461a86f9Schristos 	q->pw_expire = p->pw_expire;
53*461a86f9Schristos }
54*461a86f9Schristos 
55*461a86f9Schristos struct passwd50	*getpwuid(uid_t);
56*461a86f9Schristos struct passwd50	*getpwnam(const char *);
57*461a86f9Schristos #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
58*461a86f9Schristos     defined(_REENTRANT) || defined(_NETBSD_SOURCE)
59*461a86f9Schristos int		 getpwnam_r(const char *, struct passwd50 *, char *, size_t,
60*461a86f9Schristos     struct passwd50 **);
61*461a86f9Schristos int		 getpwuid_r(uid_t, struct passwd50 *, char *, size_t,
62*461a86f9Schristos     struct passwd50 **);
63*461a86f9Schristos #endif
64*461a86f9Schristos #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
65*461a86f9Schristos struct passwd50	*getpwent(void);
66*461a86f9Schristos #endif
67*461a86f9Schristos #if defined(_NETBSD_SOURCE)
68*461a86f9Schristos int		 pw_scan(char *, struct passwd50 *, int *);
69*461a86f9Schristos int		 getpwent_r(struct passwd50 *, char *, size_t, struct passwd50 **);
70*461a86f9Schristos #endif
71*461a86f9Schristos #if defined(_NETBSD_SOURCE)
72*461a86f9Schristos int		 pwcache_userdb(int (*)(int), void (*)(void),
73*461a86f9Schristos     struct passwd50 * (*)(const char *), struct passwd50 * (*)(uid_t));
74*461a86f9Schristos #endif
75*461a86f9Schristos 
76*461a86f9Schristos struct passwd	*__getpwuid50(uid_t);
77*461a86f9Schristos struct passwd	*__getpwnam50(const char *);
78*461a86f9Schristos #if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \
79*461a86f9Schristos     defined(_REENTRANT) || defined(_NETBSD_SOURCE)
80*461a86f9Schristos int		 __getpwnam_r50(const char *, struct passwd *, char *, size_t,
81*461a86f9Schristos     struct passwd **);
82*461a86f9Schristos int		 __getpwuid_r50(uid_t, struct passwd *, char *, size_t,
83*461a86f9Schristos     struct passwd **);
84*461a86f9Schristos #endif
85*461a86f9Schristos #if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
86*461a86f9Schristos struct passwd	*__getpwent50(void);
87*461a86f9Schristos #endif
88*461a86f9Schristos #if defined(_NETBSD_SOURCE)
89*461a86f9Schristos int		 __pw_scan50(char *, struct passwd *, int *);
90*461a86f9Schristos int		 __getpwent_r50(struct passwd *, char *, size_t, struct passwd **);
91*461a86f9Schristos #endif
92*461a86f9Schristos int		 setpassent(int);
93*461a86f9Schristos #if defined(_NETBSD_SOURCE)
94*461a86f9Schristos int		 __pwcache_userdb50(int (*)(int), void (*)(void),
95*461a86f9Schristos     struct passwd * (*)(const char *), struct passwd * (*)(uid_t));
96*461a86f9Schristos #endif
97*461a86f9Schristos __END_DECLS
98*461a86f9Schristos 
99*461a86f9Schristos #endif /* !_COMPAT_PWD_H_ */
100