2005-08-15 17:02:26 -04:00
|
|
|
/*
|
|
|
|
|
* common.h
|
|
|
|
|
* Common support routines for bin/scripts/
|
|
|
|
|
*
|
2013-01-01 17:15:01 -05:00
|
|
|
* Copyright (c) 2003-2013, PostgreSQL Global Development Group
|
2005-08-15 17:02:26 -04:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/bin/scripts/common.h
|
2005-08-15 17:02:26 -04:00
|
|
|
*/
|
|
|
|
|
#ifndef COMMON_H
|
|
|
|
|
#define COMMON_H
|
2003-03-18 17:19:47 -05:00
|
|
|
|
|
|
|
|
#include "libpq-fe.h"
|
2012-06-10 15:20:04 -04:00
|
|
|
#include "getopt_long.h" /* pgrminclude ignore */
|
|
|
|
|
#include "pqexpbuffer.h" /* pgrminclude ignore */
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2009-02-26 11:02:39 -05:00
|
|
|
enum trivalue
|
|
|
|
|
{
|
|
|
|
|
TRI_DEFAULT,
|
|
|
|
|
TRI_NO,
|
|
|
|
|
TRI_YES
|
|
|
|
|
};
|
|
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
typedef void (*help_handler) (const char *progname);
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
extern const char *get_user_name(const char *progname);
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
extern void handle_help_version_opts(int argc, char *argv[],
|
2005-10-14 22:49:52 -04:00
|
|
|
const char *fixed_progname,
|
|
|
|
|
help_handler hlp);
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
extern PGconn *connectDatabase(const char *dbname, const char *pghost,
|
2005-10-14 22:49:52 -04:00
|
|
|
const char *pgport, const char *pguser,
|
2011-12-06 08:48:15 -05:00
|
|
|
enum trivalue prompt_password, const char *progname,
|
Empty search_path in Autovacuum and non-psql/pgbench clients.
This makes the client programs behave as documented regardless of the
connect-time search_path and regardless of user-created objects. Today,
a malicious user with CREATE permission on a search_path schema can take
control of certain of these clients' queries and invoke arbitrary SQL
functions under the client identity, often a superuser. This is
exploitable in the default configuration, where all users have CREATE
privilege on schema "public".
This changes behavior of user-defined code stored in the database, like
pg_index.indexprs and pg_extension_config_dump(). If they reach code
bearing unqualified names, "does not exist" or "no schema has been
selected to create in" errors might appear. Users may fix such errors
by schema-qualifying affected names. After upgrading, consider watching
server logs for these errors.
The --table arguments of src/bin/scripts clients have been lax; for
example, "vacuumdb -Zt pg_am\;CHECKPOINT" performed a checkpoint. That
now fails, but for now, "vacuumdb -Zt 'pg_am(amname);CHECKPOINT'" still
performs a checkpoint.
Back-patch to 9.3 (all supported versions).
Reviewed by Tom Lane, though this fix strategy was not his first choice.
Reported by Arseniy Sharoglazov.
Security: CVE-2018-1058
2018-02-26 10:39:44 -05:00
|
|
|
bool echo, bool fail_ok);
|
2011-12-06 08:48:15 -05:00
|
|
|
|
|
|
|
|
extern PGconn *connectMaintenanceDatabase(const char *maintenance_db,
|
Empty search_path in Autovacuum and non-psql/pgbench clients.
This makes the client programs behave as documented regardless of the
connect-time search_path and regardless of user-created objects. Today,
a malicious user with CREATE permission on a search_path schema can take
control of certain of these clients' queries and invoke arbitrary SQL
functions under the client identity, often a superuser. This is
exploitable in the default configuration, where all users have CREATE
privilege on schema "public".
This changes behavior of user-defined code stored in the database, like
pg_index.indexprs and pg_extension_config_dump(). If they reach code
bearing unqualified names, "does not exist" or "no schema has been
selected to create in" errors might appear. Users may fix such errors
by schema-qualifying affected names. After upgrading, consider watching
server logs for these errors.
The --table arguments of src/bin/scripts clients have been lax; for
example, "vacuumdb -Zt pg_am\;CHECKPOINT" performed a checkpoint. That
now fails, but for now, "vacuumdb -Zt 'pg_am(amname);CHECKPOINT'" still
performs a checkpoint.
Back-patch to 9.3 (all supported versions).
Reviewed by Tom Lane, though this fix strategy was not his first choice.
Reported by Arseniy Sharoglazov.
Security: CVE-2018-1058
2018-02-26 10:39:44 -05:00
|
|
|
const char *pghost, const char *pgport,
|
|
|
|
|
const char *pguser, enum trivalue prompt_password,
|
|
|
|
|
const char *progname, bool echo);
|
2003-03-18 17:19:47 -05:00
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
extern PGresult *executeQuery(PGconn *conn, const char *query,
|
2005-10-14 22:49:52 -04:00
|
|
|
const char *progname, bool echo);
|
2003-05-27 15:36:55 -04:00
|
|
|
|
2005-08-15 17:02:26 -04:00
|
|
|
extern void executeCommand(PGconn *conn, const char *query,
|
2005-10-14 22:49:52 -04:00
|
|
|
const char *progname, bool echo);
|
2005-08-15 17:02:26 -04:00
|
|
|
|
2007-04-09 14:21:22 -04:00
|
|
|
extern bool executeMaintenanceCommand(PGconn *conn, const char *query,
|
2007-11-15 16:14:46 -05:00
|
|
|
bool echo);
|
2007-04-09 14:21:22 -04:00
|
|
|
|
Empty search_path in Autovacuum and non-psql/pgbench clients.
This makes the client programs behave as documented regardless of the
connect-time search_path and regardless of user-created objects. Today,
a malicious user with CREATE permission on a search_path schema can take
control of certain of these clients' queries and invoke arbitrary SQL
functions under the client identity, often a superuser. This is
exploitable in the default configuration, where all users have CREATE
privilege on schema "public".
This changes behavior of user-defined code stored in the database, like
pg_index.indexprs and pg_extension_config_dump(). If they reach code
bearing unqualified names, "does not exist" or "no schema has been
selected to create in" errors might appear. Users may fix such errors
by schema-qualifying affected names. After upgrading, consider watching
server logs for these errors.
The --table arguments of src/bin/scripts clients have been lax; for
example, "vacuumdb -Zt pg_am\;CHECKPOINT" performed a checkpoint. That
now fails, but for now, "vacuumdb -Zt 'pg_am(amname);CHECKPOINT'" still
performs a checkpoint.
Back-patch to 9.3 (all supported versions).
Reviewed by Tom Lane, though this fix strategy was not his first choice.
Reported by Arseniy Sharoglazov.
Security: CVE-2018-1058
2018-02-26 10:39:44 -05:00
|
|
|
extern void appendQualifiedRelation(PQExpBuffer buf, const char *name,
|
|
|
|
|
PGconn *conn, const char *progname, bool echo);
|
|
|
|
|
|
2006-09-22 14:50:41 -04:00
|
|
|
extern bool yesno_prompt(const char *question);
|
2005-08-15 17:02:26 -04:00
|
|
|
|
2007-04-09 14:21:22 -04:00
|
|
|
extern void setup_cancel_handler(void);
|
|
|
|
|
|
2005-10-14 22:49:52 -04:00
|
|
|
#endif /* COMMON_H */
|