diff -up wsmancli-2.6.0/src/wsman.c.orig wsmancli-2.6.0/src/wsman.c --- wsmancli-2.6.0/src/wsman.c.orig 2023-01-09 11:46:15.771553135 +0100 +++ wsmancli-2.6.0/src/wsman.c 2023-01-09 11:54:13.968830290 +0100 @@ -40,6 +40,7 @@ #include #include #include +#include #ifdef HAVE_UNISTD_H #include @@ -57,6 +58,8 @@ extern char *getpass (const char *__prompt); #endif +#define BASE_LEN 21 + static long int server_port = 0; static char *cainfo = NULL; static char *cert = NULL; @@ -498,6 +501,10 @@ request_usr_pwd( WsManClient *client, ws char *pw; char user[21]; char *p; + char c; + int len = BASE_LEN; + int pos = 0; + struct termios term; /* * fprintf(stdout,"Authentication failed, please retry\n"); @@ -560,8 +567,28 @@ request_usr_pwd( WsManClient *client, ws } /* but always ask for the password !? */ - pw = (char *)getpass("Password: "); + /* set no echo */ + tcgetattr(1, &term); + term.c_lflag &= ~ECHO; + tcsetattr(1, TCSANOW, &term); + /* get pass */ + pw = (char*) u_malloc(sizeof(char) * len); + pw[0] = '\0'; + printf("Password: "); + fflush(stdout); + while ((c = fgetc(stdin)) != '\n') { + pw[pos++] = (char) c; + if (pos >= len) { + len += BASE_LEN; + pw = realloc(pw, len); + } + } + pw[pos] = '\0'; *password = u_strdup_printf ("%s", pw); + u_free(pw); + /* set echo back again */ + term.c_lflag |= ECHO; + tcsetattr(1, TCSANOW, &term); /* make backup, *password will become free'd when next try of http-auth fails */ if (*password) {