Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
5abbfe99
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
5abbfe99
编写于
11月 05, 2018
作者:
B
BaiShaoqi
提交者:
GitHub
11月 05, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GPDB_93_MERGE_FIXME: AlterExtProtocolOwner() refactored to AlterObjectOwner_internal() (#6122)
上级
20f4dfd5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
28 addition
and
143 deletion
+28
-143
src/backend/commands/alter.c
src/backend/commands/alter.c
+28
-6
src/backend/commands/extprotocolcmds.c
src/backend/commands/extprotocolcmds.c
+0
-135
src/include/commands/extprotocolcmds.h
src/include/commands/extprotocolcmds.h
+0
-2
未找到文件。
src/backend/commands/alter.c
浏览文件 @
5abbfe99
...
...
@@ -760,12 +760,6 @@ ExecAlterOwnerStmt_internal(AlterOwnerStmt *stmt)
newowner
);
case
OBJECT_EXTPROTOCOL
:
// GPDB_93_MERGE_FIXME: this probably could be refactored to
// follow the generic case below
return
AlterExtProtocolOwner
(
strVal
(
linitial
(
stmt
->
object
)),
newowner
);
/* Generic cases */
case
OBJECT_AGGREGATE
:
case
OBJECT_COLLATION
:
case
OBJECT_CONVERSION
:
...
...
@@ -933,6 +927,34 @@ AlterObjectOwner_internal(Relation rel, Oid objectId, Oid new_ownerId)
}
}
/* MPP-14592: untrusted? don't allow ALTER OWNER to non-super user */
if
(
classId
==
ExtprotocolRelationId
)
{
char
*
old_name
;
bool
is_trusted
;
datum
=
heap_getattr
(
oldtup
,
Anum_name
,
RelationGetDescr
(
rel
),
&
isnull
);
Assert
(
!
isnull
);
old_name
=
NameStr
(
*
(
DatumGetName
(
datum
)));
datum
=
heap_getattr
(
oldtup
,
Anum_pg_extprotocol_ptctrusted
,
RelationGetDescr
(
rel
),
&
isnull
);
if
(
isnull
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"internal error: protocol
\"
%s
\"
has no trust attribute defined"
,
old_name
)));
is_trusted
=
DatumGetBool
(
datum
);
if
(
!
is_trusted
&&
!
superuser_arg
(
new_ownerId
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"untrusted protocol
\"
%s
\"
can't be owned by non superuser"
,
old_name
)));
}
/* Build a modified tuple */
nattrs
=
RelationGetNumberOfAttributes
(
rel
);
values
=
palloc0
(
nattrs
*
sizeof
(
Datum
));
...
...
src/backend/commands/extprotocolcmds.c
浏览文件 @
5abbfe99
...
...
@@ -144,138 +144,3 @@ RemoveExtProtocolById(Oid protOid)
heap_close
(
rel
,
NoLock
);
}
/*
* Change external protocol owner
*/
Oid
AlterExtProtocolOwner
(
const
char
*
name
,
Oid
newOwnerId
)
{
HeapTuple
tup
;
Relation
rel
;
ScanKeyData
scankey
;
SysScanDesc
scan
;
Oid
ptcId
;
Oid
ownerId
;
AclResult
aclresult
;
bool
isNull
;
bool
isTrusted
;
Datum
ownerDatum
;
Datum
trustedDatum
;
/*
* Check the pg_extprotocol relation to be certain the protocol
* is there.
*/
rel
=
heap_open
(
ExtprotocolRelationId
,
RowExclusiveLock
);
ScanKeyInit
(
&
scankey
,
Anum_pg_extprotocol_ptcname
,
BTEqualStrategyNumber
,
F_NAMEEQ
,
CStringGetDatum
(
name
));
scan
=
systable_beginscan
(
rel
,
ExtprotocolPtcnameIndexId
,
true
,
NULL
,
1
,
&
scankey
);
tup
=
systable_getnext
(
scan
);
if
(
!
HeapTupleIsValid
(
tup
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"protocol
\"
%s
\"
does not exist"
,
name
)));
ptcId
=
HeapTupleGetOid
(
tup
);
ownerDatum
=
heap_getattr
(
tup
,
Anum_pg_extprotocol_ptcowner
,
RelationGetDescr
(
rel
),
&
isNull
);
if
(
isNull
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"internal error: protocol
\"
%s
\"
has no owner defined"
,
name
)));
ownerId
=
DatumGetObjectId
(
ownerDatum
);
trustedDatum
=
heap_getattr
(
tup
,
Anum_pg_extprotocol_ptctrusted
,
RelationGetDescr
(
rel
),
&
isNull
);
if
(
isNull
)
ereport
(
ERROR
,
(
errcode
(
ERRCODE_UNDEFINED_OBJECT
),
errmsg
(
"internal error: protocol
\"
%s
\"
has no trust attribute defined"
,
name
)));
isTrusted
=
DatumGetBool
(
trustedDatum
);
if
(
ownerId
!=
newOwnerId
)
{
Acl
*
newAcl
;
Datum
values
[
Natts_pg_extprotocol
];
bool
nulls
[
Natts_pg_extprotocol
];
bool
replaces
[
Natts_pg_extprotocol
];
HeapTuple
newtuple
;
Datum
aclDatum
;
/* Superusers can always do it */
if
(
!
superuser
())
{
/* Must be owner */
if
(
!
pg_extprotocol_ownercheck
(
ptcId
,
GetUserId
()))
aclcheck_error
(
ACLCHECK_NOT_OWNER
,
ACL_KIND_EXTPROTOCOL
,
name
);
/* Must be able to become new owner */
check_is_member_of_role
(
GetUserId
(),
newOwnerId
);
/* New owner must have USAGE privilege on protocol */
aclresult
=
pg_extprotocol_aclcheck
(
ptcId
,
newOwnerId
,
ACL_USAGE
);
if
(
aclresult
!=
ACLCHECK_OK
)
aclcheck_error
(
aclresult
,
ACL_KIND_EXTPROTOCOL
,
name
);
}
/* MPP-14592: untrusted? don't allow ALTER OWNER to non-super user */
if
(
!
isTrusted
&&
!
superuser_arg
(
newOwnerId
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_WRONG_OBJECT_TYPE
),
errmsg
(
"untrusted protocol
\"
%s
\"
can't be owned by non superuser"
,
name
)));
MemSet
(
values
,
0
,
sizeof
(
values
));
MemSet
(
nulls
,
false
,
sizeof
(
nulls
));
MemSet
(
replaces
,
false
,
sizeof
(
replaces
));
replaces
[
Anum_pg_extprotocol_ptcowner
-
1
]
=
true
;
values
[
Anum_pg_extprotocol_ptcowner
-
1
]
=
ObjectIdGetDatum
(
newOwnerId
);
aclDatum
=
heap_getattr
(
tup
,
Anum_pg_extprotocol_ptcacl
,
RelationGetDescr
(
rel
),
&
isNull
);
if
(
!
isNull
)
{
newAcl
=
aclnewowner
(
DatumGetAclP
(
aclDatum
),
ownerId
,
newOwnerId
);
replaces
[
Anum_pg_extprotocol_ptcacl
-
1
]
=
true
;
values
[
Anum_pg_extprotocol_ptcacl
-
1
]
=
PointerGetDatum
(
newAcl
);
}
newtuple
=
heap_modify_tuple
(
tup
,
RelationGetDescr
(
rel
),
values
,
nulls
,
replaces
);
simple_heap_update
(
rel
,
&
newtuple
->
t_self
,
newtuple
);
CatalogUpdateIndexes
(
rel
,
newtuple
);
heap_freetuple
(
newtuple
);
/* Update owner dependency reference */
changeDependencyOnOwner
(
ExtprotocolRelationId
,
ptcId
,
newOwnerId
);
}
systable_endscan
(
scan
);
heap_close
(
rel
,
NoLock
);
return
ptcId
;
}
src/include/commands/extprotocolcmds.h
浏览文件 @
5abbfe99
...
...
@@ -13,7 +13,5 @@
extern
void
DefineExtProtocol
(
List
*
name
,
List
*
parameters
,
bool
trusted
);
extern
void
RemoveExtProtocolById
(
Oid
protOid
);
extern
Oid
AlterExtProtocolOwner
(
const
char
*
name
,
Oid
newOwnerId
);
#endif
/* EXTPROTOCOLCMDS_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录