Bug 10255 - smbclient does not return proper exit code for timeout
Summary: smbclient does not return proper exit code for timeout
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: Client Tools (show other bugs)
Version: 3.6.19
Hardware: Other Linux
: P3 normal
Target Milestone: ---
Assignee: Jeremy Allison
QA Contact: Samba QA Contact
Depends on:
Reported: 2013-11-06 09:13 UTC by Korbinian N.
Modified: 2015-07-09 03:32 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Korbinian N. 2013-11-06 09:13:00 UTC
if 'smbclient' loses connection due downloading a file, it fails to return a proper exit code.

call of smbclient:
| $ smbclient  //CNAME/SNAME -Ix.x.x.x -N -c "case_sensitive; cd folder; prompt;  | mget file"
| echo $?

output (lost connection):
| getting file \folder\file of size 104857600 as file Receiving SMB: Server                | stopped responding
| Short read when getting file \folder\file. Only got 90897408 bytes.
| Error Call timed out: server did not respond after 20000 milliseconds closing   | remote file
| (1381.3 kb/s) (average 1381.3 kb/s)
| 0

This is very problematic when used in scripts.

seen with:
Comment 1 Korbinian N. 2013-11-19 09:52:22 UTC
Any idea?!?!
Comment 2 Volker Lendecke 2013-11-19 10:31:21 UTC
It will be fixed eventually, but if it is urgent for you you might want to contact someone from https://www.samba.org/samba/support/ got get a quick paid response.
Comment 3 Jeremy Allison 2013-11-19 17:39:35 UTC
Fixing up the error codes in the smbclient returns paths in on my list of things to do. Unfortunately right now other things have priority. I'll accept the bug and get to it when I can.

Comment 4 Chris Severance 2015-07-09 03:32:30 UTC
It's unfortunate that smbclient is so minimally supported with minimalist commands and incomplete exit codes. Even in its crufty state, smbclient is the only Samba client that meets and exceeds the user accessibility, adaptability, and reliability of the Windows SMB client.

It isn't Samba's fault. Unix like OS don't handle mounts well when the mounted servers disappear, whether Samba, NFS, or anything else. Until I discovered smbclient I was using autofs which is reliable until the server disappears during the mount time window. Losing a mounted server often requires a Linux reboot to fix. Losing a server to smbclient or a Windows BAT file is an easily handled exit code.

smbclient exit codes should be enumerated so we can distinguish:

* Server not found
* Share not found
* Invalid Command
* A command was incomplete

In my case the incorrect exit code comes from this command

$ smbclient '//' -U 'GUEST%' -c "ls'"
ls': command not found

Fortunately all I want is to test if the supplied server exists and isn't bogus which seems to work with this null command.

$ smbclient '//' -U 'GUEST%' -c ''