Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
53691902
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,发现更多精彩内容 >>
提交
53691902
编写于
6月 02, 2003
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the world at least marginally safe for usernames with embedded spaces.
Per recent gripe.
上级
cb36e74e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
54 deletion
+68
-54
src/backend/utils/adt/acl.c
src/backend/utils/adt/acl.c
+64
-50
src/bin/initdb/initdb.sh
src/bin/initdb/initdb.sh
+4
-4
未找到文件。
src/backend/utils/adt/acl.c
浏览文件 @
53691902
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.8
6 2003/01/24 21:53
:29 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.8
7 2003/06/02 19:00
:29 tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#define ACL_IDTYPE_UID_KEYWORD "user"
#define ACL_IDTYPE_UID_KEYWORD "user"
static
const
char
*
getid
(
const
char
*
s
,
char
*
n
);
static
const
char
*
getid
(
const
char
*
s
,
char
*
n
);
static
void
putid
(
char
*
p
,
const
char
*
s
);
static
Acl
*
makeacl
(
int
n
);
static
Acl
*
makeacl
(
int
n
);
static
const
char
*
aclparse
(
const
char
*
s
,
AclItem
*
aip
);
static
const
char
*
aclparse
(
const
char
*
s
,
AclItem
*
aip
);
static
bool
aclitemeq
(
const
AclItem
*
a1
,
const
AclItem
*
a2
);
static
bool
aclitemeq
(
const
AclItem
*
a1
,
const
AclItem
*
a2
);
...
@@ -64,42 +65,68 @@ static AclMode convert_schema_priv_string(text *priv_type_text);
...
@@ -64,42 +65,68 @@ static AclMode convert_schema_priv_string(text *priv_type_text);
static
const
char
*
static
const
char
*
getid
(
const
char
*
s
,
char
*
n
)
getid
(
const
char
*
s
,
char
*
n
)
{
{
unsigned
len
;
int
len
=
0
;
const
char
*
id
;
bool
in_quotes
=
false
;
int
in_quotes
=
0
;
Assert
(
s
&&
n
);
Assert
(
s
&&
n
);
while
(
isspace
((
unsigned
char
)
*
s
))
while
(
isspace
((
unsigned
char
)
*
s
))
++
s
;
if
(
*
s
==
'"'
)
{
in_quotes
=
1
;
s
++
;
s
++
;
}
/* This test had better match what putid() does, below */
for
(;
for
(
id
=
s
,
len
=
0
;
*
s
!=
'\0'
&&
isalnum
((
unsigned
char
)
*
s
)
||
*
s
==
'_'
||
in_quotes
;
(
isalnum
((
unsigned
char
)
*
s
)
||
++
len
,
++
s
)
*
s
==
'_'
||
*
s
==
'"'
||
in_quotes
);
s
++
)
{
{
if
(
in_quotes
&&
*
s
==
'"'
)
if
(
*
s
==
'"'
)
{
{
len
--
;
in_quotes
=
!
in_quotes
;
in_quotes
=
0
;
}
else
{
if
(
len
>=
NAMEDATALEN
-
1
)
elog
(
ERROR
,
"identifier must be less than %d characters"
,
NAMEDATALEN
);
n
[
len
++
]
=
*
s
;
}
}
}
}
if
(
len
>=
NAMEDATALEN
)
elog
(
ERROR
,
"getid: identifier must be <%d characters"
,
NAMEDATALEN
);
if
(
len
>
0
)
memmove
(
n
,
id
,
len
);
n
[
len
]
=
'\0'
;
n
[
len
]
=
'\0'
;
while
(
isspace
((
unsigned
char
)
*
s
))
while
(
isspace
((
unsigned
char
)
*
s
))
++
s
;
s
++
;
return
s
;
return
s
;
}
}
/*
* Write a user or group Name at *p, surrounding it with double quotes if
* needed. There must be at least NAMEDATALEN+2 bytes available at *p.
*/
static
void
putid
(
char
*
p
,
const
char
*
s
)
{
const
char
*
src
;
bool
safe
=
true
;
for
(
src
=
s
;
*
src
;
src
++
)
{
/* This test had better match what getid() does, above */
if
(
!
isalnum
((
unsigned
char
)
*
src
)
&&
*
src
!=
'_'
)
{
safe
=
false
;
break
;
}
}
if
(
!
safe
)
*
p
++
=
'"'
;
for
(
src
=
s
;
*
src
;
src
++
)
*
p
++
=
*
src
;
if
(
!
safe
)
*
p
++
=
'"'
;
*
p
=
'\0'
;
}
/*
/*
* aclparse
* aclparse
* Consumes and parses an ACL specification of the form:
* Consumes and parses an ACL specification of the form:
...
@@ -304,7 +331,12 @@ aclitemout(PG_FUNCTION_ARGS)
...
@@ -304,7 +331,12 @@ aclitemout(PG_FUNCTION_ARGS)
unsigned
i
;
unsigned
i
;
char
*
tmpname
;
char
*
tmpname
;
p
=
out
=
palloc
(
strlen
(
"group = "
)
+
2
*
N_ACL_RIGHTS
+
2
*
NAMEDATALEN
+
2
);
out
=
palloc
(
strlen
(
"group =/"
)
+
2
*
N_ACL_RIGHTS
+
2
*
(
NAMEDATALEN
+
2
)
+
1
);
p
=
out
;
*
p
=
'\0'
;
*
p
=
'\0'
;
switch
(
ACLITEM_GET_IDTYPE
(
*
aip
))
switch
(
ACLITEM_GET_IDTYPE
(
*
aip
))
...
@@ -315,36 +347,25 @@ aclitemout(PG_FUNCTION_ARGS)
...
@@ -315,36 +347,25 @@ aclitemout(PG_FUNCTION_ARGS)
0
,
0
,
0
);
0
,
0
,
0
);
if
(
HeapTupleIsValid
(
htup
))
if
(
HeapTupleIsValid
(
htup
))
{
{
strncat
(
p
,
putid
(
p
,
NameStr
(((
Form_pg_shadow
)
GETSTRUCT
(
htup
))
->
usename
));
NameStr
(((
Form_pg_shadow
)
GETSTRUCT
(
htup
))
->
usename
),
NAMEDATALEN
);
ReleaseSysCache
(
htup
);
ReleaseSysCache
(
htup
);
}
}
else
else
{
{
/* Generate numeric UID if we don't find an entry */
/* Generate numeric UID if we don't find an entry */
char
*
tmp
;
sprintf
(
p
,
"%d"
,
aip
->
ai_grantee
);
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
int4out
,
Int32GetDatum
((
int32
)
aip
->
ai_grantee
)));
strcat
(
p
,
tmp
);
pfree
(
tmp
);
}
}
break
;
break
;
case
ACL_IDTYPE_GID
:
case
ACL_IDTYPE_GID
:
strcat
(
p
,
"group "
);
strcpy
(
p
,
"group "
);
p
+=
strlen
(
p
);
tmpname
=
get_groname
(
aip
->
ai_grantee
);
tmpname
=
get_groname
(
aip
->
ai_grantee
);
if
(
tmpname
!=
NULL
)
if
(
tmpname
!=
NULL
)
strncat
(
p
,
tmpname
,
NAMEDATALEN
);
putid
(
p
,
tmpname
);
else
else
{
{
/* Generate numeric GID if we don't find an entry */
/* Generate numeric GID if we don't find an entry */
char
*
tmp
;
sprintf
(
p
,
"%d"
,
aip
->
ai_grantee
);
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
int4out
,
Int32GetDatum
((
int32
)
aip
->
ai_grantee
)));
strcat
(
p
,
tmp
);
pfree
(
tmp
);
}
}
break
;
break
;
case
ACL_IDTYPE_WORLD
:
case
ACL_IDTYPE_WORLD
:
...
@@ -375,20 +396,13 @@ aclitemout(PG_FUNCTION_ARGS)
...
@@ -375,20 +396,13 @@ aclitemout(PG_FUNCTION_ARGS)
0
,
0
,
0
);
0
,
0
,
0
);
if
(
HeapTupleIsValid
(
htup
))
if
(
HeapTupleIsValid
(
htup
))
{
{
strncat
(
p
,
putid
(
p
,
NameStr
(((
Form_pg_shadow
)
GETSTRUCT
(
htup
))
->
usename
));
NameStr
(((
Form_pg_shadow
)
GETSTRUCT
(
htup
))
->
usename
),
NAMEDATALEN
);
ReleaseSysCache
(
htup
);
ReleaseSysCache
(
htup
);
}
}
else
else
{
{
/* Generate numeric UID if we don't find an entry */
/* Generate numeric UID if we don't find an entry */
char
*
tmp
;
sprintf
(
p
,
"%d"
,
aip
->
ai_grantor
);
tmp
=
DatumGetCString
(
DirectFunctionCall1
(
int4out
,
Int32GetDatum
((
int32
)
aip
->
ai_grantor
)));
strcat
(
p
,
tmp
);
pfree
(
tmp
);
}
}
while
(
*
p
)
while
(
*
p
)
...
...
src/bin/initdb/initdb.sh
浏览文件 @
53691902
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
# Portions Copyright (c) 1994, Regents of the University of California
#
#
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.19
1 2003/05/28 18:19:0
9 tgl Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.19
2 2003/06/02 19:00:2
9 tgl Exp $
#
#
#-------------------------------------------------------------------------
#-------------------------------------------------------------------------
...
@@ -1021,11 +1021,11 @@ echo "ok"
...
@@ -1021,11 +1021,11 @@ echo "ok"
$ECHO_N
"setting privileges on built-in objects... "
$ECHO_C
$ECHO_N
"setting privileges on built-in objects... "
$ECHO_C
(
(
cat
<<
EOF
cat
<<
EOF
UPDATE pg_class SET relacl = '{"=r/
$POSTGRES_SUPERUSERNAME
"}'
\
UPDATE pg_class SET relacl = '{"=r/
\\\\
"
$POSTGRES_SUPERUSERNAME
\\\\
"
"}'
\
WHERE relkind IN ('r', 'v', 'S') AND relacl IS NULL;
WHERE relkind IN ('r', 'v', 'S') AND relacl IS NULL;
UPDATE pg_proc SET proacl = '{"=X/
$POSTGRES_SUPERUSERNAME
"}'
\
UPDATE pg_proc SET proacl = '{"=X/
\\\\
"
$POSTGRES_SUPERUSERNAME
\\\\
"
"}'
\
WHERE proacl IS NULL;
WHERE proacl IS NULL;
UPDATE pg_language SET lanacl = '{"=U/
$POSTGRES_SUPERUSERNAME
"}'
\
UPDATE pg_language SET lanacl = '{"=U/
\\\\
"
$POSTGRES_SUPERUSERNAME
\\\\
"
"}'
\
WHERE lanpltrusted;
WHERE lanpltrusted;
GRANT USAGE ON SCHEMA pg_catalog TO PUBLIC;
GRANT USAGE ON SCHEMA pg_catalog TO PUBLIC;
GRANT CREATE, USAGE ON SCHEMA public TO PUBLIC;
GRANT CREATE, USAGE ON SCHEMA public TO PUBLIC;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录