#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:


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.

    /* AutoLoadDrivers code. */

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 Changed 13 months ago by Kyle Shannon

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 Changed 13 months ago by Kurt Schwehr

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 Changed 13 months ago by Kyle Shannon

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

comment:4 Changed 13 months ago by Kurt Schwehr

Kyle, Thanks for asking. My current proposed patch:

  • frmts/gdalallregister.cpp

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

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

    662662void GDALDriverManager::AutoLoadDrivers()
     665#ifdef GDAL_NO_AUTOLOAD
     666    CPLDebug( "GDAL", "GDALDriverManager::AutoLoadDrivers() not compiled in." );
    665668    const char *pszGDAL_DRIVER_PATH =
    666669        CPLGetConfigOption( "GDAL_DRIVER_PATH", NULL );
    667670    if( pszGDAL_DRIVER_PATH == NULL )
    815818    }
    817820    CSLDestroy( papszSearchPath );
     822#endif  // GDAL_NO_AUTOLOAD
Last edited 13 months ago by Kurt Schwehr (previous) (diff)

comment:5 Changed 13 months ago by Kyle Shannon

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

comment:6 Changed 13 months ago by Kurt Schwehr

comment:7 Changed 13 months ago by Even Rouault

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