cli: use new nmc_readline_echo() in polkit agent
authorJiří Klimeš <jklimes@redhat.com>
Fri, 4 Dec 2015 12:05:59 +0000 (13:05 +0100)
committerJiří Klimeš <jklimes@redhat.com>
Mon, 7 Dec 2015 13:14:58 +0000 (14:14 +0100)
clients/cli/polkit-agent.c

index 0d305f7..b1fcaad 100644 (file)
@@ -25,7 +25,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <termios.h>
 
 #include "nm-default.h"
 #include "polkit-agent.h"
@@ -42,18 +41,10 @@ polkit_request (const char *request,
                gpointer user_data)
 {
        char *response, *tmp, *p;
-       struct termios termios_orig, termios_new;
 
        g_print ("%s\n", message);
        g_print ("(action_id: %s)\n", action_id);
 
-       if (!echo_on) {
-               tcgetattr (STDIN_FILENO, &termios_orig);
-               termios_new = termios_orig;
-               termios_new.c_lflag &= ~(ECHO);
-               tcsetattr (STDIN_FILENO, TCSADRAIN, &termios_new);
-       }
-
        /* Ask user for polkit authorization password */
        if (user) {
                /* chop of ": " if present */
@@ -61,16 +52,12 @@ polkit_request (const char *request,
                p = strrchr (tmp, ':');
                if (p && !strcmp (p, ": "))
                        *p = '\0';
-               response = nmc_readline ("%s (%s): ", tmp, user);
+               response = nmc_readline_echo (echo_on, "%s (%s): ", tmp, user);
                g_free (tmp);
        } else
-               response = nmc_readline ("%s", request);
+               response = nmc_readline_echo (echo_on, "%s", request);
        g_print ("\n");
 
-       /* Restore original terminal settings */
-       if (!echo_on)
-               tcsetattr (STDIN_FILENO, TCSADRAIN, &termios_orig);
-
        return response;
 }