Bug 6749 - mount.cifs chooses wrong fd for error messages
Summary: mount.cifs chooses wrong fd for error messages
Status: ASSIGNED
Alias: None
Product: Samba 3.2
Classification: Unclassified
Component: Client tools (show other bugs)
Version: 3.2.7
Hardware: All Linux
: P3 minor
Target Milestone: ---
Assignee: Jeff Layton
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-21 08:10 UTC by Jan Engelhardt
Modified: 2009-09-24 20:05 UTC (History)
0 users

See Also:


Attachments
proposed patch (21.42 KB, patch)
2009-09-21 14:54 UTC, Jeff Layton
no flags Details
patch #2 (24.10 KB, patch)
2009-09-24 20:05 UTC, Jeff Layton
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Engelhardt 2009-09-21 08:10:50 UTC
mount.cifs writes errors to stdout instead of stderr. This is bad for tools which ignore stdout and only check for $? and stderr (as one would normally do, e.g. with tar(1)). Having a non-zero exit status and an empty stderr however is confusing to users (reports in pam_mount); I think it should therefore be fixed.
Comment 1 Jeff Layton 2009-09-21 10:05:52 UTC
Sounds reasonable, I'll have a look when I have time.
Comment 2 Jeff Layton 2009-09-21 14:54:23 UTC
Created attachment 4726 [details]
proposed patch

This should fix it. I basically used perl and ran a search and replace for 'printf("' to 'fprintf(stderr, "' and cleaned up the rest by hand. That seemed to cover all the spots.

This patch also makes the version output and usage message print to stderr as well...not sure if that's standard behavior or not, but seems reasonable enough.

Not heavily tested, but a pretty straightforward patch that builds and seems to work...
Comment 3 Jeff Layton 2009-09-21 14:54:53 UTC
Jan, does this look reasonable to you?
Comment 4 Jan Engelhardt 2009-09-21 16:18:03 UTC
Anything explicitly requested, such as --version, --usage and --help, is generally printed to stdout. Compare with /bin/ls, /bin/insmod, /bin/tar, just to name a few.

When a program does error out because of, for example, a faulty option, it may opt to print the "usage" help (i.e. syntax of the parameters) to stderr, as the usage was not explicitly requested.
Comment 5 Jeff Layton 2009-09-24 20:05:14 UTC
Created attachment 4739 [details]
patch #2

This one should do the right thing. Tested and pushed to samba master branch.