List:Commits« Previous MessageNext Message »
From:Alfranio Correia Date:February 10 2009 10:07am
Subject:Re: bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)
Bug#38174
View as plain text  
Sorry, I overgeneralized. I thought that the solution below would me
more secure but
I was not aware of the possible restrictions on opt_secure_file_priv. So
disregard it.

I am creating a new patch asap.


Regards.


Sergei Golubchik wrote:
> Hi, Alfranio!
>
> On Feb 09, Alfranio Correia wrote:
>   
>>  2768 Alfranio Correia	2009-02-09
>>       BUG#38174 secure-file-priv breaks LOAD DATA INFILE replication in statement
> mode
>>             
>> === modified file 'sql/log_event.cc'
>> --- a/sql/log_event.cc	2009-02-04 11:08:27 +0000
>> +++ b/sql/log_event.cc	2009-02-09 21:38:38 +0000
>> @@ -349,12 +348,13 @@ static char *pretty_print_str(char *pack
>>    @return
>>      Pointer to start of extension
>>  */
>> -
>>  static char *slave_load_file_stem(char *buf, uint file_id,
>>                                    int event_server_id, const char *ext)
>>  {
>>    char *res;
>> -  fn_format(buf,"SQL_LOAD-",slave_load_tmpdir, "", MY_UNPACK_FILENAME);
>> +  fn_format(buf, PREFIX_SQL_LOAD, 
>> +            (opt_secure_file_priv ? opt_secure_file_priv : slave_load_tmpdir), 
>> +            "", MY_UNPACK_FILENAME);
>>     
>
> No, why ? This should be slave_load_tmpdir as before.
> There's no guarantee that opt_secure_file_priv directory is writable, it
> doesn't necessarily have to be.
>   
Ok !!! I did not
>   
>>    to_unix_path(buf);
>>  
>>    buf = strend(buf);
>> @@ -382,7 +382,8 @@ static void cleanup_load_tmpdir()
>>    uint i;
>>    char fname[FN_REFLEN], prefbuf[31], *p;
>>  
>> -  if (!(dirp=my_dir(slave_load_tmpdir,MYF(MY_WME))))
>> +  if (!(dirp=my_dir((opt_secure_file_priv ? opt_secure_file_priv :
> slave_load_tmpdir),
>>     
>
> same here
>
>   
>> +                     MYF(MY_WME))))
>>      return;
>>  
>>    /* 
>> @@ -403,7 +404,9 @@ static void cleanup_load_tmpdir()
>>      file=dirp->dir_entry+i;
>>      if (is_prefix(file->name, prefbuf))
>>      {
>> -      fn_format(fname,file->name,slave_load_tmpdir,"",MY_UNPACK_FILENAME);
>> +      fn_format(fname,file->name,
>> +                (opt_secure_file_priv ? opt_secure_file_priv :
> slave_load_tmpdir),
>>     
>
> and here.
>
>   
>> +                "",MY_UNPACK_FILENAME);
>>        my_delete(fname, MYF(0));
>>      }
>>    }
>>
>> === modified file 'sql/sql_load.cc'
>> --- a/sql/sql_load.cc	2008-09-17 12:54:50 +0000
>> +++ b/sql/sql_load.cc	2009-02-09 21:38:38 +0000
>> @@ -310,14 +310,27 @@ int mysql_load(THD *thd,sql_exchange *ex
>>  	is_fifo = 1;
>>  #endif
>>  
>> -      if (opt_secure_file_priv &&
>> -          strncmp(opt_secure_file_priv, name, strlen(opt_secure_file_priv)))
>> +      if (opt_secure_file_priv) 
>>        {
>> -        /* Read only allowed from within dir specified by secure_file_priv */
>> -        my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
>> -        DBUG_RETURN(TRUE);
>> +        char buf[FN_REFLEN];
>> +        char *check_dir;
>> +        if (thd->slave_thread) 
>> +        {
>> +          fn_format(buf, PREFIX_SQL_LOAD, opt_secure_file_priv, "",
> MY_UNPACK_FILENAME);
>> +          to_unix_path(buf);
>> +          check_dir= buf;
>> +        }
>> +        else
>> +        {
>> +          check_dir= opt_secure_file_priv;
>> +        }
>> +        if (strncmp(check_dir, name, strlen(check_dir)))
>> +        {
>> +          /* Read only allowed from within dir specified by secure_file_priv */
>> +          my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--secure-file-priv");
>> +          DBUG_RETURN(TRUE);
>> +        }
>>     
>
> And here you don't check slave_load_tmpdir.
> Why you didn't use the solution we've discussed earlier ?
>
>   
>>        }
>>     
>
> Regards / Mit vielen Grüßen,
> Sergei
>
>   

Thread
bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)Bug#38174Alfranio Correia9 Feb
  • Re: bzr commit into mysql-5.1-bugteam branch(alfranio.correia:2768) Bug#38174Sergei Golubchik10 Feb
    • Re: bzr commit into mysql-5.1-bugteam branch (alfranio.correia:2768)Bug#38174Alfranio Correia10 Feb