version 1.257, 2023/07/14 05:31:44 |
version 1.258, 2023/09/08 05:56:13 |
|
|
reminp, remoutp, pidp) < 0) |
reminp, remoutp, pidp) < 0) |
return NULL; |
return NULL; |
} |
} |
return do_init(*reminp, *remoutp, |
return sftp_init(*reminp, *remoutp, |
sftp_copy_buflen, sftp_nrequests, limit_kbps); |
sftp_copy_buflen, sftp_nrequests, limit_kbps); |
} |
} |
|
|
|
|
return xstrdup("."); |
return xstrdup("."); |
return xstrdup(path + 2 + nslash); |
return xstrdup(path + 2 + nslash); |
} |
} |
if (can_expand_path(conn)) |
if (sftp_can_expand_path(conn)) |
return do_expand_path(conn, path); |
return sftp_expand_path(conn, path); |
/* No protocol extension */ |
/* No protocol extension */ |
error("server expand-path extension is required " |
error("server expand-path extension is required " |
"for ~user paths in SFTP mode"); |
"for ~user paths in SFTP mode"); |
|
|
*/ |
*/ |
if ((target = prepare_remote_path(conn, targ)) == NULL) |
if ((target = prepare_remote_path(conn, targ)) == NULL) |
cleanup_exit(255); |
cleanup_exit(255); |
target_is_dir = remote_is_dir(conn, target); |
target_is_dir = sftp_remote_is_dir(conn, target); |
if (targetshouldbedirectory && !target_is_dir) { |
if (targetshouldbedirectory && !target_is_dir) { |
debug("target directory \"%s\" does not exist", target); |
debug("target directory \"%s\" does not exist", target); |
a.flags = SSH2_FILEXFER_ATTR_PERMISSIONS; |
a.flags = SSH2_FILEXFER_ATTR_PERMISSIONS; |
a.perm = st.st_mode | 0700; /* ensure writable */ |
a.perm = st.st_mode | 0700; /* ensure writable */ |
if (do_mkdir(conn, target, &a, 1) != 0) |
if (sftp_mkdir(conn, target, &a, 1) != 0) |
cleanup_exit(255); /* error already logged */ |
cleanup_exit(255); /* error already logged */ |
target_is_dir = 1; |
target_is_dir = 1; |
} |
} |
if (target_is_dir) |
if (target_is_dir) |
abs_dst = path_append(target, filename); |
abs_dst = sftp_path_append(target, filename); |
else { |
else { |
abs_dst = target; |
abs_dst = target; |
target = NULL; |
target = NULL; |
|
|
debug3_f("copying local %s to remote %s", src, abs_dst); |
debug3_f("copying local %s to remote %s", src, abs_dst); |
|
|
if (src_is_dir && iamrecursive) { |
if (src_is_dir && iamrecursive) { |
if (upload_dir(conn, src, abs_dst, pflag, |
if (sftp_upload_dir(conn, src, abs_dst, pflag, |
SFTP_PROGRESS_ONLY, 0, 0, 1, 1) != 0) { |
SFTP_PROGRESS_ONLY, 0, 0, 1, 1) != 0) { |
error("failed to upload directory %s to %s", src, targ); |
error("failed to upload directory %s to %s", src, targ); |
errs = 1; |
errs = 1; |
} |
} |
} else if (do_upload(conn, src, abs_dst, pflag, 0, 0, 1) != 0) { |
} else if (sftp_upload(conn, src, abs_dst, pflag, 0, 0, 1) != 0) { |
error("failed to upload file %s to %s", src, targ); |
error("failed to upload file %s to %s", src, targ); |
errs = 1; |
errs = 1; |
} |
} |
|
|
* a GLOB_NOCHECK result. Check whether the unglobbed path |
* a GLOB_NOCHECK result. Check whether the unglobbed path |
* exists so we can give a nice error message early. |
* exists so we can give a nice error message early. |
*/ |
*/ |
if (do_stat(conn, g.gl_pathv[0], 1) == NULL) { |
if (sftp_stat(conn, g.gl_pathv[0], 1, NULL) != 0) { |
error("%s: %s", src, strerror(ENOENT)); |
error("%s: %s", src, strerror(ENOENT)); |
err = -1; |
err = -1; |
goto out; |
goto out; |
|
|
} |
} |
|
|
if (dst_is_dir) |
if (dst_is_dir) |
abs_dst = path_append(dst, filename); |
abs_dst = sftp_path_append(dst, filename); |
else |
else |
abs_dst = xstrdup(dst); |
abs_dst = xstrdup(dst); |
|
|
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 (sftp_globpath_is_dir(g.gl_pathv[i]) && iamrecursive) { |
if (download_dir(conn, g.gl_pathv[i], abs_dst, NULL, |
if (sftp_download_dir(conn, g.gl_pathv[i], abs_dst, |
pflag, SFTP_PROGRESS_ONLY, 0, 0, 1, 1) == -1) |
NULL, pflag, SFTP_PROGRESS_ONLY, 0, 0, 1, 1) == -1) |
err = -1; |
err = -1; |
} else { |
} else { |
if (do_download(conn, g.gl_pathv[i], abs_dst, NULL, |
if (sftp_download(conn, g.gl_pathv[i], abs_dst, NULL, |
pflag, 0, 0, 1) == -1) |
pflag, 0, 0, 1) == -1) |
err = -1; |
err = -1; |
} |
} |
|
|
cleanup_exit(255); |
cleanup_exit(255); |
memset(&g, 0, sizeof(g)); |
memset(&g, 0, sizeof(g)); |
|
|
targetisdir = remote_is_dir(to, target); |
targetisdir = sftp_remote_is_dir(to, target); |
if (!targetisdir && targetshouldbedirectory) { |
if (!targetisdir && targetshouldbedirectory) { |
error("%s: destination is not a directory", targ); |
error("%s: destination is not a directory", targ); |
err = -1; |
err = -1; |
|
|
* a GLOB_NOCHECK result. Check whether the unglobbed path |
* a GLOB_NOCHECK result. Check whether the unglobbed path |
* exists so we can give a nice error message early. |
* exists so we can give a nice error message early. |
*/ |
*/ |
if (do_stat(from, g.gl_pathv[0], 1) == NULL) { |
if (sftp_stat(from, g.gl_pathv[0], 1, NULL) != 0) { |
error("%s: %s", src, strerror(ENOENT)); |
error("%s: %s", src, strerror(ENOENT)); |
err = -1; |
err = -1; |
goto out; |
goto out; |
|
|
} |
} |
|
|
if (targetisdir) |
if (targetisdir) |
abs_dst = path_append(target, filename); |
abs_dst = sftp_path_append(target, filename); |
else |
else |
abs_dst = xstrdup(target); |
abs_dst = xstrdup(target); |
|
|
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 (sftp_globpath_is_dir(g.gl_pathv[i]) && iamrecursive) { |
if (crossload_dir(from, to, g.gl_pathv[i], abs_dst, |
if (sftp_crossload_dir(from, to, g.gl_pathv[i], abs_dst, |
NULL, pflag, SFTP_PROGRESS_ONLY, 1) == -1) |
NULL, pflag, SFTP_PROGRESS_ONLY, 1) == -1) |
err = -1; |
err = -1; |
} else { |
} else { |
if (do_crossload(from, to, g.gl_pathv[i], abs_dst, NULL, |
if (sftp_crossload(from, to, g.gl_pathv[i], abs_dst, |
pflag) == -1) |
NULL, pflag) == -1) |
err = -1; |
err = -1; |
} |
} |
free(abs_dst); |
free(abs_dst); |