]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/ask-password/ask-password.c
tree-wide: remove Lennart's copyright lines
[thirdparty/systemd.git] / src / ask-password / ask-password.c
index a5448660003e23c3d2c83473ef5b94946ab6a534..8e1d834ab44b83bb211b86b355f9d905dcc476e7 100644 (file)
@@ -1,23 +1,4 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-/***
-  This file is part of systemd.
-
-  Copyright 2010 Lennart Poettering
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
+/* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include <errno.h>
 #include <getopt.h>
@@ -36,6 +17,7 @@ static const char *arg_keyname = NULL;
 static char *arg_message = NULL;
 static usec_t arg_timeout = DEFAULT_TIMEOUT_USEC;
 static bool arg_multiple = false;
+static bool arg_no_output = false;
 static AskPasswordFlags arg_flags = ASK_PASSWORD_PUSH_CACHE;
 
 static void help(void) {
@@ -50,6 +32,7 @@ static void help(void) {
                "     --no-tty         Ask question via agent even on TTY\n"
                "     --accept-cached  Accept cached passwords\n"
                "     --multiple       List multiple passwords if available\n"
+               "     --no-output      Do not print password to standard output\n"
                , program_invocation_short_name);
 }
 
@@ -64,6 +47,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_MULTIPLE,
                 ARG_ID,
                 ARG_KEYNAME,
+                ARG_NO_OUTPUT,
         };
 
         static const struct option options[] = {
@@ -76,6 +60,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "multiple",      no_argument,       NULL, ARG_MULTIPLE      },
                 { "id",            required_argument, NULL, ARG_ID            },
                 { "keyname",       required_argument, NULL, ARG_KEYNAME       },
+                { "no-output",     no_argument,       NULL, ARG_NO_OUTPUT     },
                 {}
         };
 
@@ -127,6 +112,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_keyname = optarg;
                         break;
 
+                case ARG_NO_OUTPUT:
+                        arg_no_output = true;
+                        break;
+
                 case '?':
                         return -EINVAL;
 
@@ -168,7 +157,8 @@ int main(int argc, char *argv[]) {
         }
 
         STRV_FOREACH(p, l) {
-                puts(*p);
+                if (!arg_no_output)
+                        puts(*p);
 
                 if (!arg_multiple)
                         break;