]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tty-ask-pw-agent: the message string might not be set
authorLennart Poettering <lennart@poettering.net>
Wed, 26 Aug 2020 21:05:46 +0000 (23:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 26 Aug 2020 21:10:05 +0000 (23:10 +0200)
src/shared/ask-password-api.c
src/tty-ask-password-agent/tty-ask-password-agent.c

index 3d0b9391069507049c9fcec873a5a19eafaf2e92..a727b98e7c67dd66a6c72f8391e75aeba9661e6d 100644 (file)
@@ -237,6 +237,9 @@ int ask_password_plymouth(
 
         assert(ret);
 
+        if (!message)
+                message = "Password:";
+
         if (flag_file) {
                 notify = inotify_init1(IN_CLOEXEC|IN_NONBLOCK);
                 if (notify < 0)
index 49b30e14e029d4ffc44ef996a94a51eed5e5e594..096b90c2aa3728fec66421487603bbf93195bf3b 100644 (file)
@@ -210,7 +210,7 @@ static int process_one_password_file(const char *filename) {
 
         switch (arg_action) {
         case ACTION_LIST:
-                printf("'%s' (PID %u)\n", message, pid);
+                printf("'%s' (PID %u)\n", strna(message), pid);
                 return 0;
 
         case ACTION_WALL: {
@@ -219,7 +219,7 @@ static int process_one_password_file(const char *filename) {
                  if (asprintf(&wall,
                               "Password entry required for \'%s\' (PID %u).\r\n"
                               "Please enter password with the systemd-tty-ask-password-agent tool.",
-                              message,
+                              strna(message),
                               pid) < 0)
                          return log_oom();
 
@@ -233,7 +233,7 @@ static int process_one_password_file(const char *filename) {
 
                 if (access(socket_name, W_OK) < 0) {
                         if (arg_action == ACTION_QUERY)
-                                log_info("Not querying '%s' (PID %u), lacking privileges.", message, pid);
+                                log_info("Not querying '%s' (PID %u), lacking privileges.", strna(message), pid);
 
                         return 0;
                 }
@@ -246,7 +246,6 @@ static int process_one_password_file(const char *filename) {
                         r = ask_password_plymouth(message, not_after, flags, filename, &passwords);
                 else
                         r = agent_ask_password_tty(message, not_after, flags, filename, &passwords);
-
                 if (r < 0) {
                         /* If the query went away, that's OK */
                         if (IN_SET(r, -ETIME, -ENOENT))
@@ -262,8 +261,7 @@ static int process_one_password_file(const char *filename) {
                 if (r < 0)
                         return log_error_errno(r, "Failed to send: %m");
                 break;
-        }
-        }
+        }}
 
         return 0;
 }