remove pghba contrib module
authorTomas Vondra <[email protected]>
Wed, 24 Aug 2016 10:05:24 +0000 (12:05 +0200)
committerPavan Deolasee <[email protected]>
Thu, 1 Sep 2016 05:21:24 +0000 (10:51 +0530)
The purpose of the module is unknown, and it does not even compile
for quite some time, so apparently no one uses it. Instead of fixing
it, let's remove it - if someone realizes it's useful, we can get
it from history.

contrib/pghba/Makefile [deleted file]
contrib/pghba/pghba--1.0.sql [deleted file]
contrib/pghba/pghba--unpackaged--1.0.sql [deleted file]
contrib/pghba/pghba.c [deleted file]
contrib/pghba/pghba.control [deleted file]

diff --git a/contrib/pghba/Makefile b/contrib/pghba/Makefile
deleted file mode 100644 (file)
index 7978b3a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# contrib/pghba/Makefile
-
-MODULE_big = pghba
-OBJS = pghba.o
-
-EXTENSION = pghba
-DATA = pghba--1.0.sql pghba--unpackaged--1.0.sql
-
-ifdef USE_PGXS
-PG_CONFIG = pg_config
-PGXS := $(shell $(PG_CONFIG) --pgxs)
-include $(PGXS)
-else
-subdir = contrib/pghba
-top_builddir = ../..
-include $(top_builddir)/src/Makefile.global
-include $(top_srcdir)/contrib/contrib-global.mk
-endif
diff --git a/contrib/pghba/pghba--1.0.sql b/contrib/pghba/pghba--1.0.sql
deleted file mode 100644 (file)
index f12d5f1..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* contrib/pghba/pghba--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION pghba" to load this file. \quit
-
--- Register the function.
-CREATE FUNCTION pghba_list()
-RETURNS SETOF RECORD
-AS 'MODULE_PATHNAME', 'pghba_list'
-LANGUAGE C;
-
--- Create a view for convenient access.
-CREATE VIEW pghba AS
-        SELECT H.* FROM pghba_list() AS H
-        (linenumber integer, conntype integer, databases text, roles text,
-        addr text, mask text, ip_cmp_method integer, hostname text,
-        auth_method integer, usermap text, pamservice text, ldaptls boolean,
-        ldapserver text, ldapport integer, ldapbinddn text, ldapbindpasswd text,
-        ldapsearchattribute text, ldapbasedn text, ldapprefix text,
-        ldapsuffix text, clientcert boolean, krb_server_hostname text,
-        krb_realm text, include_realm boolean, radiusserver text,
-        radiussecret text, radiusidentifier text, radiusport integer);
-
--- Don't want these to be available to public.
-REVOKE ALL on FUNCTION pghba_list() FROM public;
-REVOKE ALL on pghba FROM public;
diff --git a/contrib/pghba/pghba--unpackaged--1.0.sql b/contrib/pghba/pghba--unpackaged--1.0.sql
deleted file mode 100644 (file)
index 0620004..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-/* contrib/pghba/pghba--unpackaged--1.0.sql */
-
--- complain if script is sourced in psql, rather than via CREATE EXTENSION
-\echo Use "CREATE EXTENSION pghba" to load this file. \quit
-
-ALTER EXTENSION pghba ADD view pghba;
diff --git a/contrib/pghba/pghba.c b/contrib/pghba/pghba.c
deleted file mode 100644 (file)
index 3cb9c72..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * pghba.c
- *       display and manipulate the contents of pg_hba.conf
- *
- *       contrib/pghba/pghba.c
- *-------------------------------------------------------------------------
- */
-#include "postgres.h"
-
-#include "catalog/pg_type.h"
-#include "funcapi.h"
-#include "libpq/hba.h"
-#include "utils/builtins.h"
-#include "miscadmin.h"
-
-#define NCOLUMNS       28
-/* This is used to separate values in multi-valued column strings */
-#define MULTI_VALUE_SEP "\001"
-
-PG_MODULE_MAGIC;
-
-Datum          pghba_list(PG_FUNCTION_ARGS);
-
-PG_FUNCTION_INFO_V1(pghba_list);
-
-Datum
-pghba_list(PG_FUNCTION_ARGS)
-{
-       ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
-       TupleDesc       tupdesc;
-       Tuplestorestate *tupstore;
-       MemoryContext per_query_ctx;
-       MemoryContext oldcontext;
-       ListCell   *line;
-       HbaLine    *hba;
-       List       *lines;
-       StringInfoData  buf;
-
-       /* check to see if caller supports us returning a tuplestore */
-       if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
-               ereport(ERROR,
-                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                errmsg("set-valued function called in context that cannot accept a set")));
-       if (!(rsinfo->allowedModes & SFRM_Materialize))
-               ereport(ERROR,
-                               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
-                                errmsg("materialize mode required, but it is not " \
-                                               "allowed in this context")));
-
-       tupdesc = CreateTemplateTupleDesc(NCOLUMNS, false);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 1, "linenumber",
-                                          INT4OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 2, "conntype",
-                                          INT4OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 3, "databases",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 4, "roles",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 5, "addr",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 6, "mask",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 7, "ip_cmp_method",
-                                          INT4OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 8, "hostname",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 9, "auth_method",
-                                          INT4OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 10, "usermap",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 11, "pamservice",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 12, "ldaptls",
-                                          BOOLOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 13, "ldapserver",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 14, "ldapport",
-                                          INT4OID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 15, "ldapbinddn",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 16, "ldapbindpasswd",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 17, "ldapsearchattribute",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 18, "ldapbasedn",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 19, "ldapprefix",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 20, "ldapsuffix",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 21, "clientcert",
-                                          BOOLOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 22, "krb_server_hostname",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 23, "krb_realm",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 24, "include_realm",
-                                          BOOLOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 25, "radiusserver",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 26, "radiussecret",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 27, "radiusidentifier",
-                                          TEXTOID, -1, 0);
-       TupleDescInitEntry(tupdesc, (AttrNumber) 28, "radiusport",
-                                          INT4OID, -1, 0);
-
-       per_query_ctx = rsinfo->econtext->ecxt_per_query_memory;
-       oldcontext = MemoryContextSwitchTo(per_query_ctx);
-
-       tupstore = tuplestore_begin_heap(true, false, work_mem);
-       rsinfo->returnMode = SFRM_Materialize;
-       rsinfo->setResult = tupstore;
-       rsinfo->setDesc = tupdesc;
-
-       MemoryContextSwitchTo(oldcontext);
-
-       initStringInfo(&buf);
-       lines = get_parsed_hba();
-       foreach(line, lines)
-       {
-               Datum           values[NCOLUMNS];
-               bool            nulls[NCOLUMNS];
-               int             i = 0, j;
-               char                    *databases;
-               char                    *roles;
-               char                    *member;
-               char                    addr[INET6_ADDRSTRLEN];
-               char            mask[INET6_ADDRSTRLEN];
-               socklen_t               addr_len;
-               socklen_t               mask_len;
-
-               hba = (HbaLine *) lfirst(line);
-
-               memset(values, 0, sizeof(values));
-               memset(nulls, 0, sizeof(nulls));
-
-               values[i++] = ObjectIdGetDatum(hba->linenumber);
-               values[i++] = ObjectIdGetDatum(hba->conntype);
-
-               /* Get the list of databases as text */
-               resetStringInfo(&buf);
-               databases = pstrdup(hba->database);
-               j = 0;
-               for (member = strtok(databases, MULTI_VALUE_SEP);
-                        member != NULL;
-                        member = strtok(NULL, MULTI_VALUE_SEP))
-               {
-                       if (j++ == 0)
-                               appendStringInfo(&buf, "%s", member);
-                       else
-                               appendStringInfo(&buf, ",%s", member);
-               }
-               values[i++] = CStringGetTextDatum(pstrdup(buf.data));
-
-               /* Get the list of roles as text */
-               resetStringInfo(&buf);
-               roles = pstrdup(hba->role);
-               j = 0;
-               for (member = strtok(roles, MULTI_VALUE_SEP);
-                        member != NULL;
-                        member = strtok(NULL, MULTI_VALUE_SEP))
-               {
-                       if (j++ == 0)
-                               appendStringInfo(&buf, "%s", member);
-                       else
-                               appendStringInfo(&buf, ",%s", member);
-               }
-               values[i++] = CStringGetTextDatum(pstrdup(buf.data));
-
-               if (hba->conntype == ctLocal)
-               {
-                       /* Address is null for local */
-                       nulls[i++] = true;
-
-                       /* Mask is null for local */
-                       nulls[i++] = true;
-               } else {
-                       addr_len=sizeof(hba->addr);
-                       getnameinfo((struct sockaddr *) & hba->addr,addr_len,addr,sizeof(addr),
-                                               0,0,NI_NUMERICHOST);
-
-                       values[i++] = CStringGetTextDatum(addr);
-
-                       mask_len=sizeof(hba->mask);
-                       getnameinfo((struct sockaddr *) & hba->mask,mask_len,mask,sizeof(mask),
-                                               0,0,NI_NUMERICHOST);
-
-                       values[i++] = CStringGetTextDatum(mask);
-               }
-
-               values[i++] = ObjectIdGetDatum(hba->ip_cmp_method);
-
-               if (hba->hostname == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->hostname));
-
-               values[i++] = ObjectIdGetDatum(hba->auth_method);
-
-               if (hba->usermap == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->usermap));
-
-               if (hba->pamservice == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->pamservice));
-
-               values[i++] = BoolGetDatum(hba->ldaptls);
-
-               if (hba->ldapserver == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapserver));
-
-               values[i++] = ObjectIdGetDatum(hba->ldapport);
-
-               if (hba->ldapbinddn == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapbinddn));
-
-               if (hba->ldapbindpasswd == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapbindpasswd));
-
-               if (hba->ldapsearchattribute == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapsearchattribute));
-
-               if (hba->ldapbasedn == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapbasedn));
-
-               if (hba->ldapprefix == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapprefix));
-
-               if (hba->ldapsuffix == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->ldapsuffix));
-
-               values[i++] = BoolGetDatum(hba->clientcert);
-
-               if (hba->krb_server_hostname == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->krb_server_hostname));
-
-               if (hba->krb_realm == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->krb_realm));
-
-               values[i++] = BoolGetDatum(hba->include_realm);
-
-               if (hba->radiusserver == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->radiusserver));
-
-               if (hba->radiussecret == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->radiussecret));
-
-               if (hba->radiusidentifier == NULL)
-                       nulls[i++] = true;
-               else
-                       values[i++] = CStringGetTextDatum(pstrdup(hba->radiusidentifier));
-
-               values[i++] = ObjectIdGetDatum(hba->radiusport);
-
-               Assert(i == NCOLUMNS);
-
-               tuplestore_putvalues(tupstore, tupdesc, values, nulls);
-       }
-
-       /* clean up and return the tuplestore */
-       tuplestore_donestoring(tupstore);
-
-       return (Datum) 0;
-}
diff --git a/contrib/pghba/pghba.control b/contrib/pghba/pghba.control
deleted file mode 100644 (file)
index c205548..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-# pghba extension
-comment = 'examine and manipulate the pg_hba file'
-default_version = '1.0'
-module_pathname = '$libdir/pghba'
-relocatable = true