~linuxjedi/drizzle/elliott-bug-653300

« back to all changes in this revision

Viewing changes to drizzled/sql_load.cc

  • Committer: lbieber
  • Date: 2010-09-26 03:23:39 UTC
  • mfrom: (1793.1.1 build)
  • Revision ID: lbieber@orisndriz08-20100926032339-59p5xxhkloa09759
Merge Monty - Beginning of catalog support, adds a default local catalog. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <fcntl.h>
32
32
#include <algorithm>
33
33
#include <climits>
 
34
#include <boost/filesystem.hpp>
34
35
 
 
36
namespace fs=boost::filesystem;
35
37
using namespace std;
36
38
namespace drizzled
37
39
{
258
260
#endif
259
261
    if (!internal::dirname_length(ex->file_name))
260
262
    {
261
 
      strcpy(name, data_home_real);
262
 
      strncat(name, tdb, FN_REFLEN-strlen(data_home_real)-1);
 
263
      strcpy(name, getDataHomeCatalog().c_str());
 
264
      strncat(name, "/", 1);
 
265
      strncat(name, tdb, FN_REFLEN-getDataHomeCatalog().size());
263
266
      (void) internal::fn_format(name, ex->file_name, name, "",
264
267
                       MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
265
268
    }
266
269
    else
267
270
    {
268
 
      (void) internal::fn_format(name, ex->file_name, data_home_real, "",
 
271
      (void) internal::fn_format(name, ex->file_name, getDataHomeCatalog().c_str(), "",
269
272
                       MY_RELATIVE_PATH | MY_UNPACK_FILENAME);
270
273
 
271
 
      if (opt_secure_file_priv &&
272
 
          strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
 
274
      if (opt_secure_file_priv)
273
275
      {
274
 
        /* Read only allowed from within dir specified by secure_file_priv */
275
 
        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
276
 
        return(true);
 
276
        fs::path secure_file_path(fs::system_complete(fs::path(opt_secure_file_priv)));
 
277
        fs::path target_path(fs::system_complete(fs::path(name)));
 
278
        if (target_path.file_string().substr(0, secure_file_path.file_string().size()) != secure_file_path.file_string())
 
279
        {
 
280
          /* Read only allowed from within dir specified by secure_file_priv */
 
281
          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
 
282
          return(true);
 
283
        }
277
284
      }
278
285
 
279
286
      struct stat stat_info;