*** a/contrib/dblink/dblink.c
--- b/contrib/dblink/dblink.c
*************** typedef struct remoteConnHashEnt
*** 162,171 ****
--- 162,175 ----
  			{ \
  				conn = rconn->conn; \
  			} \
  			else \
  			{ \
+ 				if (!superuser()) \
+ 					ereport(ERROR, \
+ 							(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), \
+ 							 errmsg("only superuser can specify connect string"))); \
  				connstr = conname_or_str; \
  				conn = PQconnectdb(connstr); \
  				if (PQstatus(conn) == CONNECTION_BAD) \
  				{ \
  					msg = pstrdup(PQerrorMessage(conn)); \
*************** dblink_connect(PG_FUNCTION_ARGS)
*** 213,222 ****
--- 217,231 ----
  	char	   *msg;
  	MemoryContext oldcontext;
  	PGconn	   *conn = NULL;
  	remoteConn *rconn = NULL;
  
+ 	if (!superuser())
+ 		ereport(ERROR,
+ 				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
+ 				 errmsg("dblink_connect() requires superuser privileges")));
+ 
  	DBLINK_INIT;
  
  	if (PG_NARGS() == 2)
  	{
  		connstr = text_to_cstring(PG_GETARG_TEXT_PP(1));
