cli: use new nmc_readline_echo() in polkit agent

This commit is contained in:
Jiří Klimeš 2015-12-04 13:05:59 +01:00
parent a14306c2ce
commit 02388060c1

View 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;
}