]> granicus.if.org Git - postgis/commitdiff
default blocking of GDAL VRT WCS WMS and MEM drivers
authorBborie Park <bkpark at ucdavis.edu>
Thu, 10 Apr 2014 21:53:39 +0000 (21:53 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Thu, 10 Apr 2014 21:53:39 +0000 (21:53 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@12456 b70326c6-7e19-0410-871a-916f4a2858ee

raster/rt_pg/rtpostgis.c

index a074e9f0c7a6e0f0c30512cedefac42ae2dfd43a..418d34a90a45317c2503d4db559fabcf763b5d63 100644 (file)
@@ -147,6 +147,11 @@ PG_MODULE_MAGIC;
 /* Module load callback */
 void _PG_init(void);
 
+/* ---------------------------------------------------------------- */
+/*  PostGIS raster GUCs                                             */
+/* ---------------------------------------------------------------- */
+
+/* postgis.gdal_datapath */
 static void
 rtpg_assignHookGDALDataPath(const char *newpath, void *extra) {
        POSTGIS_RT_DEBUGF(4, "newpath = %s", newpath);
@@ -161,18 +166,35 @@ rtpg_assignHookGDALDataPath(const char *newpath, void *extra) {
        CPLSetConfigOption("GDAL_DATA", newpath);
        POSTGIS_RT_DEBUGF(4, "GDAL_DATA = %s", CPLGetConfigOption("GDAL_DATA", NULL));
 }
-
 static char *gdaldatapath;
 
+static void
+rtpg_assignHookGDALEnabledDrivers(const char *newdrivers, void *extra) {
+       POSTGIS_RT_DEBUGF(4, "newdrivers = %s", newdrivers);
+
+       /* validate new drivers */
+
+       /*
+       CPLSetConfigOption("GDAL_SKIP", newdrivers);
+       */
+}
+static char *gdalenableddrivers;
+
 /* Module load callback */
 void
 _PG_init(void) {
+
+       /* restrict GDAL drivers */
+       /* unless over-ridden by GUCs, default to VRT, WMS, WCS and MEM */
+       CPLSetConfigOption("GDAL_SKIP", "VRT WMS WCS MEM");
+
        /* Install liblwgeom handlers */
        pg_install_lwgeom_handlers();
 
        /* TODO: Install raster callbacks (see rt_init_allocators)??? */
 
        /* Define custom GUC variables. */
+
        DefineCustomStringVariable(
                "postgis.gdal_datapath", /* name */
                "Path to GDAL data files.", /* short_desc */
@@ -187,6 +209,21 @@ _PG_init(void) {
                rtpg_assignHookGDALDataPath, /* GucStringAssignHook assign_hook */
                NULL  /* GucShowHook show_hook */
        );
+
+       DefineCustomStringVariable(
+               "postgis.gdal_enabled_drivers", /* name */
+               "Enabled GDAL drivers.", /* short_desc */
+               "List of permitted GDAL drivers. (sets the GDAL_SKIP config option).", /* long_desc */
+               &gdalenableddrivers, /* valueAddr */
+               NULL, /* bootValue */
+               PGC_SUSET, /* GucContext context */
+               0, /* int flags */
+#if POSTGIS_PGSQL_VERSION >= 91
+               NULL, /* GucStringCheckHook check_hook */
+#endif
+               rtpg_assignHookGDALEnabledDrivers, /* GucStringAssignHook assign_hook */
+               NULL  /* GucShowHook show_hook */
+       );
 }
 
 /* ---------------------------------------------------------------- */