Commit 88fb8b2e authored by Daniel Black's avatar Daniel Black

MDEV-8743: protect myisam/aria MYD files and aria log files

parent c54c490c
...@@ -273,7 +273,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing, ...@@ -273,7 +273,7 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
" file is probably in use by another process"; " file is probably in use by another process";
uint new_cf_create_time_size, new_cf_changeable_size, new_block_size; uint new_cf_create_time_size, new_cf_changeable_size, new_block_size;
my_off_t file_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; int error= CONTROL_FILE_UNKNOWN_ERROR;
DBUG_ENTER("ma_control_file_open"); DBUG_ENTER("ma_control_file_open");
......
...@@ -942,7 +942,7 @@ static File create_logfile_by_number_no_cache(uint32 file_no) ...@@ -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) */ /* TODO: add O_DIRECT to open flags (when buffer is aligned) */
if ((file= mysql_file_create(key_file_translog, if ((file= mysql_file_create(key_file_translog,
translog_filename_by_fileno(file_no, path), 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)); DBUG_PRINT("error", ("Error %d during creating file '%s'", errno, path));
translog_stop_writing(); translog_stop_writing();
...@@ -979,7 +979,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no) ...@@ -979,7 +979,7 @@ static File open_logfile_by_number_no_cache(uint32 file_no)
/* TODO: use mysql_file_create() */ /* TODO: use mysql_file_create() */
if ((file= mysql_file_open(key_file_translog, if ((file= mysql_file_open(key_file_translog,
translog_filename_by_fileno(file_no, path), translog_filename_by_fileno(file_no, path),
log_descriptor.open_flags, log_descriptor.open_flags | O_CLOEXEC,
MYF(MY_WME))) < 0) MYF(MY_WME))) < 0)
{ {
DBUG_PRINT("error", ("Error %d during opening file '%s'", errno, path)); 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, ...@@ -3263,7 +3263,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr,
File fd; File fd;
if ((fd= mysql_file_open(key_file_translog, if ((fd= mysql_file_open(key_file_translog,
translog_filename_by_fileno(file_no, path), 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; my_errno= errno;
DBUG_PRINT("error", ("Error %d during opening file #%d", DBUG_PRINT("error", ("Error %d during opening file #%d",
......
...@@ -1885,7 +1885,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share) ...@@ -1885,7 +1885,7 @@ int _ma_open_datafile(MARIA_HA *info, MARIA_SHARE *share)
DEBUG_SYNC_C("mi_open_datafile"); DEBUG_SYNC_C("mi_open_datafile");
info->dfile.file= share->bitmap.file.file= info->dfile.file= share->bitmap.file.file=
mysql_file_open(key_file_dfile, share->data_file_name.str, 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; return info->dfile.file >= 0 ? 0 : 1;
} }
...@@ -1899,7 +1899,7 @@ int _ma_open_keyfile(MARIA_SHARE *share) ...@@ -1899,7 +1899,7 @@ int _ma_open_keyfile(MARIA_SHARE *share)
mysql_mutex_lock(&share->intern_lock); mysql_mutex_lock(&share->intern_lock);
share->kfile.file= mysql_file_open(key_file_kfile, share->kfile.file= mysql_file_open(key_file_kfile,
share->unique_file_name.str, share->unique_file_name.str,
share->mode | O_SHARE | O_NOFOLLOW, share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
MYF(MY_WME | MY_NOSYMLINKS)); MYF(MY_WME | MY_NOSYMLINKS));
mysql_mutex_unlock(&share->intern_lock); mysql_mutex_unlock(&share->intern_lock);
return (share->kfile.file < 0); return (share->kfile.file < 0);
......
...@@ -1249,7 +1249,7 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share) ...@@ -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); myf flags= MY_WME | (share->mode & O_NOFOLLOW ? MY_NOSYMLINKS: 0);
DEBUG_SYNC_C("mi_open_datafile"); DEBUG_SYNC_C("mi_open_datafile");
info->dfile= mysql_file_open(mi_key_file_dfile, share->data_file_name, 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; return info->dfile >= 0 ? 0 : 1;
} }
...@@ -1258,7 +1258,7 @@ int mi_open_keyfile(MYISAM_SHARE *share) ...@@ -1258,7 +1258,7 @@ int mi_open_keyfile(MYISAM_SHARE *share)
{ {
if ((share->kfile= mysql_file_open(mi_key_file_kfile, if ((share->kfile= mysql_file_open(mi_key_file_kfile,
share->unique_file_name, share->unique_file_name,
share->mode | O_SHARE | O_NOFOLLOW, share->mode | O_SHARE | O_NOFOLLOW | O_CLOEXEC,
MYF(MY_NOSYMLINKS | MY_WME))) < 0) MYF(MY_NOSYMLINKS | MY_WME))) < 0)
return 1; return 1;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment