The unified diff between revisions [3a1464ad..] and [5adf87e2..] is displayed below. It can also be downloaded as a raw diff.

#
#
# patch "account.c"
#  from [fb4a3d799f80de884ba1f6c703b6532900c192ef]
#    to [a2ee458ceb6d8adf8710f3791e18988c216bb361]
#
# patch "account.h"
#  from [2868cecce2e6b4ad1a78026da20de1f6d8371cb5]
#    to [8e151c6a66448f638664bbd3cf5d1e6c54ac9ee9]
#
# patch "session.h"
#  from [029633beee5cd56701332bc0fa563ae201223469]
#    to [fd587b1eb278e3baaa6b91854034f56644a0341d]
#
# patch "svr-auth.c"
#  from [68e708141e7525f929427ddd9751a90dd5370c8d]
#    to [ebaddb37b6dee06130eb3e029b8bcf15c51c07c0]
#
# patch "svr-session.c"
#  from [b43a0a676506ef61f10c21f4cd6e82c9fd5154a3]
#    to [afd15c30a45f8591bd907b709c8db792314f3119]
#
============================================================
--- account.c	fb4a3d799f80de884ba1f6c703b6532900c192ef
+++ account.c	a2ee458ceb6d8adf8710f3791e18988c216bb361
@@ -24,7 +24,8 @@ int isctrl = 0;
  * sure this is valid, what would dispense client for drinks do???)
  * If it isn't valid, sent DROPBEAR_FAILURE, else DROPBEAR_SUCCESS
  */
-int check_coke_user(char *name) {
+int check_coke_user(char *name, int *balance) {
+	*balance = -9999;

 	SetCokebankToSocks();
 	if (!name) {
@@ -33,7 +34,12 @@ int check_coke_user(char *name) {
 	}

 	isctrl = InCokeControl(name);
-	if(!cokebank_open() || cokebank_get(name)-(isctrl?COKE_CONTROLLERS_MIN:0)<CONNECT_MIN) {
+	if (!cokebank_open()) {
+		return DROPBEAR_FAILURE;
+	}
+
+	*balance = cokebank_get(name);
+	if (*balance-(isctrl?COKE_CONTROLLERS_MIN:0)<CONNECT_MIN) {
 		cokebank_close();
 		return DROPBEAR_FAILURE;
 	}
============================================================
--- account.h	2868cecce2e6b4ad1a78026da20de1f6d8371cb5
+++ account.h	8e151c6a66448f638664bbd3cf5d1e6c54ac9ee9
@@ -1,7 +1,7 @@
 #ifndef ACCOUNT_H
 #define ACCOUNT_H

-int check_coke_user(char *name);
+int check_coke_user(char *name, int *balance);
 void acct_reset();
 void acct_add(size_t r, size_t w);
 void acct_report();
============================================================
--- session.h	029633beee5cd56701332bc0fa563ae201223469
+++ session.h	fd587b1eb278e3baaa6b91854034f56644a0341d
@@ -51,6 +51,7 @@ void svr_dropbear_log(int priority, cons
 void svr_session(int sock, int childpipe, char *remotehost, char *addrstring);
 void svr_dropbear_exit(int exitcode, const char* format, va_list param);
 void svr_dropbear_log(int priority, const char* format, va_list param);
+void send_msg_debug(const char* message, int always_show);

 /* Client */
 void cli_session(int sock, char *remotehost);
============================================================
--- svr-auth.c	68e708141e7525f929427ddd9751a90dd5370c8d
+++ svr-auth.c	ebaddb37b6dee06130eb3e029b8bcf15c51c07c0
@@ -278,15 +278,6 @@ goodshell:
 	endusershell();
 	TRACE(("matching shell"))

-	/* check for coke balance good */
-	if (check_coke_user(username) == DROPBEAR_FAILURE) {
-		dropbear_log(LOG_WARNING,
-				"disallowing login for '%s' cokebank balance low, bad, etc",
-				username);
-		send_msg_userauth_failure(0, 1);
-		return DROPBEAR_FAILURE;
-	}
-
 	TRACE(("uid = %d", ses.authstate.pw->pw_uid))
 	TRACE(("leave checkusername"))
 	return DROPBEAR_SUCCESS;
@@ -359,8 +350,22 @@ void send_msg_userauth_success() {
 /* Send a success message to the user, and set the "authdone" flag */
 void send_msg_userauth_success() {

+	int balance = 0;
 	TRACE(("enter send_msg_userauth_success"))

+	/* check for coke balance good */
+	if (check_coke_user(username, &balance) == DROPBEAR_FAILURE) {
+		char printbuf;
+		dropbear_log(LOG_WARNING,
+				"disallowing login for '%s' cokebank balance low, bad, etc",
+				username);
+		snprintf(printbuf, sizeof(printbuf), "coke balance (%dc) is too low",
+				balance);
+		send_msg_debug(printbuf, 1);
+		send_msg_userauth_failure(0, 1);
+		return;
+	}
+
 	CHECKCLEARTOWRITE();

 	buf_putbyte(ses.writepayload, SSH_MSG_USERAUTH_SUCCESS);
============================================================
--- svr-session.c	b43a0a676506ef61f10c21f4cd6e82c9fd5154a3
+++ svr-session.c	afd15c30a45f8591bd907b709c8db792314f3119
@@ -199,3 +199,13 @@ static void svr_remoteclosed() {

 }

+
+void send_msg_debug(const char* message, int always_show) {
+	CHECKCLEARTOWRITE();
+
+	buf_putbyte(ses.writepayload, SSH_MSG_DEBUG);
+	buf_putbyte(ses.writepayload, always_show ? 1 : 0);
+	buf_putstring(message, strlen(message));
+	buf_putstring("", 0);
+	encrypt_packet();
+}