|
23 | 23 | namespace CoSimIO { |
24 | 24 | namespace Internals { |
25 | 25 |
|
| 26 | +void AddFilePermissions(const fs::path& rPath) |
| 27 | +{ |
| 28 | + CO_SIM_IO_TRY |
| 29 | + |
| 30 | + fs::permissions(rPath, |
| 31 | + fs::perms::owner_read | fs::perms::owner_write | |
| 32 | + fs::perms::group_read | fs::perms::group_write | |
| 33 | + fs::perms::others_read | fs::perms::others_write, |
| 34 | + fs::perm_options::add); |
| 35 | + |
| 36 | + CO_SIM_IO_CATCH |
| 37 | +} |
| 38 | + |
26 | 39 | Communication::Communication( |
27 | 40 | const Info& I_Settings, |
28 | 41 | std::shared_ptr<DataCommunicator> I_DataComm) |
@@ -139,6 +152,7 @@ void Communication::BaseConnectDetail(const Info& I_Info) |
139 | 152 | CO_SIM_IO_INFO_IF("CoSimIO", ec) << "Warning, communication directory (" << mCommFolder << ") could not be deleted!\nError code: " << ec.message() << std::endl; |
140 | 153 | if (!fs::exists(mCommFolder)) { |
141 | 154 | fs::create_directory(mCommFolder); |
| 155 | + AddFilePermissions(mCommFolder); // otherwise the process with lower rights cannot delete files in it |
142 | 156 | } |
143 | 157 | } |
144 | 158 |
|
@@ -356,10 +370,13 @@ void Communication::MakeFileVisible( |
356 | 370 | CO_SIM_IO_TRY |
357 | 371 |
|
358 | 372 | if (!UseAuxFileForFileAvailability) { |
| 373 | + const fs::path tmp_file_name = GetTempFileName(rPath, UseAuxFileForFileAvailability); |
| 374 | + AddFilePermissions(tmp_file_name); |
359 | 375 | std::error_code ec; |
360 | | - fs::rename(GetTempFileName(rPath, UseAuxFileForFileAvailability), rPath, ec); |
| 376 | + fs::rename(tmp_file_name, rPath, ec); |
361 | 377 | CO_SIM_IO_ERROR_IF(ec) << rPath << " could not be made visible!\nError code: " << ec.message() << std::endl; |
362 | 378 | } else { |
| 379 | + AddFilePermissions(rPath); |
363 | 380 | std::ofstream avail_file; |
364 | 381 | avail_file.open(rPath.string() + ".avail"); |
365 | 382 | avail_file.close(); |
|
0 commit comments