From 7bf4b9dc04a060ff81aa4e0d149d0d2ff7c510dc Mon Sep 17 00:00:00 2001 From: Mike Palmiotto Date: Fri, 14 Oct 2022 12:31:05 -0400 Subject: [PATCH] Drop deprecated gucs mechanism This commit gets rid of the deprecated GUCs mechanism, thereby rendering the old `set_user.superuser_whitelist` GUC useless. Users should update their postgresql.conf to use the newer `superuser_allowlist`. --- deprecated_gucs.h | 84 ----------------------------------------------- set_user.c | 7 ---- 2 files changed, 91 deletions(-) delete mode 100644 deprecated_gucs.h diff --git a/deprecated_gucs.h b/deprecated_gucs.h deleted file mode 100644 index 673fd58..0000000 --- a/deprecated_gucs.h +++ /dev/null @@ -1,84 +0,0 @@ -/* ------------------------------------------------------------------------- - * - * deprecated_gucs.h - * - * Definitions for deprecated set_user GUCs. - * - * Copyright (c) 2010-2022, PostgreSQL Global Development Group - * - * ------------------------------------------------------------------------- - */ - -#ifndef DEPRECATED_GUCS_H -#define DEPRECATED_GUCS_H - -/* - * PostgreSQL GUC variable deprecation handling. - */ -#include "miscadmin.h" -#include "utils/guc.h" - -static bool -check_set_user_list(char **newval, void **extra, GucSource source, - const char *depname, const char *newname, bool *notice) -{ - /* - * Notify on the first non-default change for the Postmaster PID only. - */ - if (MyProcPid == PostmasterPid && source != PGC_S_DEFAULT && *notice) - { - ereport(NOTICE, (errcode(ERRCODE_WARNING_DEPRECATED_FEATURE), - errmsg("deprecated GUC: set_user.%s", depname), - errhint("Use set_user.%s instead.", newname))); - *notice = false; - } - - /* - * If the deprecated value is being set, allocate some memory to copy - * it to the new GUC, so they remain in sync. Do not free previous - * allocated value here, as set_string_field will handle that. A call - * to free here would only result in an invalid free in set_string_field. - */ - if (*newval) - { - *extra = strdup(*newval); - if (*extra == NULL) - { - ereport(FATAL, - (errcode(ERRCODE_OUT_OF_MEMORY), - errmsg("out of memory"))); - } - } - - return true; -} - -#define DefineDeprecatedStringVariable(deprecated_name, new_name, old_value, new_value) \ - DefineCustomStringVariable("set_user." #deprecated_name, \ - "Deprecated: see \"set_user." #new_name "\"", \ - NULL, &old_value, ALLOWLIST_WILDCARD, PGC_SIGHUP, GUC_NO_SHOW_ALL, \ - check_ ##deprecated_name, assign_ ##deprecated_name, show_ ##deprecated_name) - - -#define DEPRECATED_GUC(deprecated_name, new_name, old_value, new_value) \ -static char * old_value; \ -static bool notice_ ##old_value = true; \ -static bool \ -check_ ##deprecated_name(char **newval, void **extra, GucSource source) \ -{ \ - return check_set_user_list(newval, extra, source, #deprecated_name, #new_name, ¬ice_ ##old_value); \ -} \ -static void \ -assign_ ##deprecated_name (const char *newval, void *extra) \ -{ \ - if (extra) \ - { \ - new_value = extra; \ - } \ -} \ -static const char *show_ ##deprecated_name (void) \ -{ \ - return new_value; \ -} - -#endif /* DEPRECATED_GUCS_H */ diff --git a/set_user.c b/set_user.c index c85d3c0..ffbb13c 100644 --- a/set_user.c +++ b/set_user.c @@ -55,7 +55,6 @@ PG_MODULE_MAGIC; #include "compatibility.h" -#include "deprecated_gucs.h" #define ALLOWLIST_WILDCARD "*" #define SUPERUSER_AUDIT_TAG "AUDIT" @@ -103,9 +102,6 @@ extern Datum set_user(PG_FUNCTION_ARGS); void _PG_init(void); void _PG_fini(void); -DEPRECATED_GUC(nosuperuser_target_whitelist, nosuperuser_target_allowlist, NOSU_TargetWhitelist, NOSU_TargetAllowlist) -DEPRECATED_GUC(superuser_whitelist, superuser_allowlist, SU_Whitelist, SU_Allowlist) - /* used to block set_config() */ static void set_user_object_access(ObjectAccessType access, Oid classId, Oid objectId, int subId, void *arg); static void set_user_block_set_config(Oid functionId); @@ -532,9 +528,6 @@ _PG_init(void) NULL, &exit_on_error, true, PGC_SIGHUP, 0, NULL, NULL, NULL); - DefineDeprecatedStringVariable(nosuperuser_target_whitelist, nosuperuser_target_allowlist, NOSU_TargetWhitelist, NOSU_TargetAllowlist); - DefineDeprecatedStringVariable(superuser_whitelist, superuser_allowlist, SU_Whitelist, SU_Allowlist); - /* Install hook */ prev_hook = ProcessUtility_hook; ProcessUtility_hook = PU_hook;