]> granicus.if.org Git - postgresql/commitdiff
Fixed exec path problem.
authorBruce Momjian <bruce@momjian.us>
Mon, 8 Jun 1998 22:28:30 +0000 (22:28 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 8 Jun 1998 22:28:30 +0000 (22:28 +0000)
src/backend/postmaster/postmaster.c
src/backend/tcop/postgres.c
src/backend/utils/init/findbe.c
src/include/miscadmin.h

index 706d7d6a8f064534f10287b52fc4ad49f2856aa2..06ecedd21ebe032f0c558b99e6071fefb8cf0536 100644 (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]);
index 0c6cc0f40f43cb6edc8ba6b7e221c12c1dd034c5..e2a778b4916471160b8b48a28582ca5e04c7ee44 100644 (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 $");
        }
 
        /* ----------------
index e2cc9219a74a671bfbdee709b0681601902993db..74571ebc4abe7c20bb0e0c7b4719a1fdb2c3433a 100644 (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);
 }
index d7cee404c58e8c5f4c7a8c5101ff69399d24199a..0c6dcfaaf974b812906d6d88649e175d3f3a94a1 100644 (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 */