mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Allow pg_terminate_backend() to be used on backends with matching role.
A similar change was made previously for pg_cancel_backend, so now it all matches again. Dan Farina, reviewed by Fujii Masao, Noah Misch, and Jeff Davis, with slight kibitzing on the doc changes by me.
This commit is contained in:
@ -162,18 +162,20 @@ pg_cancel_backend(PG_FUNCTION_ARGS)
|
||||
}
|
||||
|
||||
/*
|
||||
* Signal to terminate a backend process. Only allowed by superuser.
|
||||
* Signal to terminate a backend process. This is allowed if you are superuser
|
||||
* or have the same role as the process being terminated.
|
||||
*/
|
||||
Datum
|
||||
pg_terminate_backend(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!superuser())
|
||||
int r = pg_signal_backend(PG_GETARG_INT32(0), SIGTERM);
|
||||
|
||||
if (r == SIGNAL_BACKEND_NOPERMISSION)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be superuser to terminate other server processes"),
|
||||
errhint("You can cancel your own processes with pg_cancel_backend().")));
|
||||
(errmsg("must be superuser or have the same role to terminate backends running in other server processes"))));
|
||||
|
||||
PG_RETURN_BOOL(pg_signal_backend(PG_GETARG_INT32(0), SIGTERM) == SIGNAL_BACKEND_SUCCESS);
|
||||
PG_RETURN_BOOL(r == SIGNAL_BACKEND_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user