mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-08 21:17:47 +03:00
Merge pull request #2754 from eworm-de/ask-password
ask-password: do no print password when storing in keyring
This commit is contained in:
commit
e05a030f90
@ -192,6 +192,15 @@
|
|||||||
This will output one password per line.</para></listitem>
|
This will output one password per line.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--no-output</option></term>
|
||||||
|
|
||||||
|
<listitem><para>Do not print passwords to standard output.
|
||||||
|
This is useful if you want to store a password in kernel
|
||||||
|
keyring with <option>--keyname</option> but do not want it
|
||||||
|
to show up on screen or in logs.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<xi:include href="standard-options.xml" xpointer="help" />
|
<xi:include href="standard-options.xml" xpointer="help" />
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ static const char *arg_keyname = NULL;
|
|||||||
static char *arg_message = NULL;
|
static char *arg_message = NULL;
|
||||||
static usec_t arg_timeout = DEFAULT_TIMEOUT_USEC;
|
static usec_t arg_timeout = DEFAULT_TIMEOUT_USEC;
|
||||||
static bool arg_multiple = false;
|
static bool arg_multiple = false;
|
||||||
|
static bool arg_no_output = false;
|
||||||
static AskPasswordFlags arg_flags = ASK_PASSWORD_PUSH_CACHE;
|
static AskPasswordFlags arg_flags = ASK_PASSWORD_PUSH_CACHE;
|
||||||
|
|
||||||
static void help(void) {
|
static void help(void) {
|
||||||
@ -48,6 +49,7 @@ static void help(void) {
|
|||||||
" --no-tty Ask question via agent even on TTY\n"
|
" --no-tty Ask question via agent even on TTY\n"
|
||||||
" --accept-cached Accept cached passwords\n"
|
" --accept-cached Accept cached passwords\n"
|
||||||
" --multiple List multiple passwords if available\n"
|
" --multiple List multiple passwords if available\n"
|
||||||
|
" --no-output Do not print password to standard output\n"
|
||||||
, program_invocation_short_name);
|
, program_invocation_short_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +64,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
ARG_MULTIPLE,
|
ARG_MULTIPLE,
|
||||||
ARG_ID,
|
ARG_ID,
|
||||||
ARG_KEYNAME,
|
ARG_KEYNAME,
|
||||||
|
ARG_NO_OUTPUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct option options[] = {
|
static const struct option options[] = {
|
||||||
@ -74,6 +77,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
{ "multiple", no_argument, NULL, ARG_MULTIPLE },
|
{ "multiple", no_argument, NULL, ARG_MULTIPLE },
|
||||||
{ "id", required_argument, NULL, ARG_ID },
|
{ "id", required_argument, NULL, ARG_ID },
|
||||||
{ "keyname", required_argument, NULL, ARG_KEYNAME },
|
{ "keyname", required_argument, NULL, ARG_KEYNAME },
|
||||||
|
{ "no-output", no_argument, NULL, ARG_NO_OUTPUT },
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,6 +129,10 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
arg_keyname = optarg;
|
arg_keyname = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ARG_NO_OUTPUT:
|
||||||
|
arg_no_output = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -166,7 +174,8 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
STRV_FOREACH(p, l) {
|
STRV_FOREACH(p, l) {
|
||||||
puts(*p);
|
if (!arg_no_output)
|
||||||
|
puts(*p);
|
||||||
|
|
||||||
if (!arg_multiple)
|
if (!arg_multiple)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user