Fixed exec path problem.

This commit is contained in:
Bruce Momjian 1998-06-08 22:28:30 +00:00
parent b206958d13
commit 3912b75705
4 changed files with 27 additions and 17 deletions

View File

@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.83 1998/06/08 19:36:40 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.84 1998/06/08 22:28:26 momjian Exp $
*
* NOTES
*
@ -315,9 +315,19 @@ PostmasterMain(int argc, char *argv[])
for (; i < 4; i++)
new_argv[i] = "";
new_argv[4] = NULL;
if (!Execfile[0] && FindExec(Execfile, argv[0]) < 0)
{
fprintf(stderr, "%s: could not find postmaster to execute...\n",
argv[0]);
exit(1);
}
new_argv[0] = Execfile;
execv(new_argv[0], new_argv);
perror(new_argv[0]);
/* How did we get here, error! */
perror(new_argv[0]);
fprintf(stderr, "PostmasterMain execv failed on %s\n", argv[0]);
exit(1);
}
@ -461,7 +471,7 @@ PostmasterMain(int argc, char *argv[])
exit(2);
}
if (!Execfile[0] && FindBackend(Execfile, argv[0]) < 0)
if (!Execfile[0] && FindExec(Execfile, argv[0]) < 0)
{
fprintf(stderr, "%s: could not find backend to execute...\n",
argv[0]);

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.73 1998/06/04 17:26:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.74 1998/06/08 22:28:27 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@ -1167,7 +1167,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
SetCharSet();
#endif
if (FindBackend(pg_pathname, argv[0]) < 0)
if (FindExec(pg_pathname, argv[0]) < 0)
elog(FATAL, "%s: could not locate executable, bailing out...",
argv[0]);
@ -1314,7 +1314,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface");
puts("$Revision: 1.73 $ $Date: 1998/06/04 17:26:45 $");
puts("$Revision: 1.74 $ $Date: 1998/06/08 22:28:27 $");
}
/* ----------------

View File

@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.7 1997/09/08 02:31:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.8 1998/06/08 22:28:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -144,14 +144,14 @@ ValidateBackend(char *path)
}
/*
* FindBackend -- find an absolute path to a valid backend executable
* FindExec -- find an absolute path to a valid backend executable
*
* The reason we have to work so hard to find an absolute path is that
* we need to feed the backend server the location of its actual
* executable file -- otherwise, we can't do dynamic loading.
*/
int
FindBackend(char *backend, char *argv0)
FindExec(char *backend, char *argv0)
{
char buf[MAXPGPATH + 2];
char *p;
@ -188,11 +188,11 @@ FindBackend(char *backend, char *argv0)
{
strncpy(backend, buf, MAXPGPATH);
if (DebugLvl)
fprintf(stderr, "FindBackend: found \"%s\" using argv[0]\n",
fprintf(stderr, "FindExec: found \"%s\" using argv[0]\n",
backend);
return (0);
}
fprintf(stderr, "FindBackend: invalid backend \"%s\"\n",
fprintf(stderr, "FindExec: invalid backend \"%s\"\n",
buf);
return (-1);
}
@ -204,7 +204,7 @@ FindBackend(char *backend, char *argv0)
if ((p = getenv("PATH")) && *p)
{
if (DebugLvl)
fprintf(stderr, "FindBackend: searching PATH ...\n");
fprintf(stderr, "FindExec: searching PATH ...\n");
pathlen = strlen(p);
path = malloc(pathlen + 1);
strcpy(path, p);
@ -225,14 +225,14 @@ FindBackend(char *backend, char *argv0)
case 0: /* found ok */
strncpy(backend, buf, MAXPGPATH);
if (DebugLvl)
fprintf(stderr, "FindBackend: found \"%s\" using PATH\n",
fprintf(stderr, "FindExec: found \"%s\" using PATH\n",
backend);
free(path);
return (0);
case -1: /* wasn't even a candidate, keep looking */
break;
case -2: /* found but disqualified */
fprintf(stderr, "FindBackend: could not read backend \"%s\"\n",
fprintf(stderr, "FindExec: could not read backend \"%s\"\n",
buf);
free(path);
return (-1);
@ -243,6 +243,6 @@ FindBackend(char *backend, char *argv0)
free(path);
}
fprintf(stderr, "FindBackend: could not find a backend to execute...\n");
fprintf(stderr, "FindExec: could not find a backend to execute...\n");
return (-1);
}

View File

@ -11,7 +11,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.24 1998/05/29 17:00:22 momjian Exp $
* $Id: miscadmin.h,v 1.25 1998/06/08 22:28:30 momjian Exp $
*
* NOTES
* some of the information in this file will be moved to
@ -126,7 +126,7 @@ extern void SetPgUserName(void);
extern Oid GetUserId(void);
extern void SetUserId(void);
extern int ValidateBackend(char *path);
extern int FindBackend(char *backend, char *argv0);
extern int FindExec(char *backend, char *argv0);
extern int CheckPathAccess(char *path, char *name, int open_mode);
/* lower case version for case-insensitive SQL referenced in pg_proc.h */