mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Restrict non-superusers to password authenticated connections
to prevent possible escalation of privilege. Provide new SECURITY DEFINER functions with old behavior, but initially REVOKE ALL from public for these functions. Per list discussion and design proposed by Tom Lane. A different approach will be used for back-branches, committed separately.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
* Darko Prenosil <Darko.Prenosil@finteh.hr>
|
||||
* Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
|
||||
*
|
||||
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.63 2007/04/06 04:21:41 tgl Exp $
|
||||
* $PostgreSQL: pgsql/contrib/dblink/dblink.c,v 1.64 2007/07/08 17:12:38 joe Exp $
|
||||
* Copyright (c) 2001-2007, PostgreSQL Global Development Group
|
||||
* ALL RIGHTS RESERVED;
|
||||
*
|
||||
@ -37,6 +37,7 @@
|
||||
#include "libpq-fe.h"
|
||||
#include "fmgr.h"
|
||||
#include "funcapi.h"
|
||||
#include "miscadmin.h"
|
||||
#include "access/heapam.h"
|
||||
#include "access/tupdesc.h"
|
||||
#include "catalog/namespace.h"
|
||||
@ -245,6 +246,22 @@ dblink_connect(PG_FUNCTION_ARGS)
|
||||
errdetail("%s", msg)));
|
||||
}
|
||||
|
||||
if (!superuser())
|
||||
{
|
||||
if (!PQconnectionUsedPassword(conn))
|
||||
{
|
||||
PQfinish(conn);
|
||||
if (rconn)
|
||||
pfree(rconn);
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
|
||||
errmsg("password is required"),
|
||||
errdetail("Non-superuser cannot connect if the server does not request a password."),
|
||||
errhint("Target server's authentication method must be changed.")));
|
||||
}
|
||||
}
|
||||
|
||||
if (connname)
|
||||
{
|
||||
rconn->conn = conn;
|
||||
|
Reference in New Issue
Block a user