11
11
*
12
12
*
13
13
* 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 $
15
15
*
16
16
* NOTES
17
17
*
33
33
*
34
34
*-------------------------------------------------------------------------
35
35
*/
36
+ #include "postgres.h"
37
+
36
38
#include <unistd.h>
37
39
#include <signal.h>
38
40
#include <sys/wait.h>
46
48
#include <time.h>
47
49
#include <sys/param.h>
48
50
49
- #include "postgres.h"
50
51
/* moved here to prevent double define */
51
52
#ifdef HAVE_NETDB_H
52
53
#include <netdb.h>
53
54
#endif
54
55
55
- #ifndef MAXHOSTNAMELEN
56
- #define MAXHOSTNAMELEN 256
57
- #endif
58
-
59
56
#ifdef HAVE_LIMITS_H
60
57
#include <limits.h>
61
58
#else
72
69
#include "getopt.h"
73
70
#endif
74
71
75
- #ifndef HAVE_GETHOSTNAME
76
- #include "port-protos.h"
77
- #endif
78
-
79
72
#include "commands/async.h"
80
73
#include "lib/dllist.h"
81
74
#include "libpq/auth.h"
@@ -191,8 +184,6 @@ static volatile bool got_SIGHUP = false;
191
184
/*
192
185
* Default Values
193
186
*/
194
- static char Execfile [MAXPGPATH ];
195
-
196
187
static int ServerSock_INET = INVALID_SOCK ; /* stream socket server */
197
188
198
189
#if !defined(__CYGWIN32__ ) && !defined(__QNX__ )
@@ -278,7 +269,7 @@ static void SignalChildren(SIGNAL_ARGS);
278
269
static int CountChildren (void );
279
270
static int
280
271
SetOptsFile (char * progname , int port , char * datadir ,
281
- int assert , int nbuf , char * execfile ,
272
+ int assert , int nbuf ,
282
273
int debuglvl , int netserver ,
283
274
#ifdef USE_SSL
284
275
int securenetserver ,
@@ -368,61 +359,17 @@ int
368
359
PostmasterMain (int argc , char * argv [])
369
360
{
370
361
int opt ;
371
- char * hostName ;
372
362
int status ;
373
363
int silentflag = 0 ;
374
364
bool DataDirOK ; /* We have a usable PGDATA value */
375
- char hostbuf [MAXHOSTNAMELEN ];
376
- int nonblank_argc ;
377
365
char original_extraoptions [MAXPGPATH ];
378
366
379
367
* original_extraoptions = '\0' ;
380
368
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
-
414
369
progname = argv [0 ];
415
370
real_argv = argv ;
416
371
real_argc = argc ;
417
372
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
-
426
373
/*
427
374
* for security, no dir or file created can be group or other
428
375
* accessible
@@ -431,13 +378,6 @@ PostmasterMain(int argc, char *argv[])
431
378
432
379
ResetAllOptions ();
433
380
434
- if (!(hostName = getenv ("PGHOST" )))
435
- {
436
- if (gethostname (hostbuf , MAXHOSTNAMELEN ) < 0 )
437
- strcpy (hostbuf , "localhost" );
438
- hostName = hostbuf ;
439
- }
440
-
441
381
MyProcPid = getpid ();
442
382
DataDir = getenv ("PGDATA" ); /* default value */
443
383
@@ -455,7 +395,7 @@ PostmasterMain(int argc, char *argv[])
455
395
* will occur.
456
396
*/
457
397
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 )
459
399
{
460
400
if (opt == 'D' )
461
401
DataDir = optarg ;
@@ -472,7 +412,7 @@ PostmasterMain(int argc, char *argv[])
472
412
ProcessConfigFile (PGC_POSTMASTER );
473
413
474
414
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 )
476
416
{
477
417
switch (opt )
478
418
{
@@ -496,15 +436,7 @@ PostmasterMain(int argc, char *argv[])
496
436
NBuffers = atoi (optarg );
497
437
break ;
498
438
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. */
508
440
break ;
509
441
case 'D' :
510
442
/* already done above */
@@ -630,13 +562,6 @@ PostmasterMain(int argc, char *argv[])
630
562
exit (1 );
631
563
}
632
564
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
-
640
565
#ifdef USE_SSL
641
566
if (!NetServer && SecureNetServer )
642
567
{
@@ -649,7 +574,7 @@ PostmasterMain(int argc, char *argv[])
649
574
650
575
if (NetServer )
651
576
{
652
- status = StreamServerPort (hostName , (unsigned short )PostPortName , & ServerSock_INET );
577
+ status = StreamServerPort (AF_INET , (unsigned short )PostPortName , & ServerSock_INET );
653
578
if (status != STATUS_OK )
654
579
{
655
580
fprintf (stderr , "%s: cannot create INET stream port\n" ,
@@ -659,7 +584,7 @@ PostmasterMain(int argc, char *argv[])
659
584
}
660
585
661
586
#if !defined(__CYGWIN32__ ) && !defined(__QNX__ )
662
- status = StreamServerPort (NULL , (unsigned short )PostPortName , & ServerSock_UNIX );
587
+ status = StreamServerPort (AF_UNIX , (unsigned short )PostPortName , & ServerSock_UNIX );
663
588
if (status != STATUS_OK )
664
589
{
665
590
fprintf (stderr , "%s: cannot create UNIX stream port\n" ,
@@ -696,7 +621,6 @@ PostmasterMain(int argc, char *argv[])
696
621
assert_enabled , /* whether -A is specified
697
622
* or not */
698
623
NBuffers , /* -B: number of shared buffers */
699
- Execfile , /* -b: postgres executable file */
700
624
DebugLvl , /* -d: debug level */
701
625
NetServer , /* -i: accept connection from INET */
702
626
#ifdef USE_SSL
@@ -785,7 +709,6 @@ pmdaemonize(char *extraoptions)
785
709
assert_enabled , /* whether -A is specified
786
710
* or not */
787
711
NBuffers , /* -B: number of shared buffers */
788
- Execfile , /* -b: postgres executable file */
789
712
DebugLvl , /* -d: debug level */
790
713
NetServer , /* -i: accept connection from INET */
791
714
#ifdef USE_SSL
@@ -1905,7 +1828,6 @@ DoBackend(Port *port)
1905
1828
{
1906
1829
char * av [ARGV_SIZE * 2 ];
1907
1830
int ac = 0 ;
1908
- char execbuf [MAXPGPATH ];
1909
1831
char debugbuf [ARGV_SIZE ];
1910
1832
char protobuf [ARGV_SIZE ];
1911
1833
char dbbuf [ARGV_SIZE ];
@@ -1958,26 +1880,7 @@ DoBackend(Port *port)
1958
1880
* ----------------
1959
1881
*/
1960
1882
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" ;
1981
1884
1982
1885
/*
1983
1886
* Pass the requested debugging level along to the backend. Level one
@@ -2229,7 +2132,6 @@ SSDataBase(bool startup)
2229
2132
{
2230
2133
char * av [ARGV_SIZE * 2 ];
2231
2134
int ac = 0 ;
2232
- char execbuf [MAXPGPATH ];
2233
2135
char nbbuf [ARGV_SIZE ];
2234
2136
char dbbuf [ARGV_SIZE ];
2235
2137
@@ -2244,8 +2146,7 @@ SSDataBase(bool startup)
2244
2146
ServerSock_UNIX = INVALID_SOCK ;
2245
2147
#endif
2246
2148
2247
- StrNCpy (execbuf , Execfile , MAXPGPATH );
2248
- av [ac ++ ] = execbuf ;
2149
+ av [ac ++ ] = "postgres" ;
2249
2150
2250
2151
av [ac ++ ] = "-d" ;
2251
2152
@@ -2294,7 +2195,7 @@ SSDataBase(bool startup)
2294
2195
*/
2295
2196
static int
2296
2197
SetOptsFile (char * progname , int port , char * datadir ,
2297
- int assert , int nbuf , char * execfile ,
2198
+ int assert , int nbuf ,
2298
2199
int debuglvl , int netserver ,
2299
2200
#ifdef USE_SSL
2300
2201
int securenetserver ,
@@ -2324,7 +2225,7 @@ SetOptsFile(char *progname, int port, char *datadir,
2324
2225
strcat (opts , buf );
2325
2226
}
2326
2227
2327
- snprintf (buf , sizeof (buf ), "-B %d\n-b %s\n " , nbuf , execfile );
2228
+ snprintf (buf , sizeof (buf ), "-B %d\n" , nbuf );
2328
2229
strcat (opts , buf );
2329
2230
2330
2231
if (debuglvl )
0 commit comments