func (sess *session) executeSCP(command string, request *ssh.Request) {
	logger := sess.logger.Session("execute-scp")

	if request.WantReply {
		request.Reply(true, nil)
	}

	copier, err := scp.NewFromCommand(command, sess.channel, sess.channel, sess.channel.Stderr(), logger)
	if err == nil {
		err = copier.Copy()
	}

	sess.sendSCPExitMessage(err)
	sess.destroy()
}
Esempio n. 2
0
		targetDir, err = ioutil.TempDir("", "scp-target")
		Expect(err).NotTo(HaveOccurred())

		secureCopier = nil
	})

	AfterEach(func() {
		os.RemoveAll(sourceDir)
		os.RemoveAll(targetDir)
	})

	Context("source mode", func() {
		var preserveTimestamps bool
		Context("when no files are requested", func() {
			It("fails construct the copier", func() {
				_, err := scp.NewFromCommand("scp -f", stdin, stdout, stderr, logger)
				Expect(err).To(HaveOccurred())
			})
		})

		Context("when files are requested", func() {
			var sourceFileInfo os.FileInfo

			BeforeEach(func() {
				preserveTimestamps = false
			})

			Context("when the requested file exists", func() {
				JustBeforeEach(func() {
					var err error