Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
6be6a185
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,发现更多精彩内容 >>
提交
6be6a185
编写于
11月 03, 2000
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor code cleanups, make in_group() check faster.
上级
aceec9ae
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
42 deletion
+44
-42
src/backend/catalog/aclchk.c
src/backend/catalog/aclchk.c
+44
-42
未找到文件。
src/backend/catalog/aclchk.c
浏览文件 @
6be6a185
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.4
1 2000/10/02 04:49:2
8 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.4
2 2000/11/03 19:02:1
8 tgl Exp $
*
* NOTES
* See acl.h.
...
...
@@ -185,41 +185,40 @@ get_groname(AclId grosysid)
static
bool
in_group
(
AclId
uid
,
AclId
gid
)
{
Relation
relation
;
HeapTuple
tuple
;
Acl
*
tmp
;
Datum
att
;
bool
isNull
;
IdList
*
tmp
;
AclId
*
aidp
;
int
i
,
num
;
AclId
*
aidp
;
bool
found
=
false
;
relation
=
heap_openr
(
GroupRelationName
,
RowExclusiveLock
);
tuple
=
SearchSysCacheTuple
(
GROSYSID
,
ObjectIdGetDatum
(
gid
),
0
,
0
,
0
);
if
(
HeapTupleIsValid
(
tuple
)
&&
!
heap_attisnull
(
tuple
,
Anum_pg_group_grolist
))
if
(
HeapTupleIsValid
(
tuple
))
{
tmp
=
(
IdList
*
)
heap_getattr
(
tuple
,
Anum_pg_group_grolist
,
RelationGetDescr
(
relation
),
(
bool
*
)
NULL
);
/* be sure the IdList is not toasted */
tmp
=
DatumGetIdListP
(
PointerGetDatum
(
tmp
));
/* XXX make me a function */
num
=
IDLIST_NUM
(
tmp
);
aidp
=
IDLIST_DAT
(
tmp
);
for
(
i
=
0
;
i
<
num
;
++
i
)
if
(
aidp
[
i
]
==
uid
)
att
=
SysCacheGetAttr
(
GROSYSID
,
tuple
,
Anum_pg_group_grolist
,
&
isNull
);
if
(
!
isNull
)
{
/* be sure the IdList is not toasted */
tmp
=
DatumGetIdListP
(
att
);
/* scan it */
num
=
IDLIST_NUM
(
tmp
);
aidp
=
IDLIST_DAT
(
tmp
);
for
(
i
=
0
;
i
<
num
;
++
i
)
{
found
=
true
;
break
;
if
(
aidp
[
i
]
==
uid
)
return
true
;
}
}
}
else
elog
(
NOTICE
,
"in_group: group %d not found"
,
gid
);
heap_close
(
relation
,
RowExclusiveLock
);
return
found
;
elog
(
NOTICE
,
"in_group: group %u not found"
,
gid
);
return
false
;
}
/*
...
...
@@ -230,11 +229,10 @@ in_group(AclId uid, AclId gid)
static
int32
aclcheck
(
char
*
relname
,
Acl
*
acl
,
AclId
id
,
AclIdType
idtype
,
AclMode
mode
)
{
unsigned
i
;
AclItem
*
aip
,
*
aidat
;
unsigned
num
,
found_group
;
int
i
,
num
;
/*
* If ACL is null, default to "OK" --- this should not happen,
...
...
@@ -252,17 +250,20 @@ aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
/*
* We'll treat the empty ACL like that, too, although this is more
* like an error (i.e., you manually blew away your ACL array) -- the
* system never creates an empty ACL.
* system never creates an empty ACL, since there must always be
* a "world" entry in the first slot.
*/
if
(
num
<
1
)
{
elog
(
DEBUG
,
"aclcheck: zero-length ACL, returning 1"
);
return
ACLCHECK_OK
;
}
Assert
(
aidat
->
ai_idtype
==
ACL_IDTYPE_WORLD
);
switch
(
idtype
)
{
case
ACL_IDTYPE_UID
:
/* Look for exact match to user */
for
(
i
=
1
,
aip
=
aidat
+
1
;
/* skip world entry */
i
<
num
&&
aip
->
ai_idtype
==
ACL_IDTYPE_UID
;
++
i
,
++
aip
)
...
...
@@ -270,34 +271,33 @@ aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
if
(
aip
->
ai_id
==
id
)
{
#ifdef ACLDEBUG_TRACE
elog
(
DEBUG
,
"aclcheck: found
%d
/%d"
,
elog
(
DEBUG
,
"aclcheck: found
user %u
/%d"
,
aip
->
ai_id
,
aip
->
ai_mode
);
#endif
return
(
aip
->
ai_mode
&
mode
)
?
ACLCHECK_OK
:
ACLCHECK_NO_PRIV
;
}
}
for
(
found_group
=
0
;
/* See if he has the permission via any group */
for
(;
i
<
num
&&
aip
->
ai_idtype
==
ACL_IDTYPE_GID
;
++
i
,
++
aip
)
{
if
(
in_group
(
id
,
aip
->
ai_id
)
)
if
(
aip
->
ai_mode
&
mode
)
{
if
(
aip
->
ai_mode
&
mode
)
if
(
in_group
(
id
,
aip
->
ai_id
)
)
{
found_group
=
1
;
break
;
}
}
}
if
(
found_group
)
{
#ifdef ACLDEBUG_TRACE
elog
(
DEBUG
,
"aclcheck: all groups ok"
);
elog
(
DEBUG
,
"aclcheck: found group %u/%d"
,
aip
->
ai_id
,
aip
->
ai_mode
);
#endif
return
ACLCHECK_OK
;
return
ACLCHECK_OK
;
}
}
}
/* Else, look to the world entry */
break
;
case
ACL_IDTYPE_GID
:
/* Look for this group ID */
for
(
i
=
1
,
aip
=
aidat
+
1
;
/* skip world entry and
* UIDs */
i
<
num
&&
aip
->
ai_idtype
==
ACL_IDTYPE_UID
;
...
...
@@ -310,14 +310,16 @@ aclcheck(char *relname, Acl *acl, AclId id, AclIdType idtype, AclMode mode)
if
(
aip
->
ai_id
==
id
)
{
#ifdef ACLDEBUG_TRACE
elog
(
DEBUG
,
"aclcheck: found
%d
/%d"
,
elog
(
DEBUG
,
"aclcheck: found
group %u
/%d"
,
aip
->
ai_id
,
aip
->
ai_mode
);
#endif
return
(
aip
->
ai_mode
&
mode
)
?
ACLCHECK_OK
:
ACLCHECK_NO_PRIV
;
}
}
/* Else, look to the world entry */
break
;
case
ACL_IDTYPE_WORLD
:
/* Only check the world entry */
break
;
default:
elog
(
ERROR
,
"aclcheck: bogus ACL id type: %d"
,
idtype
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录