mirror of
https://github.com/openbsd/src.git
synced 2026-04-27 23:56:05 +00:00
when uploading a directory using sftp/sftp (e.g. during a recursive
transfer), don't clobber the remote directory permissions unless either we created the directory during the transfer or the -p flag was set. bz3925 ok dtucker@
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp-client.c,v 1.182 2026/02/08 03:30:15 dtucker Exp $ */
|
||||
/* $OpenBSD: sftp-client.c,v 1.183 2026/02/18 02:59:27 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org>
|
||||
*
|
||||
@@ -2225,7 +2225,7 @@ 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 follow_link_flag, int inplace_flag)
|
||||
{
|
||||
int ret = 0;
|
||||
int created = 0, ret = 0;
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *filename, *new_src = NULL, *new_dst = NULL;
|
||||
@@ -2266,7 +2266,9 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst,
|
||||
*/
|
||||
saved_perm = a.perm;
|
||||
a.perm |= (S_IWUSR|S_IXUSR);
|
||||
if (sftp_mkdir(conn, dst, &a, 0) != 0) {
|
||||
if (sftp_mkdir(conn, dst, &a, 0) == 0)
|
||||
created = 1;
|
||||
else {
|
||||
if (sftp_stat(conn, dst, 0, &dirattrib) != 0)
|
||||
return -1;
|
||||
if (!S_ISDIR(dirattrib.perm)) {
|
||||
@@ -2330,7 +2332,8 @@ upload_dir_internal(struct sftp_conn *conn, const char *src, const char *dst,
|
||||
free(new_dst);
|
||||
free(new_src);
|
||||
|
||||
sftp_setstat(conn, dst, &a);
|
||||
if (created || preserve_flag)
|
||||
sftp_setstat(conn, dst, &a);
|
||||
|
||||
(void) closedir(dirp);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user