diff options
author | Achim Leitner <git@fjl.de> | 2021-10-17 22:00:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-17 13:00:24 -0700 |
commit | 84498104bfe2a4662221992951e71d2a2f5ceffc (patch) | |
tree | 59e4082ada8eec3803d530c6dd43249ebcc6bd04 /receiver.c | |
parent | 378a0a634fa7dc71e2646b8eb88b46853fada463 (diff) | |
download | rsync-84498104bfe2a4662221992951e71d2a2f5ceffc.tar.gz |
Linux: Handle protected_regular in inplace writes (#241)
The Linux fs.protected_regular sysctl setting could cause rsync to fail to write a file in-place with the O_CREAT flag set, so the code now tries an open without O_CREAT when it might help to avoid an EACCES error. A testsuite script is included (and slightly improved by Wayne to ensure that it outputs a SKIP when fs.protected_regular is turned off).
Diffstat (limited to 'receiver.c')
-rw-r--r-- | receiver.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -835,6 +835,12 @@ int recv_files(int f_in, int f_out, char *local_name) if (inplace || one_inplace) { fnametmp = one_inplace ? partialptr : fname; fd2 = do_open(fnametmp, O_WRONLY|O_CREAT, 0600); +#ifdef linux + if (fd2 == -1 && errno == EACCES) { + /* Maybe the error was due to protected_regular setting? */ + fd2 = do_open(fname, O_WRONLY, 0600); + } +#endif if (fd2 == -1) { rsyserr(FERROR_XFER, errno, "open %s failed", full_fname(fnametmp)); |