+ /* FIXME: rewrite this from scratch */
+
+ if (opt_key_size &&
+ strcmp(aname, "luksFormat") &&
+ strcmp(aname, "create") &&
+ strcmp(aname, "loopaesOpen")) {
+ usage(popt_context, EXIT_FAILURE,
+ _("Option --key-size is allowed only for luksFormat, create and loopaesOpen.\n"
+ "To limit read from keyfile use --keyfile-size=(bytes)."),
+ poptGetInvocationName(popt_context));
+ }
+
+ if (opt_key_size % 8)
+ usage(popt_context, EXIT_FAILURE,
+ _("Key size must be a multiple of 8 bits"),
+ poptGetInvocationName(popt_context));
+
+ if (!strcmp(aname, "luksKillSlot") && action_argc > 1)
+ opt_key_slot = atoi(action_argv[1]);
+ if (opt_key_slot != CRYPT_ANY_SLOT &&
+ (opt_key_slot < 0 || opt_key_slot > crypt_keyslot_max(CRYPT_LUKS1)))
+ usage(popt_context, EXIT_FAILURE, _("Key slot is invalid."),
+ poptGetInvocationName(popt_context));
+
+ if ((!strcmp(aname, "luksRemoveKey") ||
+ !strcmp(aname, "luksFormat")) &&
+ action_argc > 1) {
+ if (opt_key_file)
+ log_err(_("Option --key-file takes precedence over specified key file argument.\n"));
+ else
+ opt_key_file = (char*)action_argv[1];
+ }
+
+ if (opt_random && opt_urandom)
+ usage(popt_context, EXIT_FAILURE, _("Only one of --use-[u]random options is allowed."),
+ poptGetInvocationName(popt_context));
+ if ((opt_random || opt_urandom) && strcmp(aname, "luksFormat"))
+ usage(popt_context, EXIT_FAILURE, _("Option --use-[u]random is allowed only for luksFormat."),
+ poptGetInvocationName(popt_context));
+
+ if (opt_uuid && strcmp(aname, "luksFormat") && strcmp(aname, "luksUUID"))
+ usage(popt_context, EXIT_FAILURE, _("Option --uuid is allowed only for luksFormat and luksUUID."),
+ poptGetInvocationName(popt_context));
+
+ if ((opt_offset || opt_skip) && strcmp(aname, "create"))
+ usage(popt_context, EXIT_FAILURE, _("Options --offset and --skip are supported only for create command.\n"),
+ poptGetInvocationName(popt_context));
+