unstick r548

Revision 548

Date:
2014/02/18 05:10:04
Author:
Antonio Borneo
Revision Log:
getpass: build prompt string and pass it

Instead of printing the prompt before getpass(),
build prompt string in a buffer and pass it.
In this way, password helper gets the prompt.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Files:

Legend:

 
Added
 
Removed
 
Modified
  • branches/vpnc-nortel/config.c

     
    257 257 }
    258 258
    259 259 printf("%s", prompt);
    260 fflush(stdout);
    261
    260 262 tcgetattr(STDIN_FILENO, &t);
    261 263 t.c_lflag &= ~ECHO;
    262 264 tcsetattr(STDIN_FILENO, TCSANOW, &t);
     
    856 858
    857 859 void do_config(int argc, char **argv)
    858 860 {
    859 char *s;
    861 char *s, *prompt;
    860 862 int i, c, known;
    861 863 int got_conffile = 0, print_config = 0;
    862 864 size_t s_len;
     
    1120 1122 printf("Enter IPSec ID for %s: ", config[CONFIG_IPSEC_GATEWAY]);
    1121 1123 break;
    1122 1124 case CONFIG_IPSEC_SECRET:
    1123 printf("Enter IPSec secret for %s@%s: ",
    1125 asprintf(&prompt, "Enter IPSec secret for %s@%s: ",
    1124 1126 config[CONFIG_IPSEC_ID], config[CONFIG_IPSEC_GATEWAY]);
    1125 1127 break;
    1126 1128 case CONFIG_XAUTH_USERNAME:
    1127 1129 printf("Enter username for %s: ", config[CONFIG_IPSEC_GATEWAY]);
    1128 1130 break;
    1129 1131 case CONFIG_XAUTH_PIN:
    1130 printf("Enter PIN for %s@%s: ",
    1132 asprintf(&prompt, "Enter PIN for %s@%s: ",
    1131 1133 config[CONFIG_XAUTH_USERNAME],
    1132 1134 config[CONFIG_IPSEC_GATEWAY]);
    1133 1135 break;
    1134 1136 case CONFIG_XAUTH_PASSWORD:
    1135 printf("Enter password for %s@%s: ",
    1137 asprintf(&prompt, "Enter password for %s@%s: ",
    1136 1138 config[CONFIG_XAUTH_USERNAME],
    1137 1139 config[CONFIG_IPSEC_GATEWAY]);
    1138 1140 break;
     
    1144 1146 case CONFIG_IPSEC_SECRET:
    1145 1147 case CONFIG_XAUTH_PIN:
    1146 1148 case CONFIG_XAUTH_PASSWORD:
    1147 s = vpnc_getpass("");
    1149 s = vpnc_getpass(prompt);
    1150 free(prompt);
    1148 1151 if (s == NULL)
    1149 1152 error(1, 0, "unable to get password");
    1150 1153 break;