Fix openssh-8.7p1-scp-clears-file.patch

Related: rhbz#2056884

Signed-off-by: Zoltan Fridrich <zfridric@redhat.com>
This commit is contained in:
Zoltan Fridrich 2022-07-26 16:13:30 +02:00
parent 9591af3b1d
commit 1d30b84a88
2 changed files with 47 additions and 32 deletions

View File

@ -1,7 +1,7 @@
diff --color -ru a/scp.c b/scp.c diff --color -rup a/scp.c b/scp.c
--- a/scp.c 2022-06-30 09:47:39.529662574 +0200 --- a/scp.c 2022-07-26 14:51:40.560120817 +0200
+++ b/scp.c 2022-06-30 09:51:05.740719310 +0200 +++ b/scp.c 2022-07-26 14:52:37.118213004 +0200
@@ -1324,12 +1324,12 @@ @@ -1324,12 +1324,12 @@ source_sftp(int argc, char *src, char *t
if (src_is_dir && iamrecursive) { if (src_is_dir && iamrecursive) {
if (upload_dir(conn, src, abs_dst, pflag, if (upload_dir(conn, src, abs_dst, pflag,
@ -16,7 +16,7 @@ diff --color -ru a/scp.c b/scp.c
error("failed to upload file %s to %s", src, abs_dst); error("failed to upload file %s to %s", src, abs_dst);
errs = 1; errs = 1;
} }
@@ -1566,11 +1566,11 @@ @@ -1566,11 +1566,11 @@ sink_sftp(int argc, char *dst, const cha
debug("Fetching %s to %s\n", g.gl_pathv[i], abs_dst); debug("Fetching %s to %s\n", g.gl_pathv[i], abs_dst);
if (globpath_is_dir(g.gl_pathv[i]) && iamrecursive) { if (globpath_is_dir(g.gl_pathv[i]) && iamrecursive) {
if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL,
@ -30,10 +30,10 @@ diff --color -ru a/scp.c b/scp.c
err = -1; err = -1;
} }
free(abs_dst); free(abs_dst);
diff --color -ru a/sftp.c b/sftp.c diff --color -rup a/sftp.c b/sftp.c
--- a/sftp.c 2022-06-30 09:47:39.530662594 +0200 --- a/sftp.c 2022-07-26 14:51:40.561120836 +0200
+++ b/sftp.c 2022-06-30 09:52:05.118887441 +0200 +++ b/sftp.c 2022-07-26 14:52:37.119213023 +0200
@@ -666,12 +666,12 @@ @@ -666,12 +666,12 @@ process_get(struct sftp_conn *conn, cons
if (globpath_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { if (globpath_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL,
pflag || global_pflag, 1, resume, pflag || global_pflag, 1, resume,
@ -48,7 +48,7 @@ diff --color -ru a/sftp.c b/sftp.c
err = -1; err = -1;
} }
free(abs_dst); free(abs_dst);
@@ -760,12 +760,12 @@ @@ -760,12 +760,12 @@ process_put(struct sftp_conn *conn, cons
if (globpath_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) { if (globpath_is_dir(g.gl_pathv[i]) && (rflag || global_rflag)) {
if (upload_dir(conn, g.gl_pathv[i], abs_dst, if (upload_dir(conn, g.gl_pathv[i], abs_dst,
pflag || global_pflag, 1, resume, pflag || global_pflag, 1, resume,
@ -63,10 +63,10 @@ diff --color -ru a/sftp.c b/sftp.c
err = -1; err = -1;
} }
} }
diff --color -ru a/sftp-client.c b/sftp-client.c diff --color -rup a/sftp-client.c b/sftp-client.c
--- a/sftp-client.c 2022-06-30 09:47:39.530662594 +0200 --- a/sftp-client.c 2022-07-26 14:51:40.561120836 +0200
+++ b/sftp-client.c 2022-06-30 10:03:36.608473570 +0200 +++ b/sftp-client.c 2022-07-26 15:09:54.825295533 +0200
@@ -1454,7 +1454,7 @@ @@ -1454,7 +1454,7 @@ progress_meter_path(const char *path)
int int
do_download(struct sftp_conn *conn, const char *remote_path, do_download(struct sftp_conn *conn, const char *remote_path,
const char *local_path, Attrib *a, int preserve_flag, int resume_flag, const char *local_path, Attrib *a, int preserve_flag, int resume_flag,
@ -75,7 +75,18 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
{ {
struct sshbuf *msg; struct sshbuf *msg;
u_char *handle; u_char *handle;
@@ -1661,8 +1661,11 @@ @@ -1498,8 +1498,8 @@ do_download(struct sftp_conn *conn, cons
&handle, &handle_len) != 0)
return -1;
- local_fd = open(local_path,
- O_WRONLY | O_CREAT | (resume_flag ? 0 : O_TRUNC), mode | S_IWUSR);
+ local_fd = open(local_path, O_WRONLY | O_CREAT |
+ ((resume_flag || inplace_flag) ? 0 : O_TRUNC), mode | S_IWUSR);
if (local_fd == -1) {
error("Couldn't open local file \"%s\" for writing: %s",
local_path, strerror(errno));
@@ -1661,8 +1661,11 @@ do_download(struct sftp_conn *conn, cons
/* Sanity check */ /* Sanity check */
if (TAILQ_FIRST(&requests) != NULL) if (TAILQ_FIRST(&requests) != NULL)
fatal("Transfer complete, but requests still in queue"); fatal("Transfer complete, but requests still in queue");
@ -89,7 +100,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
if (reordered && resume_flag) { if (reordered && resume_flag) {
error("Unable to resume download of \"%s\": " error("Unable to resume download of \"%s\": "
"server reordered requests", local_path); "server reordered requests", local_path);
@@ -1724,7 +1727,7 @@ @@ -1724,7 +1727,7 @@ do_download(struct sftp_conn *conn, cons
static int static int
download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst,
int depth, Attrib *dirattrib, int preserve_flag, int print_flag, int depth, Attrib *dirattrib, int preserve_flag, int print_flag,
@ -98,7 +109,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
{ {
int i, ret = 0; int i, ret = 0;
SFTP_DIRENT **dir_entries; SFTP_DIRENT **dir_entries;
@@ -1781,7 +1784,7 @@ @@ -1781,7 +1784,7 @@ download_dir_internal(struct sftp_conn *
if (download_dir_internal(conn, new_src, new_dst, if (download_dir_internal(conn, new_src, new_dst,
depth + 1, &(dir_entries[i]->a), preserve_flag, depth + 1, &(dir_entries[i]->a), preserve_flag,
print_flag, resume_flag, print_flag, resume_flag,
@ -107,7 +118,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
ret = -1; ret = -1;
} else if (S_ISREG(dir_entries[i]->a.perm) || } else if (S_ISREG(dir_entries[i]->a.perm) ||
(follow_link_flag && S_ISLNK(dir_entries[i]->a.perm))) { (follow_link_flag && S_ISLNK(dir_entries[i]->a.perm))) {
@@ -1793,7 +1796,8 @@ @@ -1793,7 +1796,8 @@ download_dir_internal(struct sftp_conn *
if (do_download(conn, new_src, new_dst, if (do_download(conn, new_src, new_dst,
S_ISLNK(dir_entries[i]->a.perm) ? NULL : S_ISLNK(dir_entries[i]->a.perm) ? NULL :
&(dir_entries[i]->a), &(dir_entries[i]->a),
@ -117,7 +128,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
error("Download of file %s to %s failed", error("Download of file %s to %s failed",
new_src, new_dst); new_src, new_dst);
ret = -1; ret = -1;
@@ -1831,7 +1835,7 @@ @@ -1831,7 +1835,7 @@ download_dir_internal(struct sftp_conn *
int int
download_dir(struct sftp_conn *conn, const char *src, const char *dst, download_dir(struct sftp_conn *conn, const char *src, const char *dst,
Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag, Attrib *dirattrib, int preserve_flag, int print_flag, int resume_flag,
@ -126,7 +137,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
{ {
char *src_canon; char *src_canon;
int ret; int ret;
@@ -1843,26 +1847,25 @@ @@ -1843,26 +1847,25 @@ download_dir(struct sftp_conn *conn, con
ret = download_dir_internal(conn, src_canon, dst, 0, ret = download_dir_internal(conn, src_canon, dst, 0,
dirattrib, preserve_flag, print_flag, resume_flag, fsync_flag, dirattrib, preserve_flag, print_flag, resume_flag, fsync_flag,
@ -161,7 +172,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
struct request *ack = NULL; struct request *ack = NULL;
struct requests acks; struct requests acks;
size_t handle_len; size_t handle_len;
@@ -1913,10 +1916,15 @@ @@ -1913,10 +1916,15 @@ do_upload(struct sftp_conn *conn, const
} }
} }
@ -180,7 +191,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
close(local_fd); close(local_fd);
return -1; return -1;
} }
@@ -1999,6 +2007,12 @@ @@ -1999,6 +2007,12 @@ do_upload(struct sftp_conn *conn, const
ack->id, ack->len, (unsigned long long)ack->offset); ack->id, ack->len, (unsigned long long)ack->offset);
++ackid; ++ackid;
progress_counter += ack->len; progress_counter += ack->len;
@ -193,7 +204,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
free(ack); free(ack);
} }
offset += len; offset += len;
@@ -2017,6 +2031,14 @@ @@ -2017,6 +2031,14 @@ do_upload(struct sftp_conn *conn, const
status = SSH2_FX_FAILURE; status = SSH2_FX_FAILURE;
} }
@ -208,7 +219,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
if (close(local_fd) == -1) { if (close(local_fd) == -1) {
error("Couldn't close local file \"%s\": %s", local_path, error("Couldn't close local file \"%s\": %s", local_path,
strerror(errno)); strerror(errno));
@@ -2041,7 +2063,7 @@ @@ -2041,7 +2063,7 @@ do_upload(struct sftp_conn *conn, const
static int static int
upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst,
int depth, int preserve_flag, int print_flag, int resume, int fsync_flag, int depth, int preserve_flag, int print_flag, int resume, int fsync_flag,
@ -217,7 +228,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
{ {
int ret = 0; int ret = 0;
DIR *dirp; DIR *dirp;
@@ -2119,12 +2141,13 @@ @@ -2119,12 +2141,13 @@ upload_dir_internal(struct sftp_conn *co
if (upload_dir_internal(conn, new_src, new_dst, if (upload_dir_internal(conn, new_src, new_dst,
depth + 1, preserve_flag, print_flag, resume, depth + 1, preserve_flag, print_flag, resume,
@ -233,7 +244,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
error("Uploading of file %s to %s failed!", error("Uploading of file %s to %s failed!",
new_src, new_dst); new_src, new_dst);
ret = -1; ret = -1;
@@ -2144,7 +2167,7 @@ @@ -2144,7 +2167,7 @@ upload_dir_internal(struct sftp_conn *co
int int
upload_dir(struct sftp_conn *conn, const char *src, const char *dst, upload_dir(struct sftp_conn *conn, const char *src, const char *dst,
int preserve_flag, int print_flag, int resume, int fsync_flag, int preserve_flag, int print_flag, int resume, int fsync_flag,
@ -242,7 +253,7 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
{ {
char *dst_canon; char *dst_canon;
int ret; int ret;
@@ -2155,7 +2178,7 @@ @@ -2155,7 +2178,7 @@ upload_dir(struct sftp_conn *conn, const
} }
ret = upload_dir_internal(conn, src, dst_canon, 0, preserve_flag, ret = upload_dir_internal(conn, src, dst_canon, 0, preserve_flag,
@ -251,10 +262,10 @@ diff --color -ru a/sftp-client.c b/sftp-client.c
free(dst_canon); free(dst_canon);
return ret; return ret;
diff --color -ru a/sftp-client.h b/sftp-client.h diff --color -rup a/sftp-client.h b/sftp-client.h
--- a/sftp-client.h 2022-06-30 09:47:39.530662594 +0200 --- a/sftp-client.h 2022-07-26 14:51:40.561120836 +0200
+++ b/sftp-client.h 2022-06-30 10:05:50.835107759 +0200 +++ b/sftp-client.h 2022-07-26 14:52:37.120213042 +0200
@@ -138,28 +138,29 @@ @@ -138,28 +138,29 @@ int do_fsync(struct sftp_conn *conn, u_c
* Download 'remote_path' to 'local_path'. Preserve permissions and times * Download 'remote_path' to 'local_path'. Preserve permissions and times
* if 'pflag' is set * if 'pflag' is set
*/ */

View File

@ -51,7 +51,7 @@
# Do not forget to bump pam_ssh_agent_auth release if you rewind the main package release to 1 # Do not forget to bump pam_ssh_agent_auth release if you rewind the main package release to 1
%global openssh_ver 8.7p1 %global openssh_ver 8.7p1
%global openssh_rel 19 %global openssh_rel 20
%global pam_ssh_agent_ver 0.10.4 %global pam_ssh_agent_ver 0.10.4
%global pam_ssh_agent_rel 5 %global pam_ssh_agent_rel 5
@ -728,6 +728,10 @@ test -f %{sysconfig_anaconda} && \
%endif %endif
%changelog %changelog
* Tue Jul 26 2022 Zoltan Fridrich <zfridric@redhat.com> - 8.7p1-20 + 0.10.4-5
- Fix openssh-8.7p1-scp-clears-file.patch
Related: rhbz#2056884
* Fri Jul 15 2022 Dmitry Belyavskiy <dbelyavs@redhat.com> - 8.7p1-19 + 0.10.4-5 * Fri Jul 15 2022 Dmitry Belyavskiy <dbelyavs@redhat.com> - 8.7p1-19 + 0.10.4-5
- FIX pam_ssh_agent_auth auth for RSA keys - FIX pam_ssh_agent_auth auth for RSA keys
Related: rhbz#2070113 Related: rhbz#2070113