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.
Sounds reasonable, I'll have a look when I have time.
Created attachment 4726 [details]
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...
Jan, does this look reasonable to you?
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.
Created attachment 4739 [details]
This one should do the right thing. Tested and pushed to samba master branch.