Bug 7242 - POSIXLY_CORRECT env variable causes options to be ignored with mount.cifs
Summary: POSIXLY_CORRECT env variable causes options to be ignored with mount.cifs
Status: NEW
Alias: None
Product: Samba 3.4
Classification: Unclassified
Component: Client Tools (show other bugs)
Version: 3.4.7
Hardware: x64 Linux
: P3 normal
Target Milestone: ---
Assignee: Volker Lendecke
QA Contact: Samba QA Contact
URL: https://bugzilla.gnome.org/show_bug.c...
Depends on:
Reported: 2010-03-12 13:29 UTC by Rodney Beede
Modified: 2010-03-12 13:29 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Rodney Beede 2010-03-12 13:29:00 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.
Comment 1 Rodney Beede 2010-03-12 13:29:31 UTC
https://bugzilla.gnome.org/show_bug.cgi?id=612459 has discussion on how I ran into this issue.