mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-8743: protect myisam/aria MYD files and aria log files
This commit is contained in:
@@ -273,7 +273,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
|
||||
" file is probably in use by another process";
|
||||
uint new_cf_create_time_size, new_cf_changeable_size, new_block_size;
|
||||
my_off_t file_size;
|
||||
int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR;
|
||||
int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR | O_CLOEXEC;
|
||||
int error= CONTROL_FILE_UNKNOWN_ERROR;
|
||||
DBUG_ENTER("ma_control_file_open");
|
||||
|
||||
|
@@ -942,7 +942,7 @@ static File create_logfile_by_number_no_cache(uint32 file_no)
|
||||
/* TODO: add O_DIRECT to open flags (when buffer is aligned) */
|
||||
if ((file= mysql_file_create(key_file_translog,
|
||||
translog_filename_by_fileno(file_no, path),
|
||||
0, O_BINARY | O_RDWR, MYF(MY_WME))) < 0)
|
||||
0, O_BINARY | O_RDWR | O_CLOEXEC, MYF(MY_WME))) < 0)
|
||||
{
|
||||
DBUG_PRINT("error", ("Error %d during creating file '%s'", errno, path));
|
||||
translog_stop_writing();
|
||||
@@ -979,7 +979,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no)
|
||||
/* TODO: use mysql_file_create() */
|
||||
if ((file= mysql_file_open(key_file_translog,
|
||||
translog_filename_by_fileno(file_no, path),
|
||||
log_descriptor.open_flags,
|
||||
log_descriptor.open_flags | O_CLOEXEC,
|
||||
MYF(MY_WME))) < 0)
|
||||
{
|
||||
DBUG_PRINT("error", ("Error %d during opening file '%s'", errno, path));
|
||||
@@ -3263,7 +3263,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
|
||||
File fd;
|
||||
if ((fd= mysql_file_open(key_file_translog,
|
||||
translog_filename_by_fileno(file_no, path),
|
||||
O_RDONLY, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
|
||||
O_RDONLY | O_CLOEXEC, (no_errors ? MYF(0) : MYF(MY_WME)))) < 0)
|
||||
{
|
||||
my_errno= errno;
|
||||
DBUG_PRINT("error", ("Error %d during opening file #%d",
|
||||
|
@@ -1885,7 +1885,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share)
|
||||
DEBUG_SYNC_C("mi_open_datafile");
|
||||
info->dfile.file= share->bitmap.file.file=
|
||||
mysql_file_open(key_file_dfile, share->data_file_name.str,
|
||||
share->mode | O_SHARE, MYF(flags));
|
||||
share->mode | O_SHARE | O_CLOEXEC, MYF(flags));
|
||||
return info->dfile.file >= 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -1899,7 +1899,7 @@ int _ma_open_keyfile(MARIA_SHARE *share)
|
||||
mysql_mutex_lock(&share->intern_lock);
|
||||
share->kfile.file= mysql_file_open(key_file_kfile,
|
||||
share->unique_file_name.str,
|
||||
share->mode | O_SHARE | O_NOFOLLOW,
|
||||
share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
|
||||
MYF(MY_WME | MY_NOSYMLINKS));
|
||||
mysql_mutex_unlock(&share->intern_lock);
|
||||
return (share->kfile.file < 0);
|
||||
|
@@ -1249,7 +1249,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share)
|
||||
myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS: 0);
|
||||
DEBUG_SYNC_C("mi_open_datafile");
|
||||
info->dfile= mysql_file_open(mi_key_file_dfile, share->data_file_name,
|
||||
share->mode | O_SHARE, MYF(flags));
|
||||
share->mode | O_SHARE | O_CLOEXEC, MYF(flags));
|
||||
return info->dfile >= 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -1258,7 +1258,7 @@ int mi_open_keyfile(MYISAM_SHARE *share)
|
||||
{
|
||||
if ((share->kfile= mysql_file_open(mi_key_file_kfile,
|
||||
share->unique_file_name,
|
||||
share->mode | O_SHARE | O_NOFOLLOW,
|
||||
share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
|
||||
MYF(MY_NOSYMLINKS | MY_WME))) < 0)
|
||||
return 1;
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user