From e078fb5d4eeb23d0d09932e0b183a8e7bdfb17b4 Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Mon, 10 Aug 2020 09:22:54 -0700 Subject: Move connect.h from fe_utils to src/include/common. Any libpq client can use the header. Clients include backend components postgres_fdw, dblink, and logical replication apply worker. Back-patch to v10, because another fix needs this. In released branches, just copy the header and keep the original. --- src/bin/pg_basebackup/streamutil.c | 2 +- src/bin/pg_dump/pg_backup_db.c | 2 +- src/bin/pg_dump/pg_dump.c | 2 +- src/bin/pg_dump/pg_dumpall.c | 2 +- src/bin/pg_rewind/libpq_fetch.c | 2 +- src/bin/pg_upgrade/server.c | 2 +- src/bin/scripts/common.c | 2 +- src/bin/scripts/reindexdb.c | 2 +- src/bin/scripts/vacuumdb.c | 2 +- src/fe_utils/cancel.c | 2 +- src/include/common/connect.h | 28 ++++++++++++++++++++++++++++ src/include/fe_utils/connect.h | 28 ---------------------------- src/tools/findoidjoins/findoidjoins.c | 2 +- 13 files changed, 39 insertions(+), 39 deletions(-) create mode 100644 src/include/common/connect.h delete mode 100644 src/include/fe_utils/connect.h (limited to 'src') diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c index 410116492ea..c08003e7f2c 100644 --- a/src/bin/pg_basebackup/streamutil.c +++ b/src/bin/pg_basebackup/streamutil.c @@ -18,11 +18,11 @@ #include #include "access/xlog_internal.h" +#include "common/connect.h" #include "common/fe_memutils.h" #include "common/file_perm.h" #include "common/logging.h" #include "datatype/timestamp.h" -#include "fe_utils/connect.h" #include "port/pg_bswap.h" #include "pqexpbuffer.h" #include "receivelog.h" diff --git a/src/bin/pg_dump/pg_backup_db.c b/src/bin/pg_dump/pg_backup_db.c index 6dba7e19e43..94af11b80a3 100644 --- a/src/bin/pg_dump/pg_backup_db.c +++ b/src/bin/pg_dump/pg_backup_db.c @@ -17,8 +17,8 @@ #include #endif +#include "common/connect.h" #include "dumputils.h" -#include "fe_utils/connect.h" #include "fe_utils/string_utils.h" #include "parallel.h" #include "pg_backup_archiver.h" diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 94459b3539a..9c8436dde6c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -52,8 +52,8 @@ #include "catalog/pg_proc_d.h" #include "catalog/pg_trigger_d.h" #include "catalog/pg_type_d.h" +#include "common/connect.h" #include "dumputils.h" -#include "fe_utils/connect.h" #include "fe_utils/string_utils.h" #include "getopt_long.h" #include "libpq/libpq-fs.h" diff --git a/src/bin/pg_dump/pg_dumpall.c b/src/bin/pg_dump/pg_dumpall.c index 8d548491023..2c82b39af0d 100644 --- a/src/bin/pg_dump/pg_dumpall.c +++ b/src/bin/pg_dump/pg_dumpall.c @@ -18,10 +18,10 @@ #include #include +#include "common/connect.h" #include "common/file_utils.h" #include "common/logging.h" #include "dumputils.h" -#include "fe_utils/connect.h" #include "fe_utils/string_utils.h" #include "getopt_long.h" #include "pg_backup.h" diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index c44648f8231..bf4dfc23b96 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -15,8 +15,8 @@ #include #include "catalog/pg_type_d.h" +#include "common/connect.h" #include "datapagemap.h" -#include "fe_utils/connect.h" #include "fetch.h" #include "file_ops.h" #include "filemap.h" diff --git a/src/bin/pg_upgrade/server.c b/src/bin/pg_upgrade/server.c index 79ec3f04c0e..7db3c1d51f2 100644 --- a/src/bin/pg_upgrade/server.c +++ b/src/bin/pg_upgrade/server.c @@ -9,7 +9,7 @@ #include "postgres_fe.h" -#include "fe_utils/connect.h" +#include "common/connect.h" #include "fe_utils/string_utils.h" #include "pg_upgrade.h" diff --git a/src/bin/scripts/common.c b/src/bin/scripts/common.c index ee65cc39481..420d0d11a5a 100644 --- a/src/bin/scripts/common.c +++ b/src/bin/scripts/common.c @@ -18,9 +18,9 @@ #include #include "common.h" +#include "common/connect.h" #include "common/logging.h" #include "fe_utils/cancel.h" -#include "fe_utils/connect.h" #include "fe_utils/string_utils.h" #define ERRCODE_UNDEFINED_TABLE "42P01" diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index b7b19ccc1ca..40dcbc92833 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -13,9 +13,9 @@ #include "catalog/pg_class_d.h" #include "common.h" +#include "common/connect.h" #include "common/logging.h" #include "fe_utils/cancel.h" -#include "fe_utils/connect.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" #include "scripts_parallel.h" diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c index 6a3c941158f..125ed2ff5a4 100644 --- a/src/bin/scripts/vacuumdb.c +++ b/src/bin/scripts/vacuumdb.c @@ -15,9 +15,9 @@ #include "catalog/pg_class_d.h" #include "common.h" +#include "common/connect.h" #include "common/logging.h" #include "fe_utils/cancel.h" -#include "fe_utils/connect.h" #include "fe_utils/simple_list.h" #include "fe_utils/string_utils.h" #include "scripts_parallel.h" diff --git a/src/fe_utils/cancel.c b/src/fe_utils/cancel.c index 51fb67d384a..70042017481 100644 --- a/src/fe_utils/cancel.c +++ b/src/fe_utils/cancel.c @@ -18,8 +18,8 @@ #include +#include "common/connect.h" #include "fe_utils/cancel.h" -#include "fe_utils/connect.h" #include "fe_utils/string_utils.h" diff --git a/src/include/common/connect.h b/src/include/common/connect.h new file mode 100644 index 00000000000..2cc5d7dd251 --- /dev/null +++ b/src/include/common/connect.h @@ -0,0 +1,28 @@ +/*------------------------------------------------------------------------- + * + * Interfaces in support of FE/BE connections. + * + * + * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * src/include/common/connect.h + * + *------------------------------------------------------------------------- + */ +#ifndef CONNECT_H +#define CONNECT_H + +/* + * This SQL statement installs an always-secure search path, so malicious + * users can't take control. CREATE of an unqualified name will fail, because + * this selects no creation schema. This does not demote pg_temp, so it is + * suitable where we control the entire FE/BE connection but not suitable in + * SECURITY DEFINER functions. This is portable to PostgreSQL 7.3, which + * introduced schemas. When connected to an older version from code that + * might work with the old server, skip this. + */ +#define ALWAYS_SECURE_SEARCH_PATH_SQL \ + "SELECT pg_catalog.set_config('search_path', '', false);" + +#endif /* CONNECT_H */ diff --git a/src/include/fe_utils/connect.h b/src/include/fe_utils/connect.h deleted file mode 100644 index 8030af9a9f8..00000000000 --- a/src/include/fe_utils/connect.h +++ /dev/null @@ -1,28 +0,0 @@ -/*------------------------------------------------------------------------- - * - * Interfaces in support of FE/BE connections. - * - * - * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group - * Portions Copyright (c) 1994, Regents of the University of California - * - * src/include/fe_utils/connect.h - * - *------------------------------------------------------------------------- - */ -#ifndef CONNECT_H -#define CONNECT_H - -/* - * This SQL statement installs an always-secure search path, so malicious - * users can't take control. CREATE of an unqualified name will fail, because - * this selects no creation schema. This does not demote pg_temp, so it is - * suitable where we control the entire FE/BE connection but not suitable in - * SECURITY DEFINER functions. This is portable to PostgreSQL 7.3, which - * introduced schemas. When connected to an older version from code that - * might work with the old server, skip this. - */ -#define ALWAYS_SECURE_SEARCH_PATH_SQL \ - "SELECT pg_catalog.set_config('search_path', '', false);" - -#endif /* CONNECT_H */ diff --git a/src/tools/findoidjoins/findoidjoins.c b/src/tools/findoidjoins/findoidjoins.c index 5239332ea7e..3d9ca262357 100644 --- a/src/tools/findoidjoins/findoidjoins.c +++ b/src/tools/findoidjoins/findoidjoins.c @@ -10,7 +10,7 @@ #include "access/transam.h" #include "catalog/pg_class_d.h" -#include "fe_utils/connect.h" +#include "common/connect.h" #include "libpq-fe.h" #include "pqexpbuffer.h" -- cgit v1.2.3