1996-07-02 19:35:40 +00:00
|
|
|
|
/* Common code for DB-based databases in nss_db module.
|
2016-01-04 16:05:18 +00:00
|
|
|
|
Copyright (C) 1996-2016 Free Software Foundation, Inc.
|
1996-11-14 02:04:07 +00:00
|
|
|
|
This file is part of the GNU C Library.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
1996-11-14 02:04:07 +00:00
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
1996-11-14 02:04:07 +00:00
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
|
Lesser General Public License for more details.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2000-01-02 04:20:21 +00:00
|
|
|
|
#include <dlfcn.h>
|
1996-07-02 19:35:40 +00:00
|
|
|
|
#include <fcntl.h>
|
2013-05-01 15:46:34 +00:00
|
|
|
|
#include <stdint.h>
|
2011-06-15 02:21:51 +00:00
|
|
|
|
#include <sys/mman.h>
|
2015-09-08 21:11:03 +00:00
|
|
|
|
#include <libc-lock.h>
|
1996-07-02 19:35:40 +00:00
|
|
|
|
#include "nsswitch.h"
|
2000-01-02 04:20:21 +00:00
|
|
|
|
#include "nss_db.h"
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
/* The hashing function we use. */
|
|
|
|
|
#include "../intl/hash-string.h"
|
|
|
|
|
|
1996-07-02 19:35:40 +00:00
|
|
|
|
/* These symbols are defined by the including source file:
|
|
|
|
|
|
|
|
|
|
ENTNAME -- database name of the structure and functions (hostent, pwent).
|
|
|
|
|
STRUCTURE -- struct name, define only if not ENTNAME (passwd, group).
|
|
|
|
|
DATABASE -- database file name, ("hosts", "passwd")
|
|
|
|
|
|
|
|
|
|
NEED_H_ERRNO - defined iff an arg `int *herrnop' is used.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define ENTNAME_r CONCAT(ENTNAME,_r)
|
|
|
|
|
|
|
|
|
|
#include <paths.h>
|
update from main archive 960828
Thu Aug 29 00:28:08 1996 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/printf_fp.c (__printf_fp): Use default value `.` if
`decimal' char is 0.
* C-numeric.c (not_available): New constant.
(_nl_C_LC_NUMERIC): Use `not_available' for grouping value.
* nss/nsswitch.conf: Example configuration file.
* nss/db-Makefile: Example Makefile for generation of databases
for nss_db.
* nss/Makefile (distribute): Add nsswitch.conf and db-Makefile.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-messages.c (_nl_C_LC_MESSAGES): Set yesexpr to "^[yY]" and
noexpr to "^[nN]"; this conforms to POSIX.2.
* C-time.c (_nl_C_LC_TIME): Change %d to %e in d_t_format, to
conform to POSIX.2.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-monetary.c (not_available): New constant.
(_nl_C_LC_MONETARY): Set mon_decimal_point to "", and set
mon_grouping, int_frac_digits, frac_digits, p_cs_precedes,
p_sep_by_space, n_cs_precedes, n_sep_by_space, p_sign_posn, and
n_sign_posn to CHAR_MAX, as required by the POSIX Standard.
Wed Aug 28 23:12:28 1996 Ulrich Drepper <drepper@cygnus.com>
* nss/nss_db/db-XXX.c: Correct function names. They must be
`_nss_db_*' instead of `_nss_files_*'.
(lookup): `parse_line' returns 1 if succesful.
* nss/nss_files/files-service.c (servbyname): Key for database
must also contain protocol names.
(servbypt): Likewise.
Test must also check for protocol. Add `proto' argument.
Tue Aug 27 09:56:13 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* MakeTAGS ($P/subdirs.pot): Prefix all file names, not only the
first one.
Fri Aug 16 16:11:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* nss/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): Treat
EPFNOSUPPORT and EAFNOSUPPORT as implying NSS_STATUS_UNAVAIL just
like ECONNREFUSED already does.
(_nss_dns_gethostbyaddr_r): Likewise.
* nss/nss_dns/dns-network.c (_nss_dns_getnetbyname_r): Likewise.
(_nss_dns_getnetbyaddr_r): Likewise.
* sysdeps/mach/hurd/socket.c (socket): For message transmission
and RPC errors that indicate that the socket server is not really
present and able to do its job, turn the error into EPFNOSUPPORT.
* sysdeps/generic/sbrk.c (__sbrk): Get kernel brk address
always only if in static libc or if statically linked program
uses libc.so.
1996-08-29 00:31:18 +00:00
|
|
|
|
#define DBFILE _PATH_VARDB DATABASE ".db"
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
#ifdef NEED_H_ERRNO
|
2011-06-15 02:21:51 +00:00
|
|
|
|
# define H_ERRNO_PROTO , int *herrnop
|
|
|
|
|
# define H_ERRNO_ARG , herrnop
|
|
|
|
|
# define H_ERRNO_SET(val) (*herrnop = (val))
|
1996-07-02 19:35:40 +00:00
|
|
|
|
#else
|
2011-06-15 02:21:51 +00:00
|
|
|
|
# define H_ERRNO_PROTO
|
|
|
|
|
# define H_ERRNO_ARG
|
|
|
|
|
# define H_ERRNO_SET(val) ((void) 0)
|
1996-07-02 19:35:40 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
/* State for this database. */
|
|
|
|
|
static struct nss_db_map state;
|
|
|
|
|
/* Lock to protect the state and global variables. */
|
|
|
|
|
__libc_lock_define (static , lock);
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
/* Maintenance of the shared handle open on the database. */
|
1996-07-02 19:35:40 +00:00
|
|
|
|
static int keep_db;
|
2011-06-15 02:21:51 +00:00
|
|
|
|
static const char *entidx;
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
|
2000-01-02 04:20:21 +00:00
|
|
|
|
/* Open the database. */
|
1996-10-02 01:40:17 +00:00
|
|
|
|
enum nss_status
|
update from main archive 960828
Thu Aug 29 00:28:08 1996 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/printf_fp.c (__printf_fp): Use default value `.` if
`decimal' char is 0.
* C-numeric.c (not_available): New constant.
(_nl_C_LC_NUMERIC): Use `not_available' for grouping value.
* nss/nsswitch.conf: Example configuration file.
* nss/db-Makefile: Example Makefile for generation of databases
for nss_db.
* nss/Makefile (distribute): Add nsswitch.conf and db-Makefile.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-messages.c (_nl_C_LC_MESSAGES): Set yesexpr to "^[yY]" and
noexpr to "^[nN]"; this conforms to POSIX.2.
* C-time.c (_nl_C_LC_TIME): Change %d to %e in d_t_format, to
conform to POSIX.2.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-monetary.c (not_available): New constant.
(_nl_C_LC_MONETARY): Set mon_decimal_point to "", and set
mon_grouping, int_frac_digits, frac_digits, p_cs_precedes,
p_sep_by_space, n_cs_precedes, n_sep_by_space, p_sign_posn, and
n_sign_posn to CHAR_MAX, as required by the POSIX Standard.
Wed Aug 28 23:12:28 1996 Ulrich Drepper <drepper@cygnus.com>
* nss/nss_db/db-XXX.c: Correct function names. They must be
`_nss_db_*' instead of `_nss_files_*'.
(lookup): `parse_line' returns 1 if succesful.
* nss/nss_files/files-service.c (servbyname): Key for database
must also contain protocol names.
(servbypt): Likewise.
Test must also check for protocol. Add `proto' argument.
Tue Aug 27 09:56:13 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* MakeTAGS ($P/subdirs.pot): Prefix all file names, not only the
first one.
Fri Aug 16 16:11:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* nss/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): Treat
EPFNOSUPPORT and EAFNOSUPPORT as implying NSS_STATUS_UNAVAIL just
like ECONNREFUSED already does.
(_nss_dns_gethostbyaddr_r): Likewise.
* nss/nss_dns/dns-network.c (_nss_dns_getnetbyname_r): Likewise.
(_nss_dns_getnetbyaddr_r): Likewise.
* sysdeps/mach/hurd/socket.c (socket): For message transmission
and RPC errors that indicate that the socket server is not really
present and able to do its job, turn the error into EPFNOSUPPORT.
* sysdeps/generic/sbrk.c (__sbrk): Get kernel brk address
always only if in static libc or if statically linked program
uses libc.so.
1996-08-29 00:31:18 +00:00
|
|
|
|
CONCAT(_nss_db_set,ENTNAME) (int stayopen)
|
1996-07-02 19:35:40 +00:00
|
|
|
|
{
|
1996-10-02 01:40:17 +00:00
|
|
|
|
enum nss_status status;
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
__libc_lock_lock (lock);
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
status = internal_setent (DBFILE, &state);
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
if (status == NSS_STATUS_SUCCESS)
|
2011-06-21 21:09:44 +00:00
|
|
|
|
{
|
|
|
|
|
/* Remember STAYOPEN flag. */
|
|
|
|
|
keep_db |= stayopen;
|
|
|
|
|
|
|
|
|
|
/* Reset the sequential index. */
|
|
|
|
|
entidx = (const char *) state.header + state.header->valstroffset;
|
|
|
|
|
}
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-01-02 04:20:21 +00:00
|
|
|
|
/* Close it again. */
|
1996-10-02 01:40:17 +00:00
|
|
|
|
enum nss_status
|
update from main archive 960828
Thu Aug 29 00:28:08 1996 Ulrich Drepper <drepper@cygnus.com>
* stdio-common/printf_fp.c (__printf_fp): Use default value `.` if
`decimal' char is 0.
* C-numeric.c (not_available): New constant.
(_nl_C_LC_NUMERIC): Use `not_available' for grouping value.
* nss/nsswitch.conf: Example configuration file.
* nss/db-Makefile: Example Makefile for generation of databases
for nss_db.
* nss/Makefile (distribute): Add nsswitch.conf and db-Makefile.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-messages.c (_nl_C_LC_MESSAGES): Set yesexpr to "^[yY]" and
noexpr to "^[nN]"; this conforms to POSIX.2.
* C-time.c (_nl_C_LC_TIME): Change %d to %e in d_t_format, to
conform to POSIX.2.
1996-08-28 Paul Eggert <eggert@twinsun.com>
* C-monetary.c (not_available): New constant.
(_nl_C_LC_MONETARY): Set mon_decimal_point to "", and set
mon_grouping, int_frac_digits, frac_digits, p_cs_precedes,
p_sep_by_space, n_cs_precedes, n_sep_by_space, p_sign_posn, and
n_sign_posn to CHAR_MAX, as required by the POSIX Standard.
Wed Aug 28 23:12:28 1996 Ulrich Drepper <drepper@cygnus.com>
* nss/nss_db/db-XXX.c: Correct function names. They must be
`_nss_db_*' instead of `_nss_files_*'.
(lookup): `parse_line' returns 1 if succesful.
* nss/nss_files/files-service.c (servbyname): Key for database
must also contain protocol names.
(servbypt): Likewise.
Test must also check for protocol. Add `proto' argument.
Tue Aug 27 09:56:13 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* MakeTAGS ($P/subdirs.pot): Prefix all file names, not only the
first one.
Fri Aug 16 16:11:25 1996 Thomas Bushnell, n/BSG <thomas@gnu.ai.mit.edu>
* nss/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r): Treat
EPFNOSUPPORT and EAFNOSUPPORT as implying NSS_STATUS_UNAVAIL just
like ECONNREFUSED already does.
(_nss_dns_gethostbyaddr_r): Likewise.
* nss/nss_dns/dns-network.c (_nss_dns_getnetbyname_r): Likewise.
(_nss_dns_getnetbyaddr_r): Likewise.
* sysdeps/mach/hurd/socket.c (socket): For message transmission
and RPC errors that indicate that the socket server is not really
present and able to do its job, turn the error into EPFNOSUPPORT.
* sysdeps/generic/sbrk.c (__sbrk): Get kernel brk address
always only if in static libc or if statically linked program
uses libc.so.
1996-08-29 00:31:18 +00:00
|
|
|
|
CONCAT(_nss_db_end,ENTNAME) (void)
|
1996-07-02 19:35:40 +00:00
|
|
|
|
{
|
|
|
|
|
__libc_lock_lock (lock);
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
internal_endent (&state);
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
/* Reset STAYOPEN flag. */
|
|
|
|
|
keep_db = 0;
|
|
|
|
|
|
|
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
|
|
|
|
|
|
return NSS_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Macro for defining lookup functions for this DB-based database.
|
|
|
|
|
|
|
|
|
|
NAME is the name of the lookup; e.g. `pwnam'.
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
DB_CHAR is index indicator for the database.
|
|
|
|
|
|
1996-07-02 19:35:40 +00:00
|
|
|
|
KEYPATTERN gives `printf' args to construct a key string;
|
2011-06-15 02:21:51 +00:00
|
|
|
|
e.g. `("%d", id)'.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
KEYSIZE gives the allocation size of a buffer to construct it in;
|
2011-06-15 02:21:51 +00:00
|
|
|
|
e.g. `1 + sizeof (id) * 4'.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
PROTO is the potentially empty list of other parameters.
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
BREAK_IF_MATCH is a block of code which compares `struct STRUCTURE *result'
|
|
|
|
|
to the lookup key arguments and does `break;' if they match. */
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
#define DB_LOOKUP(name, db_char, keysize, keypattern, break_if_match, proto...)\
|
1996-07-02 19:35:40 +00:00
|
|
|
|
enum nss_status \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
_nss_db_get##name##_r (proto, struct STRUCTURE *result, \
|
|
|
|
|
char *buffer, size_t buflen, int *errnop H_ERRNO_PROTO)\
|
1996-07-02 19:35:40 +00:00
|
|
|
|
{ \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
struct parser_data *data = (void *) buffer; \
|
|
|
|
|
\
|
|
|
|
|
if (buflen < sizeof *data) \
|
|
|
|
|
{ \
|
|
|
|
|
*errnop = ERANGE; \
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL); \
|
|
|
|
|
return NSS_STATUS_TRYAGAIN; \
|
|
|
|
|
} \
|
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
struct nss_db_map state = { NULL, 0 }; \
|
|
|
|
|
enum nss_status status = internal_setent (DBFILE, &state); \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
if (status != NSS_STATUS_SUCCESS) \
|
|
|
|
|
{ \
|
|
|
|
|
*errnop = errno; \
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL); \
|
|
|
|
|
return status; \
|
|
|
|
|
} \
|
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
const struct nss_db_header *header = state.header; \
|
|
|
|
|
int i; \
|
|
|
|
|
for (i = 0; i < header->ndbs; ++i) \
|
|
|
|
|
if (header->dbs[i].id == db_char) \
|
|
|
|
|
break; \
|
|
|
|
|
if (i == header->ndbs) \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
{ \
|
2011-06-16 01:00:59 +00:00
|
|
|
|
status = NSS_STATUS_UNAVAIL; \
|
|
|
|
|
goto out; \
|
|
|
|
|
} \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
char *key; \
|
|
|
|
|
if (db_char == '.') \
|
|
|
|
|
key = (char *) IGNOREPATTERN keypattern; \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
const size_t size = (keysize) + 1; \
|
|
|
|
|
key = alloca (size); \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
KEYPRINTF keypattern; \
|
|
|
|
|
} \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
const stridx_t *hashtable \
|
|
|
|
|
= (const stridx_t *) ((const char *) header \
|
|
|
|
|
+ header->dbs[i].hashoffset); \
|
|
|
|
|
const char *valstrtab = (const char *) header + header->valstroffset; \
|
|
|
|
|
uint32_t hashval = __hash_string (key); \
|
|
|
|
|
size_t hidx = hashval % header->dbs[i].hashsize; \
|
|
|
|
|
size_t hval2 = 1 + hashval % (header->dbs[i].hashsize - 2); \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
status = NSS_STATUS_NOTFOUND; \
|
|
|
|
|
while (hashtable[hidx] != ~((stridx_t) 0)) \
|
|
|
|
|
{ \
|
|
|
|
|
const char *valstr = valstrtab + hashtable[hidx]; \
|
|
|
|
|
size_t len = strlen (valstr) + 1; \
|
|
|
|
|
if (len > buflen) \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
{ \
|
2011-06-16 01:00:59 +00:00
|
|
|
|
/* No room to copy the data to. */ \
|
|
|
|
|
*errnop = ERANGE; \
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL); \
|
|
|
|
|
status = NSS_STATUS_TRYAGAIN; \
|
|
|
|
|
break; \
|
|
|
|
|
} \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
/* Copy the string to a place where it can be modified. */ \
|
|
|
|
|
char *p = memcpy (buffer, valstr, len); \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
int err = parse_line (p, result, data, buflen, errnop EXTRA_ARGS); \
|
2014-11-21 05:29:56 +00:00
|
|
|
|
\
|
|
|
|
|
/* Advance before break_if_match, lest it uses continue to skip
|
|
|
|
|
to the next entry. */ \
|
|
|
|
|
if ((hidx += hval2) >= header->dbs[i].hashsize) \
|
|
|
|
|
hidx -= header->dbs[i].hashsize; \
|
|
|
|
|
\
|
2011-06-16 01:00:59 +00:00
|
|
|
|
if (err > 0) \
|
|
|
|
|
{ \
|
|
|
|
|
status = NSS_STATUS_SUCCESS; \
|
|
|
|
|
break_if_match; \
|
|
|
|
|
status = NSS_STATUS_NOTFOUND; \
|
|
|
|
|
} \
|
|
|
|
|
else if (err == -1) \
|
|
|
|
|
{ \
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL); \
|
|
|
|
|
status = NSS_STATUS_TRYAGAIN; \
|
|
|
|
|
break; \
|
2011-06-15 02:21:51 +00:00
|
|
|
|
} \
|
|
|
|
|
} \
|
2011-06-16 01:00:59 +00:00
|
|
|
|
\
|
|
|
|
|
if (status == NSS_STATUS_NOTFOUND) \
|
|
|
|
|
H_ERRNO_SET (HOST_NOT_FOUND); \
|
|
|
|
|
\
|
2011-06-15 02:21:51 +00:00
|
|
|
|
out: \
|
|
|
|
|
internal_endent (&state); \
|
|
|
|
|
\
|
1996-07-02 19:35:40 +00:00
|
|
|
|
return status; \
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
#define KEYPRINTF(pattern, args...) snprintf (key, size, pattern ,##args)
|
|
|
|
|
#define IGNOREPATTERN(pattern, arg1, args...) (char *) (uintptr_t) arg1
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the next entry from the database file, doing locking. */
|
|
|
|
|
enum nss_status
|
Update.
1997-12-08 03:24 Ulrich Drepper <drepper@cygnus.com>
* Makeconfig: Define $(rt) to rt if linuxthreads is available.
* Makefile (subdirs): Replace rt by $(rt).
* shlib-versions: Use version .2 for NSS modules.
* grp/fgetgrent_r.c (LINE_PARSER): Call parse_line with extra
argument.
* pwd/fgetpwent_r.c: Likewise.
* spwd/fgetspent_r.c: Likewise.
* spwd/sgetspent_r.c: Likewise.
* hesiod/nss_hesiod/hesiod-grp.c (lookup): Add new argument.
Store error number in *ERRNOP. Little optimization.
* hesiod/nss_hesiod/hesiod-pwd.c: Likewise.
* hesiod/nss_hesiod/hesiod-service.c: Likewise.
* inet/getnetgrent_r.c (__internal_setnetgrent_reuse): Likewise.
(__internal_getnetgrent_r): New argument.
Call __internal_setnetgrent_reuse with new argument.
(__getnetgrent_r): Call __internal_getnetgrent_r with new argument.
* inet/netgroup.h: Add argument to prototypes.
* nis/nisplus-parser.h: Likewise.
* nis/nss_compat/compat-grp.c: Change everything to store error
code through provided pointer and not use errno.
* nis/nss_compat/compat-pwd.c: Likewise.
* nis/nss_compat/compat-spwd.c: Likewise.
* nis/nss_nis/nis-alias.c: Likewise.
* nis/nss_nis/nis-ethers.c: Likewise.
* nis/nss_nis/nis-grp.c: Likewise.
* nis/nss_nis/nis-hosts.c: Likewise.
* nis/nss_nis/nis-netgrp.c: Likewise.
* nis/nss_nis/nis-network.c: Likewise.
* nis/nss_nis/nis-proto.c: Likewise.
* nis/nss_nis/nis-publickey.c: Likewise.
* nis/nss_nis/nis-pwd.c: Likewise.
* nis/nss_nis/nis-rpc.c: Likewise.
* nis/nss_nis/nis-service.c: Likewise.
* nis/nss_nis/nis-spwd.c: Likewise.
* nis/nss_nisplus/nisplus-alias.c: Likewise.
* nis/nss_nisplus/nisplus-ethers.c: Likewise.
* nis/nss_nisplus/nisplus-grp.c: Likewise.
* nis/nss_nisplus/nisplus-hosts.c: Likewise.
* nis/nss_nisplus/nisplus-netgrp.c: Likewise.
* nis/nss_nisplus/nisplus-network.c: Likewise.
* nis/nss_nisplus/nisplus-parser.c: Likewise.
* nis/nss_nisplus/nisplus-proto.c: Likewise.
* nis/nss_nisplus/nisplus-publickey.c: Likewise.
* nis/nss_nisplus/nisplus-pwd.c: Likewise.
* nis/nss_nisplus/nisplus-rpc.c: Likewise.
* nis/nss_nisplus/nisplus-service.c: Likewise.
* nis/nss_nisplus/nisplus-spwd.c: Likewise.
* nss/nss_db/db-XXX.c: Likewise.
* nss/nss_db/db-alias.c: Likewise.
* nss/nss_db/db-netgrp.c: Likewise.
* nss/nss_files/files-XXX.c: Likewise
* nss/nss_files/files-alias.c: Likewise
* nss/nss_files/files-netgrp.c: Likewise
* nss/nss_files/files-parse.c: Likewise
* nss/getXXbyYY_r.c: Call with __errno_location() as value for new
parameter of get functions.
* nss/getXXent_r.c: Likewise.
* localedata/tst-fmon.c: Print debug info if test fails.
* rt/Makefile (routines): Add aio_notify.
* rt/aio.h: Remove non-public definitions. Add aioinit stuff.
* rt/aio_cancel.c: Rewrite to support lio_listio and aio_suspend.
* rt/aio_fsync.c: Likewise.
* rt/aio_misc.c: Likewise.
* rt/aio_misc.h: Likewise.
* rt/aio_read.c: Likewise.
* rt/aio_read64.c: Likewise.
* rt/aio_suspend.c: Likewise.
* rt/aio_write.c: Likewise.
* rt/aio_write64.c: Likewise.
* rt/lio_listio.c: Likewise.
* rt/lio_listio64.c: Likewise.
* rt/aio_notify.c: New file.
* sysdeps/generic/bits/sigset.h: Pretty print.
* sysdeps/posix/pwrite.c: Define weak alias only if function is
really defined as __pwrite.
* sysdeps/unix/sysv/linux/pread.c: Rewrite to use syscall directly
instead of pread64.
* sysdeps/unix/sysv/linux/pwrite.c: Likewise.
* sysdeps/unix/sysv/linux/Makefile [$(subdir)=signal]
(sysdep_routines): Add rt_sigpending and rt_sigreturn.
* sysdeps/unix/sysv/linux/sigaction.c: Use correct value for sigset_t
size in syscall.
* sysdeps/unix/sysv/linux/sigpending.c: Likewise.
* sysdeps/unix/sysv/linux/sigprocmask.c: Likewise.
* sysdeps/unix/sysv/linux/sigreturn.c: Likewise.
* sysdeps/unix/sysv/linux/sigsuspend.c: Likewise.
* sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise.
* sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise.
* sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise. Take care
for ACT being NULL.
* sysdeps/unix/sysv/linux/syscalls.list: Don't mention user for
RT signals.
* sysdeps/unix/sysv/linux/i386/s_pread64.s: Return ENOSYS if
__NR_pread is not defined.
* sysdeps/unix/sysv/linux/i386/s_pwrite64.s: Return ENOSYS if
__NR_pwrite is not defined.
1997-12-07 11:15 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
* nis/nss_compat/compat-grp.c: If buffer is to small, set the file
handle for /etc/group back in some more cases.
* nis/nss_compat/compat-pwd.c: If buffer is to small, set the file
handle for /etc/passwd back in some more cases.
* nis/nss_compat/compat-spwd.c: If buffer is to small, set the file
handle for /etc/shadow back in some more cases.
1997-12-06 17:00 H.J. Lu <hjl@gnu.org>
* sysdeps/posix/sigblock.c (__sigblock): Don't check int mask
beyound its size.
* sysdeps/posix/sigsetmask.c (__sigsetmask): Ditto.
* sysdeps/posix/sigvec.c (convert_mask, __sigvec): Ditto.
1997-12-06 04:38 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/wordsize-32/inttypes.h: Rewrite {str,wcs}to{i,u}max
handling. Don't use macros, we need functions. Use inline functions
for optimization.
* sysdeps/wordsize-64/inttypes.h: Likewise.
* sysdeps/wordsize-32/Makefile: Add strtoimax, stroumax, wcstoimax,
and wcstoumax.
* sysdeps/wordsize-64/Makefile: Likewise.
* sysdeps/wordsize-32/Dist: Likewise.
* sysdeps/wordsize-64/Dist: Likewise.
* sysdeps/wordsize-32/strtoimax.c: New file.
* sysdeps/wordsize-32/strtoumax.c: New file.
* sysdeps/wordsize-32/wcstoimax.c: New file.
* sysdeps/wordsize-32/wcstoumax.c: New file.
* sysdeps/wordsize-64/strtoimax.c: New file.
* sysdeps/wordsize-64/strtoumax.c: New file.
* sysdeps/wordsize-64/wcstoimax.c: New file.
* sysdeps/wordsize-64/wcstoumax.c: New file.
1997-12-04 10:40 Philip Blundell <pb@nexus.co.uk>
* sysdeps/generic/wait3.c (__wait3): Use ANSI-style definition so
that transparent union works.
* sysdeps/generic/wait4.c (__wait4): Likewise.
* sysdeps/generic/wait.c (__wait): Likewise.
* sysdeps/generic/getpeername.c (getpeername): Use socklen_t not
size_t.
* sysdeps/generic/syscall.c (syscall): Return value and arg are
long, to match prototype.
* malloc/malloc.c (HAVE_MREMAP): Set to 0 for ARM, as we don't
have mremap() yet.
* sysdeps/generic/usleep.c (usleep): Returns void, to match prototype.
* sysdeps/unix/sysv/linux/arm/syscalls.list: New file.
* sysdeps/generic/bits/time.h: Use __time_t not time_t.
* sysdeps/generic/bits/resource.h: Include <bits/types.h> for
__rlim_t.
* sysdeps/standalone/arm/bits/errno.h (ENOTTY): Added.
* sysdeps/generic/bits/dirent.h (struct dirent64): Added.
* io/sys/stat.h (S_ISLNK): Always false if we don't have
__S_IFLNK.
* sysdeps/standalone/close.c (_STDIO_H): Define before including
<bits/stdio_lim.h>.
* sysdeps/standalone/filedesc.h (_STDIO_H): Likewise.
1997-12-06 01:09 Ulrich Drepper <drepper@cygnus.com>
* posix/sys/wait.h: Don't use transparent unions in C++.
1997-12-05 Andreas Jaeger <aj@arthur.rhein-neckar.de>
* time/time.h: Add strfxtime.
* libc.map: Add tcgetsid, strcasestr, wmemrtombs, wmemrtowcs,
sysv_signal, strfxtime, pread64, pwrite64.
1997-11-30 21:57 Richard Henderson <rth@cygnus.com>
Alpha changes for EGCS:
* config.h.in (ASM_ALPHA_NG_SYMBOL_PREFIX): New entry.
* configure.in (libc_cv_gcc_alpha_ng_prefix): New check.
* sysdeps/alpha/dl-machine.h (_dl_runtime_resolve): Care for prefix.
(_start): Likewise.
* sysdeps/unix/sysv/linux/alpha/init-first.h: Likewise.
1997-12-08 03:06:47 +00:00
|
|
|
|
CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
|
|
|
|
|
size_t buflen, int *errnop H_ERRNO_PROTO)
|
1996-07-02 19:35:40 +00:00
|
|
|
|
{
|
|
|
|
|
/* Return next entry in host file. */
|
|
|
|
|
enum nss_status status;
|
2011-06-15 02:21:51 +00:00
|
|
|
|
struct parser_data *data = (void *) buffer;
|
|
|
|
|
|
|
|
|
|
if (buflen < sizeof *data)
|
|
|
|
|
{
|
|
|
|
|
*errnop = ERANGE;
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL);
|
|
|
|
|
return NSS_STATUS_TRYAGAIN;
|
|
|
|
|
}
|
1996-07-02 19:35:40 +00:00
|
|
|
|
|
|
|
|
|
__libc_lock_lock (lock);
|
1998-01-21 17:04:36 +00:00
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
if (state.header == NULL)
|
1998-01-21 17:04:36 +00:00
|
|
|
|
{
|
2011-06-15 02:21:51 +00:00
|
|
|
|
status = internal_setent (DBFILE, &state);
|
|
|
|
|
if (status != NSS_STATUS_SUCCESS)
|
|
|
|
|
{
|
|
|
|
|
*errnop = errno;
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL);
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
status = NSS_STATUS_UNAVAIL;
|
|
|
|
|
if (state.header != MAP_FAILED)
|
|
|
|
|
{
|
|
|
|
|
const char *const end = ((const char *) state.header
|
|
|
|
|
+ state.header->valstroffset
|
|
|
|
|
+ state.header->valstrlen);
|
|
|
|
|
while (entidx < end)
|
|
|
|
|
{
|
|
|
|
|
const char *next = rawmemchr (entidx, '\0') + 1;
|
|
|
|
|
size_t len = next - entidx;
|
|
|
|
|
|
|
|
|
|
if (len > buflen)
|
|
|
|
|
{
|
|
|
|
|
/* No room to copy the data to. */
|
|
|
|
|
*errnop = ERANGE;
|
|
|
|
|
H_ERRNO_SET (NETDB_INTERNAL);
|
|
|
|
|
status = NSS_STATUS_TRYAGAIN;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Copy the string to a place where it can be modified. */
|
|
|
|
|
char *p = memcpy (buffer, entidx, len);
|
|
|
|
|
|
|
|
|
|
int err = parse_line (p, result, data, buflen, errnop EXTRA_ARGS);
|
|
|
|
|
|
|
|
|
|
if (err > 0)
|
|
|
|
|
{
|
|
|
|
|
status = NSS_STATUS_SUCCESS;
|
|
|
|
|
entidx = next;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (err < 0)
|
|
|
|
|
{
|
|
|
|
|
H_ERRNO_SET (HOST_NOT_FOUND);
|
|
|
|
|
status = NSS_STATUS_NOTFOUND;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Continue with the next record, this one is ill-formed. */
|
|
|
|
|
entidx = next;
|
|
|
|
|
}
|
1998-01-21 17:04:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-15 02:21:51 +00:00
|
|
|
|
out:
|
1996-07-02 19:35:40 +00:00
|
|
|
|
__libc_lock_unlock (lock);
|
|
|
|
|
|
|
|
|
|
return status;
|
|
|
|
|
}
|