diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-06-26 16:16:52 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-06-27 08:34:28 -0400 |
commit | eee5088e538be24f6c42e758ef27cecc2b2579f1 (patch) | |
tree | 2ee2d467ad4ebf9884960933ea5dd7e7530f7569 /src | |
parent | 00e5844592a8c51ceee1682013b94ac50031a9ac (diff) | |
download | postgresql-eee5088e538be24f6c42e758ef27cecc2b2579f1.tar.gz postgresql-eee5088e538be24f6c42e758ef27cecc2b2579f1.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/misc.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 96e692766bf..f3c7860f0c3 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -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); } /* |