comparison svr-auth.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 7b84c3492a95
children 43a8ea69b24c
comparison
equal deleted inserted replaced
1087:1e486f368ec3 1122:aaf576b27a10
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;
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
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,