Mercurial > dropbear
comparison svr-auth.c @ 1121:bb3a03feb31f
Merge pull request #13 from gazoo74/fix-warnings
Fix warnings
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 04 Jun 2015 22:25:28 +0800 |
parents | 7b84c3492a95 |
children | aaf576b27a10 |
comparison
equal
deleted
inserted
replaced
1087:1e486f368ec3 | 1121:bb3a03feb31f |
---|---|
34 #include "auth.h" | 34 #include "auth.h" |
35 #include "runopts.h" | 35 #include "runopts.h" |
36 #include "dbrandom.h" | 36 #include "dbrandom.h" |
37 | 37 |
38 static void authclear(); | 38 static void authclear(); |
39 static int checkusername(unsigned char *username, unsigned int userlen); | 39 static int checkusername(char *username, unsigned int userlen); |
40 | 40 |
41 /* initialise the first time for a session, resetting all parameters */ | 41 /* initialise the first time for a session, resetting all parameters */ |
42 void svr_authinitialise() { | 42 void svr_authinitialise() { |
43 | 43 |
44 ses.authstate.failcount = 0; | 44 ses.authstate.failcount = 0; |
87 | 87 |
88 CHECKCLEARTOWRITE(); | 88 CHECKCLEARTOWRITE(); |
89 | 89 |
90 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_BANNER); | 90 buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_BANNER); |
91 buf_putbufstring(ses.writepayload, banner); | 91 buf_putbufstring(ses.writepayload, banner); |
92 buf_putstring(ses.writepayload, "en", 2); | 92 buf_putstring(ses.writepayload, (const unsigned char *)"en", 2); |
93 | 93 |
94 encrypt_packet(); | 94 encrypt_packet(); |
95 | 95 |
96 TRACE(("leave send_msg_userauth_banner")) | 96 TRACE(("leave send_msg_userauth_banner")) |
97 } | 97 } |
98 | 98 |
99 /* handle a userauth request, check validity, pass to password or pubkey | 99 /* handle a userauth request, check validity, pass to password or pubkey |
100 * checking, and handle success or failure */ | 100 * checking, and handle success or failure */ |
101 void recv_msg_userauth_request() { | 101 void recv_msg_userauth_request() { |
102 | 102 |
103 unsigned char *username = NULL, *servicename = NULL, *methodname = NULL; | 103 char *username = NULL, *servicename = NULL, *methodname = NULL; |
104 unsigned int userlen, servicelen, methodlen; | 104 unsigned int userlen, servicelen, methodlen; |
105 int valid_user = 0; | 105 int valid_user = 0; |
106 | 106 |
107 TRACE(("enter recv_msg_userauth_request")) | 107 TRACE(("enter recv_msg_userauth_request")) |
108 | 108 |
117 send_msg_userauth_banner(svr_opts.banner); | 117 send_msg_userauth_banner(svr_opts.banner); |
118 buf_free(svr_opts.banner); | 118 buf_free(svr_opts.banner); |
119 svr_opts.banner = NULL; | 119 svr_opts.banner = NULL; |
120 } | 120 } |
121 | 121 |
122 username = buf_getstring(ses.payload, &userlen); | 122 username = (char *)buf_getstring(ses.payload, &userlen); |
123 servicename = buf_getstring(ses.payload, &servicelen); | 123 servicename = (char *)buf_getstring(ses.payload, &servicelen); |
124 methodname = buf_getstring(ses.payload, &methodlen); | 124 methodname = (char *)buf_getstring(ses.payload, &methodlen); |
125 | 125 |
126 /* only handle 'ssh-connection' currently */ | 126 /* only handle 'ssh-connection' currently */ |
127 if (servicelen != SSH_SERVICE_CONNECTION_LEN | 127 if (servicelen != SSH_SERVICE_CONNECTION_LEN |
128 && (strncmp(servicename, SSH_SERVICE_CONNECTION, | 128 && (strncmp(servicename, SSH_SERVICE_CONNECTION, |
129 SSH_SERVICE_CONNECTION_LEN) != 0)) { | 129 SSH_SERVICE_CONNECTION_LEN) != 0)) { |
225 } | 225 } |
226 | 226 |
227 | 227 |
228 /* Check that the username exists and isn't disallowed (root), and has a valid shell. | 228 /* Check that the username exists and isn't disallowed (root), and has a valid shell. |
229 * returns DROPBEAR_SUCCESS on valid username, DROPBEAR_FAILURE on failure */ | 229 * returns DROPBEAR_SUCCESS on valid username, DROPBEAR_FAILURE on failure */ |
230 static int checkusername(unsigned char *username, unsigned int userlen) { | 230 static int checkusername(char *username, unsigned int userlen) { |
231 | 231 |
232 char* listshell = NULL; | 232 char* listshell = NULL; |
233 char* usershell = NULL; | 233 char* usershell = NULL; |
234 uid_t uid; | 234 uid_t uid; |
235 TRACE(("enter checkusername")) | 235 TRACE(("enter checkusername")) |
331 | 331 |
332 /* put a list of allowed types */ | 332 /* put a list of allowed types */ |
333 typebuf = buf_new(30); /* long enough for PUBKEY and PASSWORD */ | 333 typebuf = buf_new(30); /* long enough for PUBKEY and PASSWORD */ |
334 | 334 |
335 if (ses.authstate.authtypes & AUTH_TYPE_PUBKEY) { | 335 if (ses.authstate.authtypes & AUTH_TYPE_PUBKEY) { |
336 buf_putbytes(typebuf, AUTH_METHOD_PUBKEY, AUTH_METHOD_PUBKEY_LEN); | 336 buf_putbytes(typebuf, (const unsigned char *)AUTH_METHOD_PUBKEY, AUTH_METHOD_PUBKEY_LEN); |
337 if (ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { | 337 if (ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { |
338 buf_putbyte(typebuf, ','); | 338 buf_putbyte(typebuf, ','); |
339 } | 339 } |
340 } | 340 } |
341 | 341 |
342 if (ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { | 342 if (ses.authstate.authtypes & AUTH_TYPE_PASSWORD) { |
343 buf_putbytes(typebuf, AUTH_METHOD_PASSWORD, AUTH_METHOD_PASSWORD_LEN); | 343 buf_putbytes(typebuf, (const unsigned char *)AUTH_METHOD_PASSWORD, AUTH_METHOD_PASSWORD_LEN); |
344 } | 344 } |
345 | 345 |
346 buf_putbufstring(ses.writepayload, typebuf); | 346 buf_putbufstring(ses.writepayload, typebuf); |
347 | 347 |
348 TRACE(("auth fail: methods %d, '%.*s'", ses.authstate.authtypes, | 348 TRACE(("auth fail: methods %d, '%.*s'", ses.authstate.authtypes, |