Opened 8 years ago

Closed 8 years ago

#6380 closed enhancement (fixed)

Allow GDALDriverManager::AutoLoadDrivers to be compiled out

Reported by: Kurt Schwehr Owned by: Kurt Schwehr
Priority: normal Milestone: 2.1.0
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

Some environments may want to prevent compiling in the driver autoloading system for drivers to help with security.

Going to add ifdef wrappers around the relevant code.

#ifndef GDAL_NO_AUTOLOAD
    /* AutoLoadDrivers code. */
#endif

I am not planning to add a configure option in the near term unless people ask for it. People wanting this feature can use USER_DEFS or modify their GDALmake.opt for now.

Change History (7)

comment:1 by Kyle Shannon, 8 years ago

Isn't this the same as not calling GDALAllRegister() and registering drivers explicitly? It seems like it could cause issues if the GDAL_NO_AUTOLOAD is set and someone calls GDALAllRegister() and it's a no-op. Just curious on the use case I guess.

comment:2 by Kurt Schwehr, 8 years ago

This will not change the normal compiled in driver behavior if you call GDALAllRegister. Only the stuff that would get loaded via GDAL_DRIVER_PATH or OGR_DRIVER_PATH. For most users, that would mean that compiling with GDAL_NO_AUTOLOAD would have no visible behavior changes. That define would block external plugins. That's why I think this removal should not be the default.

comment:3 by Kyle Shannon, 8 years ago

That sounds perfectly reasonable to me, my mistake. Thanks for the explanation Kurt.

comment:4 by Kurt Schwehr, 8 years ago

Kyle, Thanks for asking. My current proposed patch:

  • frmts/gdalallregister.cpp

     
    6262void CPL_STDCALL GDALAllRegister()
    6363
    6464{
     65    // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
    6566    GetGDALDriverManager()->AutoLoadDrivers();
    6667
    6768#ifdef FRMT_vrt
  • gcore/gdal_priv.h

     
    11481148    int         RegisterDriver( GDALDriver * );
    11491149    void        DeregisterDriver( GDALDriver * );
    11501150
     1151    // AutoLoadDrivers is a no-op if compiled with GDAL_NO_AUTOLOAD defined.
    11511152    void        AutoLoadDrivers();
    11521153    void        AutoSkipDrivers();
    11531154};
  • gcore/gdaldrivermanager.cpp

     
    662662void GDALDriverManager::AutoLoadDrivers()
    663663
    664664{
     665#ifdef GDAL_NO_AUTOLOAD
     666  CPLDebug( "GDAL", "GDALDriverManager::AutoLoadDrivers() not compiled in." );
     667#else
    665668    const char *pszGDAL_DRIVER_PATH =
    666669        CPLGetConfigOption( "GDAL_DRIVER_PATH", NULL );
    667670    if( pszGDAL_DRIVER_PATH == NULL )
     
    815818    }
    816819
    817820    CSLDestroy( papszSearchPath );
     821
     822#endif  // GDAL_NO_AUTOLOAD
     823
    818824}
    819825
    820826/************************************************************************/
Version 1, edited 8 years ago by Kurt Schwehr (previous) (next) (diff)

comment:5 by Kyle Shannon, 8 years ago

Sounds good to me. I didn't do a thorough review, but looks good.

comment:6 by Kurt Schwehr, 8 years ago

comment:7 by Even Rouault, 8 years ago

Milestone: 2.1.0
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.