mount.cifs: clean up command-line options
authorJeff Layton <jlayton@redhat.com>
Thu, 1 Apr 2010 19:19:16 +0000 (15:19 -0400)
committerJeff Layton <jlayton@redhat.com>
Thu, 1 Apr 2010 19:19:16 +0000 (15:19 -0400)
The mount.cifs command apparently tries to take a ton of command-line
options. Many of these will never be passed to mount.cifs by /bin/mount.
Others are more appropriately specified as mount options.

In both cases, there are a lot of options in the switch statement that
are not listed in the optstring, and there are characters in the
optstring that are not dealt with by the switch statement. Other options
are poorly wired to the rest of the code and don't actually do anything.

Clean it up by removing all but the ones that are likely to ever be
used.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
mount.cifs.c

index 6dfab61297dab9e45855a65c70c99085d65c16e8..fd110c7a3955f0193f8ae632105b9ad9ef3b7a64 100644 (file)
@@ -1005,8 +1005,6 @@ int main(int argc, char ** argv)
        char *currentaddress, *nextaddress;
        int rc = 0;
        int nomtab = 0;
-       int uid = 0;
-       int gid = 0;
        int fakemnt = 0;
        int already_uppercased = 0;
        size_t options_size = MAX_OPTIONS_LEN;
@@ -1040,20 +1038,9 @@ int main(int argc, char ** argv)
        parsed_info->flags = MS_MANDLOCK;
 
        /* add sharename in opts string as unc= parm */
-       while ((c = getopt_long (argc, argv, "afFhilL:no:O:rsSU:vVwt:",
-                        longopts, NULL)) != -1) {
+       while ((c = getopt_long (argc, argv, "?fhno:rvVw",
+                       longopts, NULL)) != -1) {
                switch (c) {
-/* No code to do the following  options yet */
-/*     case 'l':
-               list_with_volumelabel = 1;
-               break;
-       case 'L':
-               volumelabel = optarg;
-               break; */
-/*     case 'a':              
-               ++mount_all;
-               break; */
-
                case '?':
                case 'h':        /* help */
                        rc = mount_cifs_usage(stdout);
@@ -1061,22 +1048,6 @@ int main(int argc, char ** argv)
                case 'n':
                        ++nomtab;
                        break;
-               case 'b':
-#ifdef MS_BIND
-                       parsed_info->flags |= MS_BIND;
-#else
-                       fprintf(stderr,
-                               "option 'b' (MS_BIND) not supported\n");
-#endif
-                       break;
-               case 'm':
-#ifdef MS_MOVE               
-                       parsed_info->flags |= MS_MOVE;
-#else
-                       fprintf(stderr,
-                               "option 'm' (MS_MOVE) not supported\n");
-#endif
-                       break;
                case 'o':
                        orgoptions = strndup(optarg, MAX_OPTIONS_LEN);
                        if (!orgoptions) {
@@ -1096,75 +1067,11 @@ int main(int argc, char ** argv)
                case 'w':
                        parsed_info->flags &= ~MS_RDONLY;
                        break;
-               case '1':
-                       if (isdigit(*optarg)) {
-                               char *ep;
-
-                               uid = strtoul(optarg, &ep, 10);
-                               if (*ep) {
-                                       fprintf(stderr, "bad uid value \"%s\"\n", optarg);
-                                       rc = EX_USAGE;
-                                       goto mount_exit;
-                               }
-                       } else {
-                               struct passwd *pw;
-
-                               if (!(pw = getpwnam(optarg))) {
-                                       fprintf(stderr, "bad user name \"%s\"\n", optarg);
-                                       rc = EX_USAGE;
-                                       goto mount_exit;
-                               }
-                               uid = pw->pw_uid;
-                               endpwent();
-                       }
-                       break;
-               case '2':
-                       if (isdigit(*optarg)) {
-                               char *ep;
-
-                               gid = strtoul(optarg, &ep, 10);
-                               if (*ep) {
-                                       fprintf(stderr, "bad gid value \"%s\"\n", optarg);
-                                       rc = EX_USAGE;
-                                       goto mount_exit;
-                               }
-                       } else {
-                               struct group *gr;
-
-                               if (!(gr = getgrnam(optarg))) {
-                                       fprintf(stderr, "bad user name \"%s\"\n", optarg);
-                                       rc = EX_USAGE;
-                                       goto mount_exit;
-                               }
-                               gid = gr->gr_gid;
-                               endpwent();
-                       }
-                       break;
-               case 'u':
-                       parsed_info->got_user = 1;
-                       strlcpy(parsed_info->username, optarg,
-                               sizeof(parsed_info->username));
-                       break;
-               case 'd':
-                       strlcpy(parsed_info->domain, optarg, sizeof(parsed_info->domain));
-                       break;
-               case 'p':
-                       rc = set_password(parsed_info, optarg);
-                       if (rc)
-                               goto mount_exit;
-                       break;
-               case 'S':
-                       rc = get_password_from_file(0, NULL, parsed_info);
-                       if (rc)
-                               goto mount_exit;
-                       break;
-               case 't':
-                       break;
                case 'f':
                        ++fakemnt;
                        break;
                default:
-                       fprintf(stderr, "unknown mount option %c\n",c);
+                       fprintf(stderr, "unknown command-line option: %c\n", c);
                        rc = mount_cifs_usage(stderr);
                        goto mount_exit;
                }