Bugzilla – Attachment 3450 Details for
Bug 3222
get -r doesn't work because directories are created without write permissions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Ensure directory is writable and searchable for the duration of a recursive transfer
sftp-r-mode.patch (text/plain), 1.37 KB, created by
Darren Tucker
on 2020-10-21 13:38:40 AEDT
(
hide
)
Description:
Ensure directory is writable and searchable for the duration of a recursive transfer
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2020-10-21 13:38:40 AEDT
Size:
1.37 KB
patch
obsolete
>diff --git a/sftp-client.c b/sftp-client.c >index 6c2a4fb7..4f1849f3 100644 >--- a/sftp-client.c >+++ b/sftp-client.c >@@ -1496,7 +1496,7 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, > int i, ret = 0; > SFTP_DIRENT **dir_entries; > char *filename, *new_src = NULL, *new_dst = NULL; >- mode_t mode = 0777; >+ mode_t mode = 0777, tmpmode = mode; > > if (depth >= MAX_DIR_DEPTH) { > error("Maximum directory depth exceeded: %d levels", depth); >@@ -1515,14 +1515,15 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, > if (print_flag) > mprintf("Retrieving %s\n", src); > >- if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) >+ if (dirattrib->flags & SSH2_FILEXFER_ATTR_PERMISSIONS) { > mode = dirattrib->perm & 01777; >- else { >+ tmpmode = mode | (S_IWUSR|S_IXUSR); >+ } else { > debug("Server did not send permissions for " > "directory \"%s\"", dst); > } > >- if (mkdir(dst, mode) == -1 && errno != EEXIST) { >+ if (mkdir(dst, tmpmode) == -1 && errno != EEXIST) { > error("mkdir %s: %s", dst, strerror(errno)); > return -1; > } >@@ -1577,6 +1578,10 @@ download_dir_internal(struct sftp_conn *conn, const char *src, const char *dst, > "\"%s\"", dst); > } > >+ if (mode != tmpmode && chmod(dst, mode)) >+ error("Can't set final mode on \"%s\": %s", dst, >+ strerror(errno)); >+ > free_sftp_dirents(dir_entries); > > return ret;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 3222
:
3450
|
3451