=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/auth.c,v retrieving revision 1.41 retrieving revision 1.41.2.2 diff -u -r1.41 -r1.41.2.2 --- src/usr.bin/ssh/auth.c 2002/03/19 15:31:47 1.41 +++ src/usr.bin/ssh/auth.c 2002/05/18 04:50:37 1.41.2.2 @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth.c,v 1.41 2002/03/19 15:31:47 markus Exp $"); +RCSID("$OpenBSD: auth.c,v 1.41.2.2 2002/05/18 04:50:37 jason Exp $"); #include @@ -40,10 +40,16 @@ #include "uidswap.h" #include "tildexpand.h" #include "misc.h" +#include "bufaux.h" +#include "packet.h" /* import */ extern ServerOptions options; +/* Debugging messages */ +Buffer auth_debug; +int auth_debug_init; + /* * Check if the user is allowed to log in via ssh. If user is listed * in DenyUsers or one of user's groups is listed in DenyGroups, false @@ -410,7 +416,7 @@ } #ifdef BSD_AUTH if ((as = auth_open()) == NULL || auth_setpwd(as, pw) != 0 || - auth_approval(NULL, lc, pw->pw_name, "ssh") <= 0) { + auth_approval(as, lc, pw->pw_name, "ssh") <= 0) { debug("Approval failure for %s", user); pw = NULL; } @@ -421,4 +427,44 @@ if (pw != NULL) return (pwcopy(pw)); return (NULL); +} + +void +auth_debug_add(const char *fmt,...) +{ + char buf[1024]; + va_list args; + + if (!auth_debug_init) + return; + + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); + buffer_put_cstring(&auth_debug, buf); +} + +void +auth_debug_send(void) +{ + char *msg; + + if (!auth_debug_init) + return; + while (buffer_len(&auth_debug)) { + msg = buffer_get_string(&auth_debug, NULL); + packet_send_debug("%s", msg); + xfree(msg); + } +} + +void +auth_debug_reset(void) +{ + if (auth_debug_init) + buffer_clear(&auth_debug); + else { + buffer_init(&auth_debug); + auth_debug_init = 1; + } }