comparison cli-authinteract.c @ 1122:aaf576b27a10

Merge pull request #13 from gazoo74/fix-warnings Fix warnings
author Matt Johnston <matt@ucc.asn.au>
date Thu, 04 Jun 2015 23:08:50 +0800
parents 506e769ed6d1
children 750ec4ec4cbe
comparison
equal deleted inserted replaced
1087:1e486f368ec3 1122:aaf576b27a10
29 #include "ssh.h" 29 #include "ssh.h"
30 #include "runopts.h" 30 #include "runopts.h"
31 31
32 #ifdef ENABLE_CLI_INTERACT_AUTH 32 #ifdef ENABLE_CLI_INTERACT_AUTH
33 33
34 static unsigned char* get_response(unsigned char* prompt) 34 static char* get_response(char* prompt)
35 { 35 {
36 FILE* tty = NULL; 36 FILE* tty = NULL;
37 unsigned char* response = NULL; 37 char* response = NULL;
38 /* not a password, but a reasonable limit */ 38 /* not a password, but a reasonable limit */
39 char buf[DROPBEAR_MAX_CLI_PASS]; 39 char buf[DROPBEAR_MAX_CLI_PASS];
40 char* ret = NULL; 40 char* ret = NULL;
41 41
42 fprintf(stderr, "%s", prompt); 42 fprintf(stderr, "%s", prompt);
48 } else { 48 } else {
49 ret = fgets(buf, sizeof(buf), stdin); 49 ret = fgets(buf, sizeof(buf), stdin);
50 } 50 }
51 51
52 if (ret == NULL) { 52 if (ret == NULL) {
53 response = (unsigned char*)m_strdup(""); 53 response = m_strdup("");
54 } else { 54 } else {
55 unsigned int buflen = strlen(buf); 55 unsigned int buflen = strlen(buf);
56 /* fgets includes newlines */ 56 /* fgets includes newlines */
57 if (buflen > 0 && buf[buflen-1] == '\n') 57 if (buflen > 0 && buf[buflen-1] == '\n')
58 buf[buflen-1] = '\0'; 58 buf[buflen-1] = '\0';
59 response = (unsigned char*)m_strdup(buf); 59 response = m_strdup(buf);
60 } 60 }
61 61
62 m_burn(buf, sizeof(buf)); 62 m_burn(buf, sizeof(buf));
63 63
64 return response; 64 return response;
65 } 65 }
66 66
67 void recv_msg_userauth_info_request() { 67 void recv_msg_userauth_info_request() {
68 68
69 unsigned char *name = NULL; 69 char *name = NULL;
70 unsigned char *instruction = NULL; 70 char *instruction = NULL;
71 unsigned int num_prompts = 0; 71 unsigned int num_prompts = 0;
72 unsigned int i; 72 unsigned int i;
73 73
74 unsigned char *prompt = NULL; 74 char *prompt = NULL;
75 unsigned int echo = 0; 75 unsigned int echo = 0;
76 unsigned char *response = NULL; 76 char *response = NULL;
77 77
78 TRACE(("enter recv_msg_recv_userauth_info_request")) 78 TRACE(("enter recv_msg_recv_userauth_info_request"))
79 79
80 /* Let the user know what password/host they are authing for */ 80 /* Let the user know what password/host they are authing for */
81 if (!cli_ses.interact_request_received) { 81 if (!cli_ses.interact_request_received) {
119 cleantext(prompt); 119 cleantext(prompt);
120 120
121 echo = buf_getbool(ses.payload); 121 echo = buf_getbool(ses.payload);
122 122
123 if (!echo) { 123 if (!echo) {
124 unsigned char* p = getpass_or_cancel(prompt); 124 char* p = getpass_or_cancel(prompt);
125 response = m_strdup(p); 125 response = m_strdup(p);
126 m_burn(p, strlen(p)); 126 m_burn(p, strlen(p));
127 } else { 127 } else {
128 response = get_response(prompt); 128 response = get_response(prompt);
129 } 129 }
151 /* username */ 151 /* username */
152 buf_putstring(ses.writepayload, cli_opts.username, 152 buf_putstring(ses.writepayload, cli_opts.username,
153 strlen(cli_opts.username)); 153 strlen(cli_opts.username));
154 154
155 /* service name */ 155 /* service name */
156 buf_putstring(ses.writepayload, SSH_SERVICE_CONNECTION, 156 buf_putstring(ses.writepayload, SSH_SERVICE_CONNECTION,
157 SSH_SERVICE_CONNECTION_LEN); 157 SSH_SERVICE_CONNECTION_LEN);
158 158
159 /* method */ 159 /* method */
160 buf_putstring(ses.writepayload, AUTH_METHOD_INTERACT, 160 buf_putstring(ses.writepayload, AUTH_METHOD_INTERACT,
161 AUTH_METHOD_INTERACT_LEN); 161 AUTH_METHOD_INTERACT_LEN);