| 1 |
1325 |
phoenix |
/* Copyright (C) 1991,92,95,96,97,98,99,2001 Free Software Foundation, Inc.
|
| 2 |
|
|
This file is part of the GNU C Library.
|
| 3 |
|
|
|
| 4 |
|
|
The GNU C Library is free software; you can redistribute it and/or
|
| 5 |
|
|
modify it under the terms of the GNU Lesser General Public
|
| 6 |
|
|
License as published by the Free Software Foundation; either
|
| 7 |
|
|
version 2.1 of the License, or (at your option) any later version.
|
| 8 |
|
|
|
| 9 |
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
| 10 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 11 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 12 |
|
|
Lesser General Public License for more details.
|
| 13 |
|
|
|
| 14 |
|
|
You should have received a copy of the GNU Lesser General Public
|
| 15 |
|
|
License along with the GNU C Library; if not, write to the Free
|
| 16 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
| 17 |
|
|
02111-1307 USA. */
|
| 18 |
|
|
|
| 19 |
|
|
/*
|
| 20 |
|
|
* POSIX Standard: 9.2.2 User Database Access <pwd.h>
|
| 21 |
|
|
*/
|
| 22 |
|
|
|
| 23 |
|
|
#ifndef _PWD_H
|
| 24 |
|
|
#define _PWD_H 1
|
| 25 |
|
|
|
| 26 |
|
|
#include <features.h>
|
| 27 |
|
|
|
| 28 |
|
|
__BEGIN_DECLS
|
| 29 |
|
|
|
| 30 |
|
|
#include <bits/types.h>
|
| 31 |
|
|
|
| 32 |
|
|
#define __need_size_t
|
| 33 |
|
|
#include <stddef.h>
|
| 34 |
|
|
|
| 35 |
|
|
#ifdef __USE_XOPEN
|
| 36 |
|
|
/* The Single Unix specification says that some more types are
|
| 37 |
|
|
available here. */
|
| 38 |
|
|
# ifndef __gid_t_defined
|
| 39 |
|
|
typedef __gid_t gid_t;
|
| 40 |
|
|
# define __gid_t_defined
|
| 41 |
|
|
# endif
|
| 42 |
|
|
|
| 43 |
|
|
# ifndef __uid_t_defined
|
| 44 |
|
|
typedef __uid_t uid_t;
|
| 45 |
|
|
# define __uid_t_defined
|
| 46 |
|
|
# endif
|
| 47 |
|
|
#endif
|
| 48 |
|
|
|
| 49 |
|
|
/* The passwd structure. */
|
| 50 |
|
|
struct passwd
|
| 51 |
|
|
{
|
| 52 |
|
|
char *pw_name; /* Username. */
|
| 53 |
|
|
char *pw_passwd; /* Password. */
|
| 54 |
|
|
__uid_t pw_uid; /* User ID. */
|
| 55 |
|
|
__gid_t pw_gid; /* Group ID. */
|
| 56 |
|
|
char *pw_gecos; /* Real name. */
|
| 57 |
|
|
char *pw_dir; /* Home directory. */
|
| 58 |
|
|
char *pw_shell; /* Shell program. */
|
| 59 |
|
|
};
|
| 60 |
|
|
|
| 61 |
|
|
|
| 62 |
|
|
#if defined __USE_SVID || defined __USE_GNU
|
| 63 |
|
|
# define __need_FILE
|
| 64 |
|
|
# include <stdio.h>
|
| 65 |
|
|
#endif
|
| 66 |
|
|
|
| 67 |
|
|
|
| 68 |
|
|
#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN_EXTENDED
|
| 69 |
|
|
/* Rewind the password-file stream. */
|
| 70 |
|
|
extern void setpwent (void) __THROW;
|
| 71 |
|
|
|
| 72 |
|
|
/* Close the password-file stream. */
|
| 73 |
|
|
extern void endpwent (void) __THROW;
|
| 74 |
|
|
|
| 75 |
|
|
/* Read an entry from the password-file stream, opening it if necessary. */
|
| 76 |
|
|
extern struct passwd *getpwent (void) __THROW;
|
| 77 |
|
|
#endif
|
| 78 |
|
|
|
| 79 |
|
|
#ifdef __USE_SVID
|
| 80 |
|
|
/* Read an entry from STREAM. */
|
| 81 |
|
|
extern struct passwd *fgetpwent (FILE *__stream) __THROW;
|
| 82 |
|
|
|
| 83 |
|
|
/* Write the given entry onto the given stream. */
|
| 84 |
|
|
extern int putpwent (__const struct passwd *__restrict __p,
|
| 85 |
|
|
FILE *__restrict __f) __THROW;
|
| 86 |
|
|
#endif
|
| 87 |
|
|
|
| 88 |
|
|
/* Search for an entry with a matching user ID. */
|
| 89 |
|
|
extern struct passwd *getpwuid (__uid_t __uid) __THROW;
|
| 90 |
|
|
|
| 91 |
|
|
/* Search for an entry with a matching username. */
|
| 92 |
|
|
extern struct passwd *getpwnam (__const char *__name) __THROW;
|
| 93 |
|
|
|
| 94 |
|
|
#if defined __USE_POSIX || defined __USE_MISC
|
| 95 |
|
|
|
| 96 |
|
|
# ifdef __USE_MISC
|
| 97 |
|
|
/* Reasonable value for the buffer sized used in the reentrant
|
| 98 |
|
|
functions below. But better use `sysconf'. */
|
| 99 |
|
|
# define NSS_BUFLEN_PASSWD 1024
|
| 100 |
|
|
# endif
|
| 101 |
|
|
|
| 102 |
|
|
/* Reentrant versions of some of the functions above.
|
| 103 |
|
|
|
| 104 |
|
|
PLEASE NOTE: the `getpwent_r' function is not (yet) standardized.
|
| 105 |
|
|
The interface may change in later versions of this library. But
|
| 106 |
|
|
the interface is designed following the principals used for the
|
| 107 |
|
|
other reentrant functions so the chances are good this is what the
|
| 108 |
|
|
POSIX people would choose. */
|
| 109 |
|
|
|
| 110 |
|
|
# if defined __USE_SVID || defined __USE_MISC
|
| 111 |
|
|
extern int getpwent_r (struct passwd *__restrict __resultbuf,
|
| 112 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 113 |
|
|
struct passwd **__restrict __result) __THROW;
|
| 114 |
|
|
# endif
|
| 115 |
|
|
|
| 116 |
|
|
extern int getpwuid_r (__uid_t __uid,
|
| 117 |
|
|
struct passwd *__restrict __resultbuf,
|
| 118 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 119 |
|
|
struct passwd **__restrict __result) __THROW;
|
| 120 |
|
|
|
| 121 |
|
|
extern int getpwnam_r (__const char *__restrict __name,
|
| 122 |
|
|
struct passwd *__restrict __resultbuf,
|
| 123 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 124 |
|
|
struct passwd **__restrict __result) __THROW;
|
| 125 |
|
|
|
| 126 |
|
|
|
| 127 |
|
|
# ifdef __USE_SVID
|
| 128 |
|
|
/* Read an entry from STREAM. This function is not standardized and
|
| 129 |
|
|
probably never will. */
|
| 130 |
|
|
extern int fgetpwent_r (FILE *__restrict __stream,
|
| 131 |
|
|
struct passwd *__restrict __resultbuf,
|
| 132 |
|
|
char *__restrict __buffer, size_t __buflen,
|
| 133 |
|
|
struct passwd **__restrict __result) __THROW;
|
| 134 |
|
|
# endif
|
| 135 |
|
|
|
| 136 |
|
|
#endif /* POSIX or reentrant */
|
| 137 |
|
|
|
| 138 |
|
|
#ifdef __USE_GNU
|
| 139 |
|
|
/* Re-construct the password-file line for the given uid
|
| 140 |
|
|
in the given buffer. This knows the format that the caller
|
| 141 |
|
|
will expect, but this need not be the format of the password file. */
|
| 142 |
|
|
extern int getpw (__uid_t __uid, char *__buffer) __THROW;
|
| 143 |
|
|
#endif
|
| 144 |
|
|
|
| 145 |
|
|
__END_DECLS
|
| 146 |
|
|
|
| 147 |
|
|
#endif /* pwd.h */
|