Bug 1252 - sftp returns 0 when upload is unsuccessful due to a full device
Summary: sftp returns 0 when upload is unsuccessful due to a full device
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp (show other bugs)
Version: 4.2p1
Hardware: ix86 Linux
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_4_6
  Show dependency treegraph
 
Reported: 2006-10-21 08:46 AEST by Tomas Jirka
Modified: 2023-01-13 13:57 AEDT (History)
1 user (show)

See Also:


Attachments
propogate error status on upload falure (457 bytes, patch)
2007-01-22 18:03 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Jirka 2006-10-21 08:46:40 AEST
when trying to upload a file via sftp and the disk on the server
is full, sftp returns succes (0) although it should return non-zero code.

repeatable on:
linux 2.6.1x ix86,OpenSSH_4.0p1,OpenSSH_4.2p1

the cause may be the same as in bug 773


$ sftp localhost
Connecting to localhost...
sftp> cd /tmp/full
sftp> put my.img
Uploading my.img to /tmp/pokus/my.img
my.img                                                     0%    0     0.0KB/s   --:-- ETACouldn't write to remote file "/tmp/full/my.img": Failure
                                                              -2147483648% 11449TB  31.1MB/s

$ echo $?
0
Comment 1 Damien Miller 2007-01-22 18:03:36 AEDT
Created attachment 1232 [details]
propogate error status on upload falure

Thanks for the report. This is a bug in sftp-client.c:do_upload(). The error status on a write failure was not being returned to the caller.

BTW in interactive mode (the default when sftp is started for a tty), the return value will be zero anyway because the sftp client exits normally. A better demonstration is batch mode, where the sftp client's exit status will reflect the failure of a command:

echo "put /bin/ls /dev/full" | sftp -b - linux-host

(substitute a full filesystem for /dev/full if you don't have Linux)
Comment 2 Damien Miller 2007-01-22 22:33:34 AEDT
This patch has been committed and will be in OpenSSH 4.6. Thanks for the report!
Comment 3 Damien Miller 2008-04-04 09:56:51 AEDT
Close resolved bugs after release.