mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 02:38:09 +09:00
sftpserver.c: Add support for O_TRUNC while opening files
Signed-off-by: Eshan Kelkar <eshankelkar@galorithm.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
committed by
Jakub Jelen
parent
6c4e4a9e1c
commit
a59d587060
@@ -882,17 +882,26 @@ process_open(sftp_client_message client_msg)
|
|||||||
SSH_LOG(SSH_LOG_PROTOCOL, "Processing open: filename %s, mode=0%o" PRIu32,
|
SSH_LOG(SSH_LOG_PROTOCOL, "Processing open: filename %s, mode=0%o" PRIu32,
|
||||||
filename, mode);
|
filename, mode);
|
||||||
|
|
||||||
if (((msg_flag & (uint32_t)SSH_FXF_READ) == SSH_FXF_READ) &&
|
if ((msg_flag & (uint32_t)SSH_FXF_WRITE) == SSH_FXF_WRITE) {
|
||||||
((msg_flag & (uint32_t)SSH_FXF_WRITE) == SSH_FXF_WRITE)) {
|
if ((msg_flag & (uint32_t)SSH_FXF_READ) == SSH_FXF_READ) {
|
||||||
file_flag = O_RDWR; // file must exist
|
/* Both read and write */
|
||||||
if ((msg_flag & (uint32_t)SSH_FXF_CREAT) == SSH_FXF_CREAT)
|
file_flag = O_RDWR;
|
||||||
file_flag |= O_CREAT;
|
} else {
|
||||||
} else if ((msg_flag & (uint32_t)SSH_FXF_WRITE) == SSH_FXF_WRITE) {
|
/* Only write */
|
||||||
file_flag = O_WRONLY;
|
file_flag = O_WRONLY;
|
||||||
if ((msg_flag & (uint32_t)SSH_FXF_APPEND) == SSH_FXF_APPEND)
|
}
|
||||||
|
|
||||||
|
if ((msg_flag & (uint32_t)SSH_FXF_APPEND) == SSH_FXF_APPEND) {
|
||||||
file_flag |= O_APPEND;
|
file_flag |= O_APPEND;
|
||||||
if ((msg_flag & (uint32_t)SSH_FXF_CREAT) == SSH_FXF_CREAT)
|
}
|
||||||
|
|
||||||
|
if ((msg_flag & (uint32_t)SSH_FXF_CREAT) == SSH_FXF_CREAT) {
|
||||||
file_flag |= O_CREAT;
|
file_flag |= O_CREAT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((msg_flag & (uint32_t)SSH_FXF_TRUNC) == SSH_FXF_TRUNC) {
|
||||||
|
file_flag |= O_TRUNC;
|
||||||
|
}
|
||||||
} else if ((msg_flag & (uint32_t)SSH_FXF_READ) == SSH_FXF_READ) {
|
} else if ((msg_flag & (uint32_t)SSH_FXF_READ) == SSH_FXF_READ) {
|
||||||
file_flag = O_RDONLY;
|
file_flag = O_RDONLY;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user