#include <unistd.h>
#include "ask-password-api.h"
-#include "def.h"
+#include "build.h"
+#include "constants.h"
#include "log.h"
#include "macro.h"
#include "main-func.h"
" --id=ID Query identifier (e.g. \"cryptsetup:/dev/sda5\")\n"
" --keyname=NAME Kernel key name for caching passwords (e.g. \"cryptsetup\")\n"
" --credential=NAME\n"
- " Credential name for LoadCredential=/SetCredential=\n"
- " credentials\n"
+ " Credential name for ImportCredential=, LoadCredential= or\n"
+ " SetCredential= credentials\n"
" --timeout=SEC Timeout in seconds\n"
" --echo=yes|no|masked\n"
" Control whether to show password while typing (echo)\n"
/* Note the asymmetry: the long option --echo= allows an optional argument, the short option does
* not. */
+
+ /* Resetting to 0 forces the invocation of an internal initialization routine of getopt_long()
+ * that checks for GNU extensions in optstring ('-' or '+' at the beginning). */
+ optind = 0;
while ((c = getopt_long(argc, argv, "+hen", options, NULL)) >= 0)
switch (c) {
/* Empty argument or explicit string "masked" for default behaviour. */
arg_flags &= ~(ASK_PASSWORD_ECHO|ASK_PASSWORD_SILENT);
else {
- bool b;
-
- r = parse_boolean_argument("--echo=", optarg, &b);
+ r = parse_boolean_argument("--echo=", optarg, NULL);
if (r < 0)
return r;
- SET_FLAG(arg_flags, ASK_PASSWORD_ECHO, b);
- SET_FLAG(arg_flags, ASK_PASSWORD_SILENT, !b);
+ SET_FLAG(arg_flags, ASK_PASSWORD_ECHO, r);
+ SET_FLAG(arg_flags, ASK_PASSWORD_SILENT, !r);
}
break;
return -EINVAL;
default:
- assert_not_reached("Unhandled option");
+ assert_not_reached();
}
if (isempty(emoji) || streq(emoji, "auto"))
SET_FLAG(arg_flags, ASK_PASSWORD_HIDE_EMOJI, FLAGS_SET(arg_flags, ASK_PASSWORD_ECHO));
else {
- bool b;
-
- r = parse_boolean_argument("--emoji=", emoji, &b);
+ r = parse_boolean_argument("--emoji=", emoji, NULL);
if (r < 0)
return r;
- SET_FLAG(arg_flags, ASK_PASSWORD_HIDE_EMOJI, !b);
+ SET_FLAG(arg_flags, ASK_PASSWORD_HIDE_EMOJI, !r);
}
if (argc > optind) {
static int run(int argc, char *argv[]) {
_cleanup_strv_free_erase_ char **l = NULL;
usec_t timeout;
- char **p;
int r;
log_show_color(true);