1111 *
1212 *
1313 * IDENTIFICATION
14- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.145 2000/06/02 15:57:22 momjian Exp $
14+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.146 2000/06/04 01:44:31 petere Exp $
1515 *
1616 * NOTES
1717 *
3333 *
3434 *-------------------------------------------------------------------------
3535 */
36+ #include "postgres.h"
37+
3638#include <unistd.h>
3739#include <signal.h>
3840#include <sys/wait.h>
4648#include <time.h>
4749#include <sys/param.h>
4850
49- #include "postgres.h"
5051 /* moved here to prevent double define */
5152#ifdef HAVE_NETDB_H
5253#include <netdb.h>
5354#endif
5455
55- #ifndef MAXHOSTNAMELEN
56- #define MAXHOSTNAMELEN 256
57- #endif
58-
5956#ifdef HAVE_LIMITS_H
6057#include <limits.h>
6158#else
7269#include "getopt.h"
7370#endif
7471
75- #ifndef HAVE_GETHOSTNAME
76- #include "port-protos.h"
77- #endif
78-
7972#include "commands/async.h"
8073#include "lib/dllist.h"
8174#include "libpq/auth.h"
@@ -191,8 +184,6 @@ static volatile bool got_SIGHUP = false;
191184/*
192185 * Default Values
193186 */
194- static char Execfile [MAXPGPATH ];
195-
196187static int ServerSock_INET = INVALID_SOCK ; /* stream socket server */
197188
198189#if !defined(__CYGWIN32__ ) && !defined(__QNX__ )
@@ -278,7 +269,7 @@ static void SignalChildren(SIGNAL_ARGS);
278269static int CountChildren (void );
279270static int
280271SetOptsFile (char * progname , int port , char * datadir ,
281- int assert , int nbuf , char * execfile ,
272+ int assert , int nbuf ,
282273 int debuglvl , int netserver ,
283274#ifdef USE_SSL
284275 int securenetserver ,
@@ -368,61 +359,17 @@ int
368359PostmasterMain (int argc , char * argv [])
369360{
370361 int opt ;
371- char * hostName ;
372362 int status ;
373363 int silentflag = 0 ;
374364 bool DataDirOK ; /* We have a usable PGDATA value */
375- char hostbuf [MAXHOSTNAMELEN ];
376- int nonblank_argc ;
377365 char original_extraoptions [MAXPGPATH ];
378366
379367 * original_extraoptions = '\0' ;
380368
381- #ifndef HAVE_SETPROCTITLE
382- /*
383- * We need four params so we can display status. If we don't get
384- * them from the user, let's make them ourselves.
385- */
386- if (argc < 5 )
387- {
388- int i ;
389- char * new_argv [6 ];
390-
391- for (i = 0 ; i < argc ; i ++ )
392- new_argv [i ] = argv [i ];
393- for (; i < 5 ; i ++ )
394- new_argv [i ] = "" ;
395- new_argv [5 ] = NULL ;
396-
397- if (!Execfile [0 ] && FindExec (Execfile , argv [0 ], "postmaster" ) < 0 )
398- {
399- fprintf (stderr , "%s: could not find postmaster to execute...\n" ,
400- argv [0 ]);
401- exit (1 );
402- }
403- new_argv [0 ] = Execfile ;
404-
405- execv (new_argv [0 ], new_argv );
406-
407- /* How did we get here? Error! */
408- perror (new_argv [0 ]);
409- fprintf (stderr , "PostmasterMain execv failed on %s\n" , argv [0 ]);
410- exit (1 );
411- }
412- #endif
413-
414369 progname = argv [0 ];
415370 real_argv = argv ;
416371 real_argc = argc ;
417372
418- /*
419- * don't process any dummy args we placed at the end for status
420- * display
421- */
422- for (nonblank_argc = argc ; nonblank_argc > 0 ; nonblank_argc -- )
423- if (argv [nonblank_argc - 1 ] != NULL && argv [nonblank_argc - 1 ][0 ] != '\0' )
424- break ;
425-
426373 /*
427374 * for security, no dir or file created can be group or other
428375 * accessible
@@ -431,13 +378,6 @@ PostmasterMain(int argc, char *argv[])
431378
432379 ResetAllOptions ();
433380
434- if (!(hostName = getenv ("PGHOST" )))
435- {
436- if (gethostname (hostbuf , MAXHOSTNAMELEN ) < 0 )
437- strcpy (hostbuf , "localhost" );
438- hostName = hostbuf ;
439- }
440-
441381 MyProcPid = getpid ();
442382 DataDir = getenv ("PGDATA" ); /* default value */
443383
@@ -455,7 +395,7 @@ PostmasterMain(int argc, char *argv[])
455395 * will occur.
456396 */
457397 opterr = 1 ;
458- while ((opt = getopt (nonblank_argc , argv , "A:a:B:b:D:d:Film:MN:no:p:Ss-:" )) != EOF )
398+ while ((opt = getopt (argc , argv , "A:a:B:b:D:d:Film:MN:no:p:Ss-:" )) != EOF )
459399 {
460400 if (opt == 'D' )
461401 DataDir = optarg ;
@@ -472,7 +412,7 @@ PostmasterMain(int argc, char *argv[])
472412 ProcessConfigFile (PGC_POSTMASTER );
473413
474414 IgnoreSystemIndexes (false);
475- while ((opt = getopt (nonblank_argc , argv , "A:a:B:b:D:d:Film:MN:no:p:Ss-:" )) != EOF )
415+ while ((opt = getopt (argc , argv , "A:a:B:b:D:d:Film:MN:no:p:Ss-:" )) != EOF )
476416 {
477417 switch (opt )
478418 {
@@ -496,15 +436,7 @@ PostmasterMain(int argc, char *argv[])
496436 NBuffers = atoi (optarg );
497437 break ;
498438 case 'b' :
499- /* Set the backend executable file to use. */
500- if (!ValidateBinary (optarg ))
501- StrNCpy (Execfile , optarg , MAXPGPATH );
502- else
503- {
504- fprintf (stderr , "%s: invalid backend \"%s\"\n" ,
505- progname , optarg );
506- exit (2 );
507- }
439+ /* Can no longer set the backend executable file to use. */
508440 break ;
509441 case 'D' :
510442 /* already done above */
@@ -630,13 +562,6 @@ PostmasterMain(int argc, char *argv[])
630562 exit (1 );
631563 }
632564
633- if (!Execfile [0 ] && FindExec (Execfile , argv [0 ], "postgres" ) < 0 )
634- {
635- fprintf (stderr , "%s: could not find backend to execute...\n" ,
636- argv [0 ]);
637- exit (1 );
638- }
639-
640565#ifdef USE_SSL
641566 if (!NetServer && SecureNetServer )
642567 {
@@ -649,7 +574,7 @@ PostmasterMain(int argc, char *argv[])
649574
650575 if (NetServer )
651576 {
652- status = StreamServerPort (hostName , (unsigned short )PostPortName , & ServerSock_INET );
577+ status = StreamServerPort (AF_INET , (unsigned short )PostPortName , & ServerSock_INET );
653578 if (status != STATUS_OK )
654579 {
655580 fprintf (stderr , "%s: cannot create INET stream port\n" ,
@@ -659,7 +584,7 @@ PostmasterMain(int argc, char *argv[])
659584 }
660585
661586#if !defined(__CYGWIN32__ ) && !defined(__QNX__ )
662- status = StreamServerPort (NULL , (unsigned short )PostPortName , & ServerSock_UNIX );
587+ status = StreamServerPort (AF_UNIX , (unsigned short )PostPortName , & ServerSock_UNIX );
663588 if (status != STATUS_OK )
664589 {
665590 fprintf (stderr , "%s: cannot create UNIX stream port\n" ,
@@ -696,7 +621,6 @@ PostmasterMain(int argc, char *argv[])
696621 assert_enabled , /* whether -A is specified
697622 * or not */
698623 NBuffers , /* -B: number of shared buffers */
699- Execfile , /* -b: postgres executable file */
700624 DebugLvl , /* -d: debug level */
701625 NetServer , /* -i: accept connection from INET */
702626#ifdef USE_SSL
@@ -785,7 +709,6 @@ pmdaemonize(char *extraoptions)
785709 assert_enabled , /* whether -A is specified
786710 * or not */
787711 NBuffers , /* -B: number of shared buffers */
788- Execfile , /* -b: postgres executable file */
789712 DebugLvl , /* -d: debug level */
790713 NetServer , /* -i: accept connection from INET */
791714#ifdef USE_SSL
@@ -1905,7 +1828,6 @@ DoBackend(Port *port)
19051828{
19061829 char * av [ARGV_SIZE * 2 ];
19071830 int ac = 0 ;
1908- char execbuf [MAXPGPATH ];
19091831 char debugbuf [ARGV_SIZE ];
19101832 char protobuf [ARGV_SIZE ];
19111833 char dbbuf [ARGV_SIZE ];
@@ -1958,26 +1880,7 @@ DoBackend(Port *port)
19581880 * ----------------
19591881 */
19601882
1961- StrNCpy (execbuf , Execfile , MAXPGPATH );
1962- av [ac ++ ] = execbuf ;
1963-
1964- /*
1965- * We need to set our argv[0] to an absolute path name because some
1966- * OS's use this for dynamic loading, like BSDI. Without it, when we
1967- * change directories to the database dir, the dynamic loader can't
1968- * find the base executable and fails. Another advantage is that this
1969- * changes the 'ps' displayed process name on some platforms. It does
1970- * on BSDI. That's a big win.
1971- */
1972-
1973- #ifndef linux
1974-
1975- /*
1976- * This doesn't work on linux and overwrites the only valid pointer to
1977- * the argv buffer. See PS_INIT_STATUS macro.
1978- */
1979- real_argv [0 ] = Execfile ;
1980- #endif
1883+ av [ac ++ ] = "postgres" ;
19811884
19821885 /*
19831886 * Pass the requested debugging level along to the backend. Level one
@@ -2229,7 +2132,6 @@ SSDataBase(bool startup)
22292132 {
22302133 char * av [ARGV_SIZE * 2 ];
22312134 int ac = 0 ;
2232- char execbuf [MAXPGPATH ];
22332135 char nbbuf [ARGV_SIZE ];
22342136 char dbbuf [ARGV_SIZE ];
22352137
@@ -2244,8 +2146,7 @@ SSDataBase(bool startup)
22442146 ServerSock_UNIX = INVALID_SOCK ;
22452147#endif
22462148
2247- StrNCpy (execbuf , Execfile , MAXPGPATH );
2248- av [ac ++ ] = execbuf ;
2149+ av [ac ++ ] = "postgres" ;
22492150
22502151 av [ac ++ ] = "-d" ;
22512152
@@ -2294,7 +2195,7 @@ SSDataBase(bool startup)
22942195 */
22952196static int
22962197SetOptsFile (char * progname , int port , char * datadir ,
2297- int assert , int nbuf , char * execfile ,
2198+ int assert , int nbuf ,
22982199 int debuglvl , int netserver ,
22992200#ifdef USE_SSL
23002201 int securenetserver ,
@@ -2324,7 +2225,7 @@ SetOptsFile(char *progname, int port, char *datadir,
23242225 strcat (opts , buf );
23252226 }
23262227
2327- snprintf (buf , sizeof (buf ), "-B %d\n-b %s\n " , nbuf , execfile );
2228+ snprintf (buf , sizeof (buf ), "-B %d\n" , nbuf );
23282229 strcat (opts , buf );
23292230
23302231 if (debuglvl )
0 commit comments