Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
9d220fc1
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,发现更多精彩内容 >>
提交
9d220fc1
编写于
2月 02, 2011
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify pg_upgrade checking of executable permissions.
上级
0c5933d0
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
25 addition
and
48 deletion
+25
-48
contrib/pg_upgrade/exec.c
contrib/pg_upgrade/exec.c
+25
-48
未找到文件。
contrib/pg_upgrade/exec.c
浏览文件 @
9d220fc1
...
...
@@ -15,8 +15,7 @@
static
void
check_data_dir
(
const
char
*
pg_data
);
static
void
check_bin_dir
(
ClusterInfo
*
cluster
);
static
int
check_exec
(
const
char
*
dir
,
const
char
*
cmdName
);
static
const
char
*
validate_exec
(
const
char
*
path
);
static
void
validate_exec
(
const
char
*
dir
,
const
char
*
cmdName
);
/*
...
...
@@ -160,58 +159,32 @@ check_data_dir(const char *pg_data)
static
void
check_bin_dir
(
ClusterInfo
*
cluster
)
{
check
_exec
(
cluster
->
bindir
,
"postgres"
);
check
_exec
(
cluster
->
bindir
,
"pg_ctl"
);
check
_exec
(
cluster
->
bindir
,
"pg_resetxlog"
);
validate
_exec
(
cluster
->
bindir
,
"postgres"
);
validate
_exec
(
cluster
->
bindir
,
"pg_ctl"
);
validate
_exec
(
cluster
->
bindir
,
"pg_resetxlog"
);
if
(
cluster
==
&
new_cluster
)
{
/* these are only needed in the new cluster */
check
_exec
(
cluster
->
bindir
,
"pg_config"
);
check
_exec
(
cluster
->
bindir
,
"psql"
);
check
_exec
(
cluster
->
bindir
,
"pg_dumpall"
);
validate
_exec
(
cluster
->
bindir
,
"pg_config"
);
validate
_exec
(
cluster
->
bindir
,
"psql"
);
validate
_exec
(
cluster
->
bindir
,
"pg_dumpall"
);
}
}
/*
* check_exec()
*
* Checks whether either of the two command names (cmdName and alternative)
* appears to be an executable (in the given directory). If dir/cmdName is
* an executable, this function returns 1. If dir/alternative is an
* executable, this function returns 2. If neither of the given names is
* a valid executable, this function returns 0 to indicated failure.
*/
static
int
check_exec
(
const
char
*
dir
,
const
char
*
cmdName
)
{
char
path
[
MAXPGPATH
];
const
char
*
errMsg
;
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
dir
,
cmdName
);
if
((
errMsg
=
validate_exec
(
path
))
==
NULL
)
return
1
;
/* 1 -> first alternative OK */
else
pg_log
(
PG_FATAL
,
"check for %s failed - %s
\n
"
,
cmdName
,
errMsg
);
return
0
;
/* 0 -> neither alternative is acceptable */
}
/*
* validate_exec()
*
* validate "path" as an executable file
* returns 0 if the file is found and no error is encountered.
* -1 if the regular file "path" does not exist or cannot be executed.
* -2 if the file is otherwise valid but cannot be read.
*/
static
const
char
*
validate_exec
(
const
char
*
path
)
static
void
validate_exec
(
const
char
*
dir
,
const
char
*
cmdName
)
{
char
path
[
MAXPGPATH
];
struct
stat
buf
;
snprintf
(
path
,
sizeof
(
path
),
"%s/%s"
,
dir
,
cmdName
);
#ifdef WIN32
/* Win32 requires a .exe suffix for stat() */
char
path_exe
[
MAXPGPATH
+
sizeof
(
EXE_EXT
)
-
1
];
...
...
@@ -229,10 +202,12 @@ validate_exec(const char *path)
* Ensure that the file exists and is a regular file.
*/
if
(
stat
(
path
,
&
buf
)
<
0
)
return
getErrorText
(
errno
);
pg_log
(
PG_FATAL
,
"check for %s failed - %s
\n
"
,
cmdName
,
getErrorText
(
errno
));
if
(
!
S_ISREG
(
buf
.
st_mode
))
return
"not an executable file"
;
pg_log
(
PG_FATAL
,
"check for %s failed - not an executable file
\n
"
,
cmdName
);
/*
* Ensure that the file is both executable and readable (required for
...
...
@@ -240,15 +215,17 @@ validate_exec(const char *path)
*/
#ifndef WIN32
if
(
access
(
path
,
R_OK
)
!=
0
)
return
"can't read file (permission denied)"
;
if
(
access
(
path
,
X_OK
)
!=
0
)
return
"can't execute (permission denied)"
;
return
NULL
;
#else
if
((
buf
.
st_mode
&
S_IRUSR
)
==
0
)
return
"can't read file (permission denied)"
;
#endif
pg_log
(
PG_FATAL
,
"check for %s failed - cannot read file (permission denied)
\n
"
,
cmdName
);
#ifndef WIN32
if
(
access
(
path
,
X_OK
)
!=
0
)
#else
if
((
buf
.
st_mode
&
S_IXUSR
)
==
0
)
return
"can't execute (permission denied)"
;
return
NULL
;
#endif
pg_log
(
PG_FATAL
,
"check for %s failed - cannot execute (permission denied)
\n
"
,
cmdName
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录