The Samba-Bugzilla – Bug 7242
POSIXLY_CORRECT env variable causes options to be ignored with mount.cifs
Last modified: 2010-03-12 13:29:49 UTC
mount.cifs has the following call for parsing options:
while ((c = getopt_long (argc, argv,
longopts, NULL)) != -1)
However in some cases without the end-user knowing their terminal will be started with POSIXLY_CORRECT set. This causes getopt_long to ignore their options since the first thing seen in argv is usually the program binary pathname or the server unc or the local mount destination.
It'd be useful if when mount.cifs started it *cleared* the environment variable before calling getopt_long.
Note that you cannot do POSIXLY_CORRECT=disabled as just the existence of the environment variable causes the behavior.
From the man page for getopt_long:
POSIXLY_CORRECT If set, option processing stops when the first non-
option is found and a leading `-' or `+' in the
optstring is ignored.
If that isn't possible then a warning message would be helpful. Of course the warning would have to be generated even if the verbose flag were not available since "-v" will never be parsed.
A third option would be to pass in a modified copy of argv that leaves out the first three arguments from argv.
https://bugzilla.gnome.org/show_bug.cgi?id=612459 has discussion on how I ran into this issue.