Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ssh: add -d option to scp when copying directories #180

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lbajolet-hashicorp
Copy link
Contributor

The -d option of scp, as for the -t option, is an undocumented one, and is used for specifying that we are working in directory mode.

In effect, this flag ensures that the target is to be a directory, and implies that scp will check that the target directory exists before attempting to copy the contents of the source.

Adding this flag to the scp sink makes the communicator behave correctly in relation to the scp command as it would be used by clients, rejecting copies to a non-existent destination directory, rather than mistakenly creating it, partially (or completely) copying the source's contents, and potentially succeeding where it should not.

The -d option of scp, as for the -t option, is an undocumented one, and
is used for specifying that we are working in directory mode.

In effect, this flag ensures that the target is to be a directory, and
implies that scp will check that the target directory exists before
attempting to copy the contents of the source.

Adding this flag to the scp sink makes the communicator behave correctly
in relation to the scp command as it would be used by clients, rejecting
copies to a non-existent destination directory, rather than mistakenly
creating it, partially (or completely) copying the source's contents,
and potentially succeeding where it should not.
As with the directory upload, not specifying the -d option in scp when
uploading a file may result in uploading succeeding even when the
destination directory (if suffixed by a `/') succeeds, and makes the
resulting file upload take the name of the destination directory.

To avoid this problem, we add the option so that if the destination is
explicitely a directory, this does not succeed anymore.
@nywilken nywilken added the version/bump minor A PR that changes behavior or contains breaking changes template configuration options. label Jul 5, 2023
@nywilken nywilken added this to the 0.5.0 milestone Jul 5, 2023
@nywilken nywilken self-assigned this Jul 5, 2023
@nywilken nywilken removed this from the 0.5.0 milestone Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change bug Something isn't working version/bump minor A PR that changes behavior or contains breaking changes template configuration options.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants