1
0
mirror of https://github.com/containers/youki synced 2024-11-22 17:02:00 +01:00

Don't create a file when it already exists when mounting with bind (#2031)

For example, it is more likely that the /etc/hosts file already exists. In that case, it fails because it tries to open the file with write permission while it is RO.

Signed-off-by: utam0k <k0ma@utam0k.jp>
This commit is contained in:
Toru Komatsu 2023-06-12 13:50:53 +09:00 committed by GitHub
parent 3251599f0f
commit f5f2242f85
Signed by: GitHub
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 3 deletions

@ -497,7 +497,7 @@ impl Mount {
err
})?;
if src.is_file() {
if src.is_file() && !dest.exists() {
OpenOptions::new()
.create(true)
.write(true)

@ -78,8 +78,6 @@ tracepoint:syscalls:sys_enter_setresuid
printf("ruid=%d, euid=%d, suid=%d\n", args->ruid, args->euid, args->suid);
}
END
{
clear(@filename);