diff options
author | Ulrich Drepper <drepper@redhat.com> | 1998-08-21 17:22:56 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 1998-08-21 17:22:56 +0000 |
commit | 5148d49f37ad2648ef77159b0b2d1b332c584ed9 (patch) | |
tree | 5db7d9cb4929ea18160d7adb37d1635c63f59f03 /nss | |
parent | 1ddf537f074f453f4d8b70c1b5df3f9ac728bec4 (diff) | |
download | glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.tar.gz glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.tar.xz glibc-5148d49f37ad2648ef77159b0b2d1b332c584ed9.zip |
Update.
1998-08-21 17:21 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/glob64.c: Define __stat using __xstat64. 1998-08-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makefile (elf/ldso_install): Put back. The problem still persists. * elf/Makefile (ldso_install): Likewise. 1998-08-20 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * db2/db/db.c (db_open) [_LIBC]: Rename to __nss_db_open and create weak alias. * include/db.h: Declare __nss_db_open. * db2/Versions: Export it. * db2/makedb.c: Convert to use db2 API. * nss/nss_db/db-XXX.c: Likewise. * nss/nss_db/db-netgrp.c: Likewise. * nss/nss_db/db-alias.c: Likewise. (_nss_db_getaliasent_r): Allow retrying with a larger buffer. 1998-08-19 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Remove sys_setresuid, already built automatically (or not). * sysdeps/unix/sysv/linux/syscalls.list: Define __setresuid instead of __syscall_setresuid and add back setresuid. * sysdeps/unix/sysv/linux/seteuid.c: Use __setresuid instead of __syscall_setresuid. 1998-08-21 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/sys/mount.h: Fix typo. * libio/libioP.c (FILEBUF_LITERAL): Also initialize new _offset
Diffstat (limited to 'nss')
-rw-r--r-- | nss/nss_db/db-XXX.c | 56 | ||||
-rw-r--r-- | nss/nss_db/db-alias.c | 44 | ||||
-rw-r--r-- | nss/nss_db/db-netgrp.c | 33 |
3 files changed, 93 insertions, 40 deletions
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c index 3839940028..8ba73efcb6 100644 --- a/nss/nss_db/db-XXX.c +++ b/nss/nss_db/db-XXX.c @@ -17,7 +17,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <db_185.h> +#include <db.h> #include <fcntl.h> #include <bits/libc-lock.h> #include "nsswitch.h" @@ -60,29 +60,41 @@ static enum nss_status internal_setent (int stayopen) { enum nss_status status = NSS_STATUS_SUCCESS; + int err; if (db == NULL) { - db = __dbopen (DBFILE, O_RDONLY, 0, DB_BTREE, NULL); + err = __nss_db_open (DBFILE, DB_BTREE, DB_RDONLY, 0, NULL, NULL, &db); - if (db == NULL) - status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + if (err != 0) + { + __set_errno (err); + status = err == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + } else { /* We have to make sure the file is `closed on exec'. */ + int fd; int result, flags; - result = flags = fcntl ((*db->fd) (db), F_GETFD, 0); + err = db->fd (db, &fd); + if (err != 0) + { + __set_errno (err); + result = -1; + } + else + result = flags = fcntl (fd, F_GETFD, 0); if (result >= 0) { flags |= FD_CLOEXEC; - result = fcntl ((*db->fd) (db), F_SETFD, flags); + result = fcntl (fd, F_SETFD, flags); } if (result < 0) { /* Something went wrong. Close the stream and return a failure. */ - (*db->close) (db); + db->close (db, 0); db = NULL; status = NSS_STATUS_UNAVAIL; } @@ -122,7 +134,7 @@ internal_endent (void) { if (db != NULL) { - (*db->close) (db); + db->close (db, 0); db = NULL; } } @@ -146,7 +158,7 @@ CONCAT(_nss_db_end,ENTNAME) (void) /* Do a database lookup for KEY. */ static enum nss_status -lookup (const DBT *key, struct STRUCTURE *result, +lookup (DBT *key, struct STRUCTURE *result, void *buffer, size_t buflen, int *errnop H_ERRNO_PROTO) { char *p; @@ -164,17 +176,21 @@ lookup (const DBT *key, struct STRUCTURE *result, } /* Succeed iff it matches a value that parses correctly. */ - err = (*db->get) (db, key, &value, 0); - if (err < 0) - { - *errnop = errno; - H_ERRNO_SET (NETDB_INTERNAL); - status = NSS_STATUS_UNAVAIL; - } - else if (err != 0) + value.flags = 0; + err = db->get (db, NULL, key, &value, 0); + if (err != 0) { - H_ERRNO_SET (HOST_NOT_FOUND); - status = NSS_STATUS_NOTFOUND; + if (err == DB_NOTFOUND) + { + H_ERRNO_SET (HOST_NOT_FOUND); + status = NSS_STATUS_NOTFOUND; + } + else + { + *errnop = err; + H_ERRNO_SET (NETDB_INTERNAL); + status = NSS_STATUS_UNAVAIL; + } } else if (buflen < value.size) { @@ -253,6 +269,7 @@ _nss_db_get##name##_r (proto, \ const size_t size = (keysize) + 1; \ key.data = __alloca (size); \ key.size = KEYPRINTF keypattern; \ + key.flags = 0; \ __libc_lock_lock (lock); \ status = lookup (&key, result, buffer, buflen, errnop H_ERRNO_ARG); \ __libc_lock_unlock (lock); \ @@ -281,6 +298,7 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer, do { key.size = snprintf (key.data = buf, sizeof buf, "0%u", entidx++); + key.flags = 0; status = lookup (&key, result, buffer, buflen, errnop H_ERRNO_ARG); if (status == NSS_STATUS_TRYAGAIN #ifdef NEED_H_ERRNO diff --git a/nss/nss_db/db-alias.c b/nss/nss_db/db-alias.c index 27b7952b30..81037ed5f7 100644 --- a/nss/nss_db/db-alias.c +++ b/nss/nss_db/db-alias.c @@ -21,7 +21,7 @@ #include <aliases.h> #include <alloca.h> #include <ctype.h> -#include <db_185.h> +#include <db.h> #include <errno.h> #include <fcntl.h> #include <bits/libc-lock.h> @@ -44,29 +44,42 @@ static enum nss_status internal_setent (int stayopen) { enum nss_status status = NSS_STATUS_SUCCESS; + int err; if (db == NULL) { - db = __dbopen (_PATH_VARDB "aliases.db", O_RDONLY, 0, DB_BTREE, NULL); + err = __nss_db_open (_PATH_VARDB "aliases.db", DB_BTREE, DB_RDONLY, 0, + NULL, NULL, &db); - if (db == NULL) - status = NSS_STATUS_UNAVAIL; + if (err != 0) + { + __set_errno (err); + status = NSS_STATUS_UNAVAIL; + } else { /* We have to make sure the file is `closed on exec'. */ + int fd; int result, flags; - result = flags = fcntl ((*db->fd) (db), F_GETFD, 0); + err = db->fd (db, &fd); + if (err != 0) + { + __set_errno (err); + result = -1; + } + else + result = flags = fcntl (fd, F_GETFD, 0); if (result >= 0) { flags |= FD_CLOEXEC; - result = fcntl ((*db->fd) (db), F_SETFD, flags); + result = fcntl (fd, F_SETFD, flags); } if (result < 0) { /* Something went wrong. Close the stream and return a failure. */ - (*db->close) (db); + db->close (db, 0); db = NULL; status = NSS_STATUS_UNAVAIL; } @@ -106,7 +119,7 @@ internal_endent (void) { if (db != NULL) { - (*db->close) (db); + db->close (db, 0); db = NULL; } } @@ -133,7 +146,7 @@ _nss_db_endaliasent (void) :include: statements so we simply have to parse the list and store the result. */ static enum nss_status -lookup (const DBT *key, struct aliasent *result, char *buffer, +lookup (DBT *key, struct aliasent *result, char *buffer, size_t buflen, int *errnop) { enum nss_status status; @@ -142,9 +155,13 @@ lookup (const DBT *key, struct aliasent *result, char *buffer, /* Open the database. */ status = internal_setent (keep_db); if (status != NSS_STATUS_SUCCESS) - return status; + { + *errnop = errno; + return status; + } - if ((*db->get) (db, key, &value, 0) == 0) + value.flags = 0; + if (db->get (db, NULL, key, &value, 0) == 0) { const char *src = value.data; @@ -228,7 +245,11 @@ _nss_db_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen, __libc_lock_lock (lock); key.size = snprintf (key.data = buf, sizeof buf, "0%u", entidx++); + key.flags = 0; status = lookup (&key, result, buffer, buflen, errnop); + if (status == NSS_STATUS_TRYAGAIN && *errnop == ERANGE) + /* Give the user a chance to get the same entry with a larger buffer. */ + --entidx; __libc_lock_unlock (lock); return status; @@ -247,6 +268,7 @@ _nss_db_getaliasbyname_r (const char *name, struct aliasent *result, key.data = __alloca (key.size); ((char *) key.data)[0] = '.'; memcpy (&((char *) key.data)[1], name, key.size - 1); + key.flags = 0; __libc_lock_lock (lock); status = lookup (&key, result, buffer, buflen, errnop); diff --git a/nss/nss_db/db-netgrp.c b/nss/nss_db/db-netgrp.c index d63d1cb1af..8707d85f04 100644 --- a/nss/nss_db/db-netgrp.c +++ b/nss/nss_db/db-netgrp.c @@ -18,7 +18,7 @@ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <db_185.h> +#include <db.h> #include <errno.h> #include <fcntl.h> #include <string.h> @@ -43,32 +43,44 @@ enum nss_status _nss_db_setnetgrent (const char *group) { enum nss_status status = NSS_STATUS_SUCCESS; + int err; __libc_lock_lock (lock); /* Make sure the data base file is open. */ if (db == NULL) { - db = __dbopen (DBFILE, O_RDONLY, 0, DB_BTREE, NULL); + err = __nss_db_open (DBFILE, DB_BTREE, O_RDONLY, 0, NULL, NULL, &db); - if (db == NULL) - status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + if (err != 0) + { + __set_errno (err); + status = err == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL; + } else { /* We have to make sure the file is `closed on exec'. */ + int fd; int result, flags; - result = flags = fcntl ((*db->fd) (db), F_GETFD, 0); + err = db->fd (db, &fd); + if (err != 0) + { + __set_errno (err); + result = -1; + } + else + result = flags = fcntl (fd, F_GETFD, 0); if (result >= 0) { flags |= FD_CLOEXEC; - result = fcntl ((*db->fd) (db), F_SETFD, flags); + result = fcntl (fd, F_SETFD, flags); } if (result < 0) { /* Something went wrong. Close the stream and return a failure. */ - (*db->close) (db); + db->close (db, 0); db = NULL; status = NSS_STATUS_UNAVAIL; } @@ -77,10 +89,11 @@ _nss_db_setnetgrent (const char *group) if (status == NSS_STATUS_SUCCESS) { - DBT key = { data: (void *) group, size: strlen (group) }; + DBT key = { data: (void *) group, size: strlen (group), flags: 0 }; DBT value; - if ((*db->get) (db, &key, &value, 0) != 0) + value.flags = 0; + if (db->get (db, NULL, &key, &value, 0) != 0) status = NSS_STATUS_NOTFOUND; else cursor = entry = value.data; @@ -100,7 +113,7 @@ _nss_db_endnetgrent (void) if (db != NULL) { - (*db->close) (db); + db->close (db, 0); db = NULL; } |