[openssh-commits] [openssh] 02/02: upstream: same treatment for remote/remote copies (i.e. scp -3):

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Feb 18 14:04:52 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 84206bde8adbef2dfe4f5b97dd23399827015333
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed Feb 18 03:04:12 2026 +0000

    upstream: same treatment for remote/remote copies (i.e. scp -3):
    
    adjust permissions on destination directory only if we created it or -p was
    requested. bz3925
    
    OpenBSD-Commit-ID: d977006df7b8330e06ceaa319383b347f1aca3ef
---
 sftp-client.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sftp-client.c b/sftp-client.c
index ab33bdb8a..7cc20f34d 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp-client.c,v 1.183 2026/02/18 02:59:27 djm Exp $ */
+/* $OpenBSD: sftp-client.c,v 1.184 2026/02/18 03:04:12 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
  *
@@ -2693,7 +2693,7 @@ crossload_dir_internal(struct sftp_conn *from, struct sftp_conn *to,
     int depth, Attrib *dirattrib, int preserve_flag, int print_flag,
     int follow_link_flag)
 {
-	int i, ret = 0;
+	int i, ret = 0, created = 0;
 	SFTP_DIRENT **dir_entries;
 	char *filename, *new_from_path = NULL, *new_to_path = NULL;
 	mode_t mode = 0777;
@@ -2739,7 +2739,9 @@ crossload_dir_internal(struct sftp_conn *from, struct sftp_conn *to,
 	 * the path already existed and is a directory.  Ensure we can
 	 * write to the directory we create for the duration of the transfer.
 	 */
-	if (sftp_mkdir(to, to_path, &curdir, 0) != 0) {
+	if (sftp_mkdir(to, to_path, &curdir, 0) == 0)
+		created = 1;
+	else {
 		if (sftp_stat(to, to_path, 0, &newdir) != 0)
 			return -1;
 		if (!S_ISDIR(newdir.perm)) {
@@ -2801,7 +2803,8 @@ crossload_dir_internal(struct sftp_conn *from, struct sftp_conn *to,
 	free(new_to_path);
 	free(new_from_path);
 
-	sftp_setstat(to, to_path, &curdir);
+	if (created || preserve_flag)
+		sftp_setstat(to, to_path, &curdir);
 
 	sftp_free_dirents(dir_entries);
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list