Bug 7551 - smbclient does not return proper exit code
smbclient does not return proper exit code
Status: RESOLVED FIXED
Product: Samba 3.5
Classification: Unclassified
Component: SMB2
3.5.4
Other Linux
: P3 normal
: ---
Assigned To: Karolin Seeger
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-07-05 12:17 UTC by Enrico Scholz
Modified: 2011-10-08 18:20 UTC (History)
2 users (show)

See Also:


Attachments
Fix for 3.5.x. (430 bytes, patch)
2010-07-15 18:01 UTC, Jeremy Allison
no flags Details
Exit with the return code of cli_push (665 bytes, patch)
2011-09-29 09:36 UTC, Bram
no flags Details
git-am fix for 3.6.1. (843 bytes, patch)
2011-09-30 00:11 UTC, Jeremy Allison
metze: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Enrico Scholz 2010-07-05 12:17:10 UTC
'smbclient' fails sometimes to return a proper return code:

| $ smbclient -k //cricetus/test3 -c 'put /tmp/osl /x' ; echo $?
| cli_push returned NT_STATUS_DISK_FULL
| putting file /tmp/osl as \/x (11963,8 kb/s) (average 11963,8 kb/s)
| 0

This is very problematic when used in scripts


Seen with
samba-client-3.0.33-3.28.el5
samba-client-3.5.4-62.fc13.x86_64
Comment 1 Jeremy Allison 2010-07-15 18:01:34 UTC
Created attachment 5845 [details]
Fix for 3.5.x.

This should fix your use case. Can you test and get back to me please ?

Jeremy.
Comment 2 Bram 2011-09-29 09:35:29 UTC
I experienced the same problem and tested the fix.

Testing with samba-3.5.3 (as client) with the fix applied:

Before the fix:

$ smbclient '\\server\share -U 'user%pass' -c 'put /tmp/foo.tt "\dir\test"' ; echo $?
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
cli_push returned NT_STATUS_DISK_FULL
putting file /tmp/foo.tt as \dir\test (38768.4 kb/s) (average 38768.4 kb/s)
0

After the fix:

$ smbclient '\\server\share -U 'user%pass' -c 'put /tmp/foo.tt "\dir\test"' ; echo $?
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
cli_push returned NT_STATUS_DISK_FULL
putting file /tmp/foo.tt as \dir\test (66523.7 kb/s) (average 66523.8 kb/s)
1

But it is still broken when 'put - ' is used:

$ cat /tmp/foo.tt | smbclient '\\server\share -U 'user%pass' -c 'put - "\dir\test"' ; echo $?
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
cli_push returned NT_STATUS_DISK_FULL
putting file - as \dir\test (72258.5 kb/s) (average 72258.6 kb/s)
0

=> Exit status 0 instead of 1.

Attached is a patch (against git-master) that should fix this.

After my change:

$ cat /tmp/foo.tt | smbclient '\\server\share' -U 'user%pass' -c 'put - "\dir\test"' ; echo $?
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]
cli_push returned NT_STATUS_DISK_FULL
putting file - as \dir\test (57410.9 kb/s) (average 57411.0 kb/s)
1
Comment 3 Bram 2011-09-29 09:36:30 UTC
Created attachment 6962 [details]
Exit with the return code of cli_push
Comment 4 Jeremy Allison 2011-09-29 19:18:43 UTC
I've applied the second patch to master - looks good. I'll update for 3.6.1 once the autobuild completes.

Karolin, both these patches are good for 3.5.next, the second one is also needed for 3.6.1.

Jeremy.
Comment 5 Jeremy Allison 2011-09-30 00:11:58 UTC
Created attachment 6971 [details]
git-am fix for 3.6.1.

git-am fix that got pushed to master. Should apply to 3.6.1 and 3.5.next.
Jeremy.
Comment 6 Stefan Metzmacher 2011-09-30 06:41:00 UTC
Comment on attachment 6971 [details]
git-am fix for 3.6.1.

Looks ok
Comment 7 Karolin Seeger 2011-10-08 18:20:26 UTC
Pushed both patches to v3-5-test and the second one to v3-6-test.
Closing out bug report.

Thanks!