*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.247 2001/10/19 17:03:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.248 2001/10/19 18:19:41 tgl Exp $
*
* NOTES
*
{
char path[MAXPGPATH];
FILE *fp;
+ struct stat stat_buf;
if (checkdir == NULL)
{
progname);
ExitPostmaster(2);
}
+
+ /*
+ * Check if the directory has group or world access. If so, reject.
+ */
+ if (stat(checkdir, &stat_buf) == -1)
+ {
+ if (errno == ENOENT)
+ elog(FATAL, "data directory %s was not found", checkdir);
+ else
+ elog(FATAL, "could not read permissions of directory %s: %m",
+ checkdir);
+ }
+
+ if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
+ elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
+ checkdir);
/* Look for PG_VERSION before looking for pg_control */
ValidatePgVersion(checkdir);
IgnoreSystemIndexes(false);
- optind = 1; /* start over */
+ optind = 1; /* start over (should be redundant here) */
#ifdef HAVE_INT_OPTRESET
optreset = 1;
#endif
av[ac] = (char *) NULL;
+ optind = 1; /* reset getopt(3) for subprocess */
+#ifdef HAVE_INT_OPTRESET
+ optreset = 1;
+#endif
+
/*
* Release postmaster's working memory context so that backend can
* recycle the space. Note this does not trash *MyProcPort, because
av[ac] = (char *) NULL;
- optind = 1;
+ optind = 1; /* reset getopt(3) for subprocess */
+#ifdef HAVE_INT_OPTRESET
+ optreset = 1;
+#endif
BootstrapMain(ac, av);
ExitPostmaster(0);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.236 2001/10/19 17:03:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.237 2001/10/19 18:19:41 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
secure = true;
ctx = PGC_POSTMASTER;
- optind = 1; /* reset after postmaster's usage */
-
while ((flag = getopt(argc, argv, "A:B:c:CD:d:Eef:FiNOPo:p:S:st:v:W:x:-:")) != EOF)
switch (flag)
{
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.236 $ $Date: 2001/10/19 17:03:08 $\n");
+ puts("$Revision: 1.237 $ $Date: 2001/10/19 18:19:41 $\n");
}
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.79 2001/10/19 17:03:08 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.80 2001/10/19 18:19:41 tgl Exp $
*
*-------------------------------------------------------------------------
*/
SetDataDir(const char *dir)
{
char *new;
- struct stat stat_buf;
AssertArg(dir);
if (!new)
elog(FATAL, "out of memory");
}
-
- /*
- * Check if the directory has group or world access. If so, reject.
- */
- if (stat(new, &stat_buf) == -1)
- elog(FATAL, "could not read permissions of directory %s: %s",
- new, strerror(errno));
-
- if (stat_buf.st_mode & (S_IRWXG | S_IRWXO))
- elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)",
- new);
if (DataDir)
free(DataDir);