os/ossrv/genericopenlibs/openenvcore/include/pwd.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*-
sl@0
     2
 * Copyright (c) 1989, 1993
sl@0
     3
 *	The Regents of the University of California.  All rights reserved.
sl@0
     4
 * (c) UNIX System Laboratories, Inc.
sl@0
     5
 * All or some portions of this file are derived from material licensed
sl@0
     6
 * to the University of California by American Telephone and Telegraph
sl@0
     7
 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
sl@0
     8
 * the permission of UNIX System Laboratories, Inc.
sl@0
     9
 *
sl@0
    10
 * Redistribution and use in source and binary forms, with or without
sl@0
    11
 * modification, are permitted provided that the following conditions
sl@0
    12
 * are met:
sl@0
    13
 * 1. Redistributions of source code must retain the above copyright
sl@0
    14
 *    notice, this list of conditions and the following disclaimer.
sl@0
    15
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    16
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    17
 *    documentation and/or other materials provided with the distribution.
sl@0
    18
 * 4. Neither the name of the University nor the names of its contributors
sl@0
    19
 *    may be used to endorse or promote products derived from this software
sl@0
    20
 *    without specific prior written permission.
sl@0
    21
 *
sl@0
    22
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
sl@0
    23
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    24
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    25
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
sl@0
    26
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    27
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    28
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    29
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    30
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    31
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    32
 * SUCH DAMAGE.
sl@0
    33
 *
sl@0
    34
 *	@(#)pwd.h	8.2 (Berkeley) 1/21/94
sl@0
    35
 * $FreeBSD: src/include/pwd.h,v 1.16 2005/01/26 17:26:54 nectar Exp $
sl@0
    36
 * © Portions copyright (c) 2005-2006 Nokia Corporation.  All rights reserved.
sl@0
    37
 */
sl@0
    38
sl@0
    39
#ifndef _PWD_H_
sl@0
    40
#define	_PWD_H_
sl@0
    41
sl@0
    42
#include <sys/cdefs.h>
sl@0
    43
#include <sys/_types.h>
sl@0
    44
sl@0
    45
#ifndef _GID_T_DECLARED
sl@0
    46
typedef	__gid_t		gid_t;
sl@0
    47
#define	_GID_T_DECLARED
sl@0
    48
#endif
sl@0
    49
sl@0
    50
#ifndef _TIME_T_DECLARED
sl@0
    51
typedef	__time_t	time_t;
sl@0
    52
#define	_TIME_T_DECLARED
sl@0
    53
#endif
sl@0
    54
sl@0
    55
#ifndef _UID_T_DECLARED
sl@0
    56
typedef	__uid_t		uid_t;
sl@0
    57
#define	_UID_T_DECLARED
sl@0
    58
#endif
sl@0
    59
sl@0
    60
#ifndef _SIZE_T_DECLARED
sl@0
    61
typedef __size_t	size_t;
sl@0
    62
#define _SIZE_T_DECLARED
sl@0
    63
#endif
sl@0
    64
sl@0
    65
#define _PATH_PWD		"/etc"
sl@0
    66
#define	_PATH_PASSWD		"/etc/passwd"
sl@0
    67
#define	_PASSWD			"passwd"
sl@0
    68
#define	_PATH_MASTERPASSWD	"/etc/master.passwd"
sl@0
    69
#define	_MASTERPASSWD		"master.passwd"
sl@0
    70
sl@0
    71
#define	_PATH_MP_DB		"/etc/pwd.db"
sl@0
    72
#define	_MP_DB			"pwd.db"
sl@0
    73
#define	_PATH_SMP_DB		"/etc/spwd.db"
sl@0
    74
#define	_SMP_DB			"spwd.db"
sl@0
    75
sl@0
    76
#define	_PATH_PWD_MKDB		"/usr/sbin/pwd_mkdb"
sl@0
    77
sl@0
    78
/* Historically, the keys in _PATH_MP_DB/_PATH_SMP_DB had the format
sl@0
    79
 * `1 octet tag | key', where the tag is one of the _PW_KEY* values
sl@0
    80
 * listed below.  These values happen to be ASCII digits.  Starting
sl@0
    81
 * with FreeBSD 5.1, the tag is now still a single octet, but the
sl@0
    82
 * upper 4 bits are interpreted as a version.  Pre-FreeBSD 5.1 format
sl@0
    83
 * entries are version `3' -- this conveniently results in the same
sl@0
    84
 * key values as before.  The new, architecture-independent entries
sl@0
    85
 * are version `4'.
sl@0
    86
 * As it happens, some applications read the database directly.
sl@0
    87
 * (Bad app, no cookie!)  Thus, we leave the _PW_KEY* symbols at their
sl@0
    88
 * old pre-FreeBSD 5.1 values so these apps still work.  Consequently
sl@0
    89
 * we have to muck around a bit more to get the correct, versioned
sl@0
    90
 * tag, and that is what the _PW_VERSIONED macro is about.
sl@0
    91
 */
sl@0
    92
sl@0
    93
#define _PW_VERSION_MASK	'\xF0'
sl@0
    94
#define _PW_VERSIONED(x, v)	((unsigned char)(((x) & 0xCF) | ((v)<<4)))
sl@0
    95
sl@0
    96
#define	_PW_KEYBYNAME		'\x31'	/* stored by name */
sl@0
    97
#define	_PW_KEYBYNUM		'\x32'	/* stored by entry in the "file" */
sl@0
    98
#define	_PW_KEYBYUID		'\x33'	/* stored by uid */
sl@0
    99
#define _PW_KEYYPENABLED	'\x34'	/* YP is enabled */
sl@0
   100
#define	_PW_KEYYPBYNUM		'\x35'	/* special +  @ netgroup entries */
sl@0
   101
sl@0
   102
/* The database also contains a key to indicate the format version of
sl@0
   103
 * the entries therein.  There may be other, older versioned entries
sl@0
   104
 * as well.
sl@0
   105
 */
sl@0
   106
#define _PWD_VERSION_KEY	"\xFF" "VERSION"
sl@0
   107
#define _PWD_CURRENT_VERSION	'\x04'
sl@0
   108
sl@0
   109
#define	_PASSWORD_EFMT1		'_'	/* extended encryption format */
sl@0
   110
sl@0
   111
#define	_PASSWORD_LEN		128	/* max length, not counting NULL */
sl@0
   112
sl@0
   113
struct passwd {
sl@0
   114
	char	*pw_name;		/* user name */
sl@0
   115
	char	*pw_passwd;		/* encrypted password */
sl@0
   116
	uid_t	pw_uid;			/* user uid */
sl@0
   117
	gid_t	pw_gid;			/* user gid */
sl@0
   118
	time_t	pw_change;		/* password change time */
sl@0
   119
	char	*pw_class;		/* user access class */
sl@0
   120
	char	*pw_gecos;		/* Honeywell login info */
sl@0
   121
	char	*pw_dir;		/* home directory */
sl@0
   122
	char	*pw_shell;		/* default shell */
sl@0
   123
	time_t	pw_expire;		/* account expiration */
sl@0
   124
	int	pw_fields;		/* internal: fields filled in */
sl@0
   125
};
sl@0
   126
sl@0
   127
/* Mapping from fields to bits for pw_fields. */
sl@0
   128
#define _PWF(x)		(1 << x)
sl@0
   129
#define _PWF_NAME	_PWF(0)
sl@0
   130
#define _PWF_PASSWD	_PWF(1)
sl@0
   131
#define _PWF_UID	_PWF(2)
sl@0
   132
#define _PWF_GID	_PWF(3)
sl@0
   133
#define _PWF_CHANGE	_PWF(4)
sl@0
   134
#define _PWF_CLASS	_PWF(5)
sl@0
   135
#define _PWF_GECOS	_PWF(6)
sl@0
   136
#define _PWF_DIR	_PWF(7)
sl@0
   137
#define _PWF_SHELL	_PWF(8)
sl@0
   138
#define _PWF_EXPIRE	_PWF(9)
sl@0
   139
sl@0
   140
/* XXX These flags are bogus.  With nsswitch, there are many
sl@0
   141
 * possible sources and they cannot be represented in a small integer.
sl@0
   142
 */                           
sl@0
   143
#define _PWF_SOURCE	0x3000
sl@0
   144
#define _PWF_FILES	0x1000
sl@0
   145
#define _PWF_NIS	0x2000
sl@0
   146
#define _PWF_HESIOD	0x3000
sl@0
   147
sl@0
   148
__BEGIN_DECLS
sl@0
   149
IMPORT_C struct passwd	*getpwnam(const char *);
sl@0
   150
IMPORT_C struct passwd	*getpwuid(uid_t);
sl@0
   151
sl@0
   152
#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 500
sl@0
   153
IMPORT_C void		 endpwent(void);
sl@0
   154
IMPORT_C struct passwd	*getpwent(void);
sl@0
   155
IMPORT_C void		 setpwent(void);
sl@0
   156
IMPORT_C int		 getpwnam_r(const char *, struct passwd *, char *, size_t,
sl@0
   157
		    struct passwd **);
sl@0
   158
IMPORT_C int		 getpwuid_r(uid_t, struct passwd *, char *, size_t,
sl@0
   159
		    struct passwd **);
sl@0
   160
#endif
sl@0
   161
sl@0
   162
__END_DECLS
sl@0
   163
sl@0
   164
#endif /* !_PWD_H_ */