do not set O_TRUNC when opening destination file.

It prevents `mscp localhost:hoge ~/hoge` from truncating the source
file. See https://bugzilla.mindrot.org/show_bug.cgi?id=3431.

https://github.com/upa/mscp/issues/1
This commit is contained in:
Ryo Nakamura
2023-08-04 15:06:14 +09:00
parent 16f2f88cc9
commit 24c1bc9149
4 changed files with 33 additions and 8 deletions

View File

@@ -46,7 +46,11 @@ typedef struct mf_struct mf;
mf *mscp_open(const char *path, int flags, mode_t mode, sftp_session sftp);
void mscp_close(mf *f);
int mscp_lseek(mf *f, size_t off);
int mscp_chmod(const char *path, mode_t mode, sftp_session sftp);
/* mscp_setstat() involves chmod and truncate. It executes both at
* once via a single SFTP command (sftp_setstat()).
*/
int mscp_setstat(const char *path, mode_t mode, size_t size, sftp_session sftp);
/* remote glob */
int mscp_glob(const char *pattern, int flags, glob_t *pglob, sftp_session sftp);