aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/libpq/hba.c13
-rw-r--r--src/backend/utils/init/findbe.c4
-rw-r--r--src/backend/utils/init/postinit.c22
3 files changed, 15 insertions, 24 deletions
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index 8ff7c09c9a6..0cc2bbf6ac9 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.18 1997/08/18 02:14:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.19 1997/08/27 03:48:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,9 +15,9 @@
#include <string.h>
#include <errno.h>
#include <pwd.h>
-#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
#include <sys/socket.h>
-#include <sys/types.h> /* needed by in.h on Ultrix */
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
@@ -299,8 +299,7 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
system.
---------------------------------------------------------------------------*/
- int rc;
- struct stat statbuf;
+ int fd;
FILE *file; /* The config file we have to read */
@@ -315,9 +314,9 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr,
strlen(OLD_CONF_FILE)+2)*sizeof(char));
sprintf(old_conf_file, "%s/%s", DataDir, OLD_CONF_FILE);
- rc = stat(old_conf_file, &statbuf);
- if (rc == 0) {
+ if ((fd = open(old_conf_file,O_RDONLY,0)) != -1) {
/* Old config file exists. Tell this guy he needs to upgrade. */
+ close(fd);
sprintf(PQerrormsg,
"A file exists by the name used for host-based authentication "
"in prior releases of Postgres (%s). The name and format of "
diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c
index 4043baa2888..8718e3f91d6 100644
--- a/src/backend/utils/init/findbe.c
+++ b/src/backend/utils/init/findbe.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.4 1997/08/12 20:16:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.5 1997/08/27 03:48:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -14,8 +14,8 @@
#include <grp.h>
#include <pwd.h>
#include <string.h>
-#include <sys/stat.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include "postgres.h"
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index f338cc83c70..fb21e51a492 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.11 1997/08/19 21:35:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.12 1997/08/27 03:48:39 momjian Exp $
*
* NOTES
* InitPostgres() is the function called from PostgresMain
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <string.h>
#include <sys/file.h>
-#include <sys/stat.h>
#include <sys/types.h>
#include <math.h>
#include <unistd.h>
@@ -79,15 +78,6 @@ static void InitUserid(void);
static IPCKey PostgresIpcKey;
-
-#ifndef private
-#ifndef EBUG
-#define private static
-#else /* !defined(EBUG) */
-#define private
-#endif /* !defined(EBUG) */
-#endif /* !defined(private) */
-
/* ----------------------------------------------------------------
* InitPostgres support
* ----------------------------------------------------------------
@@ -141,7 +131,7 @@ InitMyDatabaseId()
sprintf(dbfname, "%s%cpg_database", DataDir, SEP_CHAR);
fileflags = O_RDONLY;
- if ((dbfd = open(dbfname, O_RDONLY, 0666)) < 0)
+ if ((dbfd = open(dbfname, O_RDONLY, 0)) < 0)
elog(FATAL, "Cannot open %s", dbfname);
pfree(dbfname);
@@ -261,10 +251,10 @@ static void
DoChdirAndInitDatabaseNameAndPath(char *name) {
char *reason;
/* Failure reason returned by some function. NULL if no failure */
- struct stat statbuf;
+ int fd;
char errormsg[1000];
- if (stat(DataDir, &statbuf) < 0)
+ if ((fd = open(DataDir, O_RDONLY,0)) == -1)
sprintf(errormsg, "Database system does not exist. "
"PGDATA directory '%s' not found. Normally, you "
"create a database system by running initdb.",
@@ -272,13 +262,14 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
else {
char myPath[MAXPGPATH]; /* DatabasePath points here! */
+ close(fd);
if (strlen(DataDir) + strlen(name) + 10 > sizeof(myPath))
sprintf(errormsg, "Internal error in postinit.c: database "
"pathname exceeds maximum allowable length.");
else {
sprintf(myPath, "%s/base/%s", DataDir, name);
- if (stat(myPath, &statbuf) < 0)
+ if ((fd = open(myPath, O_RDONLY,0)) == -1)
sprintf(errormsg,
"Database '%s' does not exist. "
"(We know this because the directory '%s' "
@@ -288,6 +279,7 @@ DoChdirAndInitDatabaseNameAndPath(char *name) {
"of '%s/base/'.",
name, myPath, DataDir);
else {
+ close(fd);
ValidatePgVersion(DataDir, &reason);
if (reason != NULL)
sprintf(errormsg,