Skip to content

Commit

Permalink
Disable echo on rndssu password prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernd Wachter committed Mar 20, 2013
1 parent 9c87541 commit 0c5b2a3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions rndssucli/rndssucli.cpp
Expand Up @@ -6,6 +6,9 @@
*/

#include <QCoreApplication>

#include <termios.h>

#include "rndssucli.h"

RndSsuCli::RndSsuCli(): QObject(){
Expand Down Expand Up @@ -50,11 +53,22 @@ void RndSsuCli::optRegister(){
QTextStream qin(stdin);
QTextStream qout(stdout);

struct termios termNew, termOld;

qout << "Username: " << flush;
username = qin.readLine();

tcgetattr(STDIN_FILENO, &termNew);
termOld = termNew;
termNew.c_lflag &= ~ECHO;
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &termNew) == -1)
qout << "WARNING: Unable to disable echo on your terminal, password will echo!";

qout << "Password: " << flush;
password = qin.readLine();

tcsetattr(STDIN_FILENO, TCSANOW, &termOld);

ssu.sendRegistration(username, password);
}

Expand Down

0 comments on commit 0c5b2a3

Please sign in to comment.