1082 fflush(stderr); |
1082 fflush(stderr); |
1083 |
1083 |
1084 #ifndef _WIN32 |
1084 #ifndef _WIN32 |
1085 // hide terminal input |
1085 // hide terminal input |
1086 struct termios oflags, nflags; |
1086 struct termios oflags, nflags; |
1087 tcgetattr(fileno(stdin), &oflags); |
1087 if(isatty(fileno(stdin))) { |
1088 nflags = oflags; |
1088 tcgetattr(fileno(stdin), &oflags); |
1089 nflags.c_lflag &= ~ECHO; |
1089 nflags = oflags; |
1090 nflags.c_lflag |= ECHONL; |
1090 nflags.c_lflag &= ~ECHO; |
1091 if (tcsetattr(fileno(stdin), TCSANOW, &nflags) != 0) { |
1091 nflags.c_lflag |= ECHONL; |
1092 perror("tcsetattr"); |
1092 if (tcsetattr(fileno(stdin), TCSANOW, &nflags) != 0) { |
1093 } |
1093 perror("tcsetattr"); |
|
1094 } |
|
1095 } |
|
1096 |
1094 #endif |
1097 #endif |
1095 |
1098 |
1096 // read password input |
1099 // read password input |
1097 UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); |
1100 UcxBuffer *buf = ucx_buffer_new(NULL, 128, UCX_BUFFER_AUTOEXTEND); |
1098 int c = 0; |
1101 int c = 0; |
1105 ucx_buffer_putc(buf, 0); |
1108 ucx_buffer_putc(buf, 0); |
1106 fflush(stdin); |
1109 fflush(stdin); |
1107 |
1110 |
1108 #ifndef _WIN32 |
1111 #ifndef _WIN32 |
1109 // restore terminal settings |
1112 // restore terminal settings |
1110 if (tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) { |
1113 if (isatty(fileno(stdin)) && tcsetattr(fileno(stdin), TCSANOW, &oflags) != 0) { |
1111 perror("tcsetattr"); |
1114 perror("tcsetattr"); |
1112 } |
1115 } |
1113 #endif |
1116 #endif |
1114 |
1117 |
1115 char *str = buf->space; |
1118 char *str = buf->space; |