Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7b970bc

Browse files
committed
Use aclcheck_error() in place of ad-hoc permissions complaints.
1 parent ea4686e commit 7b970bc

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/backend/commands/functioncmds.c

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.14 2002/07/29 20:45:44 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.15 2002/07/29 23:44:44 tgl Exp $
1313
*
1414
* DESCRIPTION
1515
* These routines take the parse tree and pick out the
@@ -47,6 +47,7 @@
4747
#include "parser/parse_func.h"
4848
#include "parser/parse_type.h"
4949
#include "utils/acl.h"
50+
#include "utils/builtins.h"
5051
#include "utils/fmgroids.h"
5152
#include "utils/lsyscache.h"
5253
#include "utils/syscache.h"
@@ -633,10 +634,14 @@ CreateCast(CreateCastStmt *stmt)
633634

634635
if (stmt->func != NULL)
635636
{
636-
funcid = LookupFuncNameTypeNames(stmt->func->funcname, stmt->func->funcargs, false, "CreateCast");
637+
funcid = LookupFuncNameTypeNames(stmt->func->funcname,
638+
stmt->func->funcargs,
639+
false,
640+
"CreateCast");
637641

638-
if(!pg_proc_ownercheck(funcid, GetUserId()))
639-
elog(ERROR, "permission denied");
642+
if (!pg_proc_ownercheck(funcid, GetUserId()))
643+
aclcheck_error(ACLCHECK_NOT_OWNER,
644+
NameListToString(stmt->func->funcname));
640645

641646
tuple = SearchSysCache(PROCOID, ObjectIdGetDatum(funcid), 0, 0, 0);
642647
if (!HeapTupleIsValid(tuple))
@@ -661,10 +666,13 @@ CreateCast(CreateCastStmt *stmt)
661666
else
662667
{
663668
/* indicates binary compatibility */
664-
if (!pg_type_ownercheck(sourcetypeid, GetUserId())
665-
|| !pg_type_ownercheck(targettypeid, GetUserId()))
666-
elog(ERROR, "permission denied");
667-
funcid = 0;
669+
if (!pg_type_ownercheck(sourcetypeid, GetUserId()))
670+
aclcheck_error(ACLCHECK_NOT_OWNER,
671+
TypeNameToString(stmt->sourcetype));
672+
if (!pg_type_ownercheck(targettypeid, GetUserId()))
673+
aclcheck_error(ACLCHECK_NOT_OWNER,
674+
TypeNameToString(stmt->targettype));
675+
funcid = InvalidOid;
668676
}
669677

670678
/* ready to go */
@@ -754,14 +762,18 @@ DropCast(DropCastStmt *stmt)
754762
caststruct = (Form_pg_cast) GETSTRUCT(tuple);
755763
if (caststruct->castfunc != InvalidOid)
756764
{
757-
if(!pg_proc_ownercheck(caststruct->castfunc, GetUserId()))
758-
elog(ERROR, "permission denied");
765+
if (!pg_proc_ownercheck(caststruct->castfunc, GetUserId()))
766+
aclcheck_error(ACLCHECK_NOT_OWNER,
767+
get_func_name(caststruct->castfunc));
759768
}
760769
else
761770
{
762-
if (!pg_type_ownercheck(sourcetypeid, GetUserId())
763-
|| !pg_type_ownercheck(targettypeid, GetUserId()))
764-
elog(ERROR, "permission denied");
771+
if (!pg_type_ownercheck(sourcetypeid, GetUserId()))
772+
aclcheck_error(ACLCHECK_NOT_OWNER,
773+
format_type_be(sourcetypeid));
774+
if (!pg_type_ownercheck(targettypeid, GetUserId()))
775+
aclcheck_error(ACLCHECK_NOT_OWNER,
776+
format_type_be(targettypeid));
765777
}
766778

767779
/*

0 commit comments

Comments
 (0)