1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-03 09:13:20 +03:00

Reduce open() calls. Replace fopen() calls with calls to fd.c functions.

This commit is contained in:
Bruce Momjian
1997-08-18 02:15:04 +00:00
parent eaae21fb4d
commit 022903f22e
11 changed files with 74 additions and 106 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.17 1997/08/12 22:52:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.18 1997/08/18 02:14:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,7 +28,7 @@
#include <libpq/pqcomm.h>
#include <libpq/hba.h>
#include <port/inet_aton.h> /* For inet_aton() */
#include <storage/fd.h>
/* Some standard C libraries, including GNU, have an isblank() function.
Others, including Solaris, do not. So we have our own.
@@ -334,8 +334,8 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
strlen(CONF_FILE)+2)*sizeof(char));
sprintf(conf_file, "%s/%s", DataDir, CONF_FILE);
file = fopen(conf_file, "r");
if (file == 0) {
file = AllocateFile(conf_file, "r");
if (file == NULL) {
/* The open of the config file failed. */
*host_ok_p = false;
@@ -350,7 +350,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
} else {
process_open_config_file(file, ip_addr, database, host_ok_p, userauth_p,
usermap_name, find_password_entries);
fclose(file);
FreeFile(file);
}
free(conf_file);
}
@@ -636,8 +636,8 @@ verify_against_usermap(const char DataDir[],
strlen(MAP_FILE)+2)*sizeof(char));
sprintf(map_file, "%s/%s", DataDir, MAP_FILE);
file = fopen(map_file, "r");
if (file == 0) {
file = AllocateFile(map_file, "r");
if (file == NULL) {
/* The open of the map file failed. */
*checks_out_p = false;
@@ -654,7 +654,7 @@ verify_against_usermap(const char DataDir[],
verify_against_open_usermap(file,
pguser, ident_username, usermap_name,
checks_out_p);
fclose(file);
FreeFile(file);
}
free(map_file);

View File

@@ -2,6 +2,7 @@
#include <libpq/password.h>
#include <libpq/hba.h>
#include <libpq/libpq.h>
#include <storage/fd.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_CRYPT_H
@@ -56,7 +57,7 @@ verify_password(char *user, char *password, Port *port,
strcat(pw_file_fullname, "/");
strcat(pw_file_fullname, pw_file_name);
pw_file = fopen(pw_file_fullname, "r");
pw_file = AllocateFile(pw_file_fullname, "r");
if(!pw_file) {
sprintf(PQerrormsg,
"verify_password: couldn't open password file '%s'\n",
@@ -84,7 +85,7 @@ verify_password(char *user, char *password, Port *port,
if(strcmp(user, test_user) == 0) {
/* we're outta here one way or the other. */
fclose(pw_file);
FreeFile(pw_file);
if(strcmp(crypt(password, salt), test_pw) == 0) {
/* it matched. */