Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
7a161ac3
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7a161ac3
编写于
11月 25, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up comments, organize code snippets added at different times into
a slightly less random order.
上级
249fe81c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
79 addition
and
48 deletion
+79
-48
src/backend/main/main.c
src/backend/main/main.c
+79
-48
未找到文件。
src/backend/main/main.c
浏览文件 @
7a161ac3
/*-------------------------------------------------------------------------
/*-------------------------------------------------------------------------
*
*
* main.c
* main.c
* Stub main() routine for the postgres backend.
* Stub main() routine for the postgres executable.
*
* This does some essential startup tasks for any incarnation of postgres
* (postmaster, standalone backend, or standalone bootstrap mode) and then
* dispatches to the proper FooMain() routine for the incarnation.
*
*
*
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.3
4 2000/11/16 05:51:00 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.3
5 2000/11/25 03:45:47 tgl
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -16,6 +21,9 @@
...
@@ -16,6 +21,9 @@
#include <pwd.h>
#include <pwd.h>
#include <unistd.h>
#include <unistd.h>
#ifdef USE_LOCALE
#include <locale.h>
#endif
#if defined(__alpha) && !defined(linux) && !defined(__FreeBSD__)
#if defined(__alpha) && !defined(linux) && !defined(__FreeBSD__)
#include <sys/sysinfo.h>
#include <sys/sysinfo.h>
...
@@ -25,23 +33,35 @@
...
@@ -25,23 +33,35 @@
#undef ASSEMBLER
#undef ASSEMBLER
#endif
#endif
#ifdef USE_LOCALE
#include <locale.h>
#endif
#include "miscadmin.h"
#include "miscadmin.h"
#include "bootstrap/bootstrap.h"
#include "bootstrap/bootstrap.h"
#include "tcop/tcopprot.h"
#include "tcop/tcopprot.h"
#define NOROOTEXEC "\
#define NOROOTEXEC "\
\n\"root\" execution of the PostgreSQL
backend
is not permitted.\n\n\
\n\"root\" execution of the PostgreSQL
server
is not permitted.\n\n\
The
backend must be started under its own
userid to prevent\n\
The
server must be started under an unprivileged
userid to prevent\n\
a possible system security compromise. See the INSTALL file for\n\
a possible system security compromise. See the INSTALL file for\n\
more information on how to properly start the postmaster.\n\n"
more information on how to properly start the server.\n\n"
int
int
main
(
int
argc
,
char
*
argv
[])
main
(
int
argc
,
char
*
argv
[])
{
{
int
len
;
int
len
;
struct
passwd
*
pw
;
/*
* Place platform-specific startup hacks here. This is the right
* place to put code that must be executed early in launch of either
* a postmaster, a standalone backend, or a standalone bootstrap run.
* Note that this code will NOT be executed when a backend or
* sub-bootstrap run is forked by the postmaster.
*
* XXX The need for code here is proof that the platform in question
* is too brain-dead to provide a standard C execution environment
* without help. Avoid adding more here, if you can.
*/
#if defined(__alpha)
#if defined(__alpha)
#ifdef NOFIXADE
#ifdef NOFIXADE
...
@@ -52,21 +72,10 @@ main(int argc, char *argv[])
...
@@ -52,21 +72,10 @@ main(int argc, char *argv[])
int
buffer
[]
=
{
SSIN_UACPROC
,
UAC_NOPRINT
};
int
buffer
[]
=
{
SSIN_UACPROC
,
UAC_NOPRINT
};
#endif
/* NOPRINTADE */
#endif
/* NOPRINTADE */
#endif
#endif
/* __alpha */
#ifdef USE_LOCALE
setlocale
(
LC_CTYPE
,
""
);
/* take locale information from an
* environment */
setlocale
(
LC_COLLATE
,
""
);
setlocale
(
LC_MONETARY
,
""
);
#endif
#if defined(NOFIXADE) || defined(NOPRINTADE)
#if defined(NOFIXADE) || defined(NOPRINTADE)
/*
* Must be first so that the bootstrap code calls it, too. (Only
* needed on some RISC architectures.)
*/
#if defined(ultrix4)
#if defined(ultrix4)
syscall
(
SYS_sysmips
,
MIPS_FIXADE
,
0
,
NULL
,
NULL
,
NULL
);
syscall
(
SYS_sysmips
,
MIPS_FIXADE
,
0
,
NULL
,
NULL
,
NULL
);
#endif
#endif
...
@@ -74,56 +83,78 @@ main(int argc, char *argv[])
...
@@ -74,56 +83,78 @@ main(int argc, char *argv[])
#if defined(__alpha)
#if defined(__alpha)
if
(
setsysinfo
(
SSI_NVPAIRS
,
buffer
,
1
,
(
caddr_t
)
NULL
,
if
(
setsysinfo
(
SSI_NVPAIRS
,
buffer
,
1
,
(
caddr_t
)
NULL
,
(
unsigned
long
)
NULL
)
<
0
)
(
unsigned
long
)
NULL
)
<
0
)
elog
(
NOTICE
,
"setsysinfo failed: %d
\n
"
,
errno
);
fprintf
(
stderr
,
"setsysinfo failed: %d
\n
"
,
errno
);
#endif
#endif
#endif
/* NOFIXADE || NOPRINTADE */
#endif
/* NOFIXADE || NOPRINTADE */
#ifdef __BEOS__
/* BeOS-specific actions on startup */
beos_startup
(
argc
,
argv
);
#endif
/*
/*
*
use one executable for both postgres and postmaster, invoke one or
*
Not-quite-so-platform-specific startup environment checks.
*
the other depending on the name of the executable
*
Still best to minimize these.
*/
*/
len
=
strlen
(
argv
[
0
]);
/* OK this is going to seem weird, but BeOS is presently basically
/*
* a single user system. There is work going on, but at present it'll
* Make sure we are not running as root.
* say that every user is uid 0, i.e. root. We'll inhibit this check
*
* until Be get the system working with multiple users!!
* BeOS currently runs everything as root :-(, so this check must
*/
* be temporarily disabled there...
*/
#ifndef __BEOS__
#ifndef __BEOS__
if
(
!
geteuid
()
)
if
(
geteuid
()
==
0
)
{
{
fprintf
(
stderr
,
"%s"
,
NOROOTEXEC
);
fprintf
(
stderr
,
"%s"
,
NOROOTEXEC
);
exit
(
1
);
exit
(
1
);
}
}
#endif
/* __BEOS__ */
#endif
/* __BEOS__ */
#ifdef __BEOS__
/*
/* Specific beos actions on startup */
* Set up locale information from environment, in only the categories
beos_startup
(
argc
,
argv
);
* needed by Postgres; leave other categories set to default "C".
* (Note that CTYPE and COLLATE will be overridden later from pg_control
* if we are in an already-initialized database. We set them here so
* that they will be available to fill pg_control during initdb.)
*/
#ifdef USE_LOCALE
setlocale
(
LC_CTYPE
,
""
);
setlocale
(
LC_COLLATE
,
""
);
setlocale
(
LC_MONETARY
,
""
);
#endif
#endif
/*
* Now dispatch to one of PostmasterMain, PostgresMain, or BootstrapMain
* depending on the program name (and possibly first argument) we
* were called with. The lack of consistency here is historical.
*/
len
=
strlen
(
argv
[
0
]);
if
(
len
>=
10
&&
!
strcmp
(
argv
[
0
]
+
len
-
10
,
"postmaster"
))
if
(
len
>=
10
&&
strcmp
(
argv
[
0
]
+
len
-
10
,
"postmaster"
)
==
0
)
{
/* Called as "postmaster" */
exit
(
PostmasterMain
(
argc
,
argv
));
exit
(
PostmasterMain
(
argc
,
argv
));
}
/*
/*
*
if the first argument is "-boot", then invoke the backend in
*
If the first argument is "-boot", then invoke bootstrap mode.
*
bootstrap mode
*
Note we remove "-boot" from the arguments passed on to BootstrapMain.
*/
*/
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"-boot"
)
==
0
)
if
(
argc
>
1
&&
strcmp
(
argv
[
1
],
"-boot"
)
==
0
)
exit
(
BootstrapMain
(
argc
-
1
,
argv
+
1
));
/* remove the -boot arg
exit
(
BootstrapMain
(
argc
-
1
,
argv
+
1
));
* from the command line */
else
/*
* Otherwise we're a standalone backend. Invoke PostgresMain,
* specifying current userid as the "authenticated" Postgres user name.
*/
pw
=
getpwuid
(
geteuid
());
if
(
pw
==
NULL
)
{
{
struct
passwd
*
pw
;
fprintf
(
stderr
,
"%s: invalid current euid"
,
argv
[
0
]);
exit
(
1
);
pw
=
getpwuid
(
geteuid
());
if
(
!
pw
)
{
fprintf
(
stderr
,
"%s: invalid current euid"
,
argv
[
0
]);
exit
(
1
);
}
exit
(
PostgresMain
(
argc
,
argv
,
argc
,
argv
,
pw
->
pw_name
));
}
}
exit
(
PostgresMain
(
argc
,
argv
,
argc
,
argv
,
pw
->
pw_name
));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录