Bug 3135

Summary: SFTP Assumes quiet in batch mode - This regression breaks integration
Product: Portable OpenSSH Reporter: Matthew Parslow <matt>
Component: sftpAssignee: Damien Miller <djm>
Status: CLOSED FIXED    
Severity: normal CC: djm, dtucker
Priority: P5    
Version: 8.2p1   
Hardware: Other   
OS: Linux   
Bug Depends on:    
Bug Blocks: 3117    
Attachments:
Description Flags
Add -N flag to override quiet mode
none
correct patch none

Description Matthew Parslow 2020-03-13 10:21:50 AEDT
Prior to 2013, sftp in batch mode (-b) produced output that included what was done. Quiet mode could be specified as well if desired.

Batch mode now assumes quiet mode and cannot be overridden.

This breaks integration which expects sftp output but uses batch mode.

Quiet as the default might be ok, but there is no way to 'unquiet'

I will be providing a pull on github that checks if quiet is set - if it's not set, assume quiet, if it's set to no, honour that setting. This provides the default functionality which is now current, but provides the ability to override.
Comment 1 Damien Miller 2020-03-13 11:01:14 AEDT
I don't understand what you're referring to. sftp does produce output by default in batch mode:

$ cat > /tmp/b
cd /bin
get ls /tmp
get xxls /tmp
$ sftp -b /tmp/b localhost
sftp> cd /bin
sftp> get ls /tmp
sftp> get xxls /tmp
File "/bin/xxls" not found.
Comment 2 Matthew Parslow 2020-03-13 11:31:03 AEDT
It does have some output, but it's in quiet mode.

https://github.com/openssh/openssh-portable/commit/9303e6527bb5ca7630c765f28624702c212bfd6c?fbclid=IwAR3KCDxObbHrEBsHNUrHDxFfv4FT6wULg2udwPq6ZhPZvHkbwYdA2qbwnYI#diff-bfa9ee6de996100a65619653d189809fR2195 shows where it sets quiet mode.

example:

$ ls -lrt
total 0
$ cat /tmp/test/commands
ls /tmp/test/
get /tmp/test/*
$ sftp -b /tmp/test/commands testhost
sftp> ls /tmp/test
/tmp/test/1file   /tmp/test/2dir    /tmp/test/3file
sftp> get /tmp/test/*
Cannot download non-regular file: /tmp/test/2dir/
$ ls
1file  3file


Compare to:

matt@ludev:/tmp/dest$ sftp  testhost < /tmp/test/commands
Connected to testhost.
sftp> ls /tmp/test/
/tmp/test/1file     /tmp/test/2dir      /tmp/test/3file
sftp> get /tmp/test/*
Fetching /tmp/test/1file to 1file
Fetching /tmp/test/2dir/ to 2dir
Cannot download non-regular file: /tmp/test/2dir/
Fetching /tmp/test/3file to 3file
Comment 3 Damien Miller 2020-03-13 13:44:47 AEDT
Created attachment 3363 [details]
Add -N flag to override quiet mode

Ah, I changed that because a few people thought the verbose output was too noisy for scripted use.

Anyway, this patch adds a -N flag ("noisy") that clears quiet mode:

[djm@djm openssh]$ ./sftp -Nb /tmp/b localhost
Connected to fuyu.
sftp> cd /bin
sftp> get ls /tmp
Fetching /bin/ls to /tmp/ls
sftp> get xxls /tmp
File "/bin/xxls" not found.
Comment 4 Damien Miller 2020-03-13 13:51:36 AEDT
Created attachment 3364 [details]
correct patch

oops, wrong patch. This one does it correctly.
Comment 5 Damien Miller 2020-04-03 15:47:12 AEDT
this has been committed and will be in openssh-8.3 - thanks
Comment 6 Damien Miller 2021-03-04 09:54:40 AEDT
close bugs that were resolved in OpenSSH 8.5 release cycle