1 /*-------------------------------------------------------------------------
4 * Stub main() routine for the postgres backend.
6 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.34 2000/11/16 05:51:00 momjian Exp $
13 *-------------------------------------------------------------------------
20 #if defined(__alpha) && !defined(linux) && !defined(__FreeBSD__)
21 #include <sys/sysinfo.h>
22 #include "machine/hal_sysinfo.h"
31 #include "miscadmin.h"
32 #include "bootstrap/bootstrap.h"
33 #include "tcop/tcopprot.h"
36 \n\"root\" execution of the PostgreSQL backend is not permitted.\n\n\
37 The backend must be started under its own userid to prevent\n\
38 a possible system security compromise. See the INSTALL file for\n\
39 more information on how to properly start the postmaster.\n\n"
42 main(int argc, char *argv[])
48 int buffer[] = {SSIN_UACPROC, UAC_SIGBUS};
52 int buffer[] = {SSIN_UACPROC, UAC_NOPRINT};
54 #endif /* NOPRINTADE */
58 setlocale(LC_CTYPE, ""); /* take locale information from an
60 setlocale(LC_COLLATE, "");
61 setlocale(LC_MONETARY, "");
63 #if defined(NOFIXADE) || defined(NOPRINTADE)
66 * Must be first so that the bootstrap code calls it, too. (Only
67 * needed on some RISC architectures.)
71 syscall(SYS_sysmips, MIPS_FIXADE, 0, NULL, NULL, NULL);
75 if (setsysinfo(SSI_NVPAIRS, buffer, 1, (caddr_t) NULL,
76 (unsigned long) NULL) < 0)
77 elog(NOTICE, "setsysinfo failed: %d\n", errno);
80 #endif /* NOFIXADE || NOPRINTADE */
83 * use one executable for both postgres and postmaster, invoke one or
84 * the other depending on the name of the executable
86 len = strlen(argv[0]);
88 /* OK this is going to seem weird, but BeOS is presently basically
89 * a single user system. There is work going on, but at present it'll
90 * say that every user is uid 0, i.e. root. We'll inhibit this check
91 * until Be get the system working with multiple users!!
96 fprintf(stderr, "%s", NOROOTEXEC);
102 /* Specific beos actions on startup */
103 beos_startup(argc,argv);
107 if (len >= 10 && !strcmp(argv[0] + len - 10, "postmaster"))
108 exit(PostmasterMain(argc, argv));
111 * if the first argument is "-boot", then invoke the backend in
114 if (argc > 1 && strcmp(argv[1], "-boot") == 0)
115 exit(BootstrapMain(argc - 1, argv + 1)); /* remove the -boot arg
116 * from the command line */
121 pw = getpwuid(geteuid());
124 fprintf(stderr, "%s: invalid current euid", argv[0]);
127 exit(PostgresMain(argc, argv, argc, argv, pw->pw_name));