Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
aff700a1
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,发现更多精彩内容 >>
提交
aff700a1
编写于
8月 11, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid crashing when restoring a saved GUC session_authorization value
that refers to a now-deleted userid. Per gripe from Chris Ochs.
上级
f79fbb2b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
17 deletion
+37
-17
src/backend/commands/variable.c
src/backend/commands/variable.c
+34
-15
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+3
-2
未找到文件。
src/backend/commands/variable.c
浏览文件 @
aff700a1
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.9
8 2004/07/01 00:50:12
tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/variable.c,v 1.9
9 2004/08/11 21:10:36
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -591,31 +591,37 @@ assign_client_encoding(const char *value, bool doit, GucSource source)
* lookups. Hence, the stored form of the value must provide a numeric userid
* that can be re-used directly. We store the string in the form of
* NAMEDATALEN 'x's, followed by T or F to indicate superuserness, followed
* by the numeric userid --- this cannot conflict with any valid user name,
* because of the NAMEDATALEN limit on names.
* by the numeric userid, followed by a comma, followed by the user name.
* This cannot be confused with a plain user name because of the NAMEDATALEN
* limit on names, so we can tell whether we're being passed an initial
* username or a saved/restored value.
*/
extern
char
*
session_authorization_string
;
/* in guc.c */
const
char
*
assign_session_authorization
(
const
char
*
value
,
bool
doit
,
GucSource
source
)
{
AclId
usesysid
=
0
;
bool
is_superuser
=
false
;
const
char
*
actual_username
=
NULL
;
char
*
result
;
if
(
strspn
(
value
,
"x"
)
==
NAMEDATALEN
&&
(
value
[
NAMEDATALEN
]
==
'T'
||
value
[
NAMEDATALEN
]
==
'F'
))
{
/* might be a saved numeric userid */
/* might be a saved userid string */
AclId
savedsysid
;
char
*
endptr
;
use
sysid
=
(
AclId
)
strtoul
(
value
+
NAMEDATALEN
+
1
,
&
endptr
,
10
);
saved
sysid
=
(
AclId
)
strtoul
(
value
+
NAMEDATALEN
+
1
,
&
endptr
,
10
);
if
(
endptr
!=
value
+
NAMEDATALEN
+
1
&&
*
endptr
==
'
\0
'
)
if
(
endptr
!=
value
+
NAMEDATALEN
+
1
&&
*
endptr
==
'
,
'
)
{
/* syntactically valid, so use the numeric user ID and flag */
/* syntactically valid, so break out the data */
usesysid
=
savedsysid
;
is_superuser
=
(
value
[
NAMEDATALEN
]
==
'T'
);
actual_username
=
endptr
+
1
;
}
else
usesysid
=
0
;
}
if
(
usesysid
==
0
)
...
...
@@ -647,6 +653,7 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
usesysid
=
((
Form_pg_shadow
)
GETSTRUCT
(
userTup
))
->
usesysid
;
is_superuser
=
((
Form_pg_shadow
)
GETSTRUCT
(
userTup
))
->
usesuper
;
actual_username
=
value
;
ReleaseSysCache
(
userTup
);
}
...
...
@@ -654,15 +661,16 @@ assign_session_authorization(const char *value, bool doit, GucSource source)
if
(
doit
)
SetSessionAuthorization
(
usesysid
,
is_superuser
);
result
=
(
char
*
)
malloc
(
NAMEDATALEN
+
32
);
result
=
(
char
*
)
malloc
(
NAMEDATALEN
+
32
+
strlen
(
actual_username
)
);
if
(
!
result
)
return
NULL
;
memset
(
result
,
'x'
,
NAMEDATALEN
);
snprintf
(
result
+
NAMEDATALEN
,
32
,
"%c%lu"
,
is_superuser
?
'T'
:
'F'
,
(
unsigned
long
)
usesysid
);
sprintf
(
result
+
NAMEDATALEN
,
"%c%lu,%s"
,
is_superuser
?
'T'
:
'F'
,
(
unsigned
long
)
usesysid
,
actual_username
);
return
result
;
}
...
...
@@ -671,8 +679,19 @@ const char *
show_session_authorization
(
void
)
{
/*
*
We can't use the stored string; see comments for
*
Extract the user name from the stored string; see
* assign_session_authorization
*/
return
GetUserNameFromId
(
GetSessionUserId
());
const
char
*
value
=
session_authorization_string
;
AclId
savedsysid
;
char
*
endptr
;
Assert
(
strspn
(
value
,
"x"
)
==
NAMEDATALEN
&&
(
value
[
NAMEDATALEN
]
==
'T'
||
value
[
NAMEDATALEN
]
==
'F'
));
savedsysid
=
(
AclId
)
strtoul
(
value
+
NAMEDATALEN
+
1
,
&
endptr
,
10
);
Assert
(
endptr
!=
value
+
NAMEDATALEN
+
1
&&
*
endptr
==
','
);
return
endptr
+
1
;
}
src/backend/utils/misc/guc.c
浏览文件 @
aff700a1
...
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.23
0 2004/08/08 20:17:36
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.23
1 2004/08/11 21:10:37
tgl Exp $
*
*--------------------------------------------------------------------
*/
...
...
@@ -175,7 +175,6 @@ static char *locale_ctype;
static
char
*
regex_flavor_string
;
static
char
*
server_encoding_string
;
static
char
*
server_version_string
;
static
char
*
session_authorization_string
;
static
char
*
timezone_string
;
static
char
*
XactIsoLevel_string
;
static
char
*
custom_variable_classes
;
...
...
@@ -184,6 +183,8 @@ static int max_index_keys;
static
int
max_identifier_length
;
static
int
block_size
;
static
bool
integer_datetimes
;
/* should be static, but commands/variable.c needs to get at it */
char
*
session_authorization_string
;
/*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录