Bug 7069 - smbget does not return an error status after some errors
Summary: smbget does not return an error status after some errors
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.4
Classification: Unclassified
Component: Client Tools (show other bugs)
Version: 3.4.5
Hardware: x86 Linux
: P3 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-27 09:17 UTC by Johannes Poehlmann
Modified: 2010-02-04 03:16 UTC (History)
0 users

See Also:


Attachments
clean up smbget return status in case of some errors (1.95 KB, patch)
2010-01-27 09:51 UTC, Johannes Poehlmann
no flags Details
Replacement cleanup. (8.79 KB, patch)
2010-01-27 17:35 UTC, Jeremy Allison
no flags Details
after applying Jeremies patch, applying this one made it work. clean_exit() always dows a "exit(0)", so no status code of 1 was issued (306 bytes, text/x-patch)
2010-01-28 05:19 UTC, Johannes Poehlmann
no flags Details
cumulative patch with Jeremies clean up patch and the patch above (7.54 KB, text/x-patch)
2010-01-28 05:23 UTC, Johannes Poehlmann
no flags Details
git-am format patch for 3.5.0. (9.42 KB, patch)
2010-01-28 17:18 UTC, Jeremy Allison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Poehlmann 2010-01-27 09:17:21 UTC
I realized that some error conditions are reported on the console but 
the return code of smbget ist 0. This broke some scripts.

After looking into the code i think to have found a reason:

smb_download_file() and smb_download_dir() return 0 in case of error.
the return code of these functions is then returned from main where
1 means error and 0 means no error.

I will append a patch for this
Comment 1 Johannes Poehlmann 2010-01-27 09:51:11 UTC
Created attachment 5225 [details]
clean up smbget return status in case of some errors

I could build the samba-3.4.5 source tree with this patch. 
Now 

smbget -WGROUP smb://server/share/nonexisting file || echo ARGHH

Will say "ARGHH"
Comment 2 Jeremy Allison 2010-01-27 17:35:36 UTC
Created attachment 5228 [details]
Replacement cleanup.

I re-wrote the patch somewhat. Convention is that 0 means success, != 0 means failure on UNIX so I changed the code to do this. Can you test this out in your environment and let me know if it works as a fix for you ?

Jeremy.
Comment 3 Johannes Poehlmann 2010-01-28 05:19:42 UTC
Created attachment 5236 [details]
after applying Jeremies patch, applying this one made it work. clean_exit() always dows a "exit(0)", so no status code of 1 was issued

I will attach a cumulative patch also
Comment 4 Johannes Poehlmann 2010-01-28 05:23:12 UTC
Created attachment 5237 [details]
cumulative patch with Jeremies clean up patch and the patch above
Comment 5 Jeremy Allison 2010-01-28 17:18:28 UTC
Created attachment 5245 [details]
git-am format patch for 3.5.0.
Comment 6 Jeremy Allison 2010-01-28 17:19:03 UTC
Re-assigning to Karolin for inclusion in 3.5.x. Tested and checked by submitter.
Jeremy.
Comment 7 Karolin Seeger 2010-02-04 03:16:44 UTC
Pushed to v3-5-test. Will be included in 3.5.0.
Closing out bug report.

Thanks a lot for testing and providing the patch!