Skip to content

Commit 3fc7d6f

Browse files
author
Rafał Miłecki
committed
Extract & log authentication challenge message
When gateway replies with a challenge it (usually?) provides a relevant message. Example: ret=6,actionurl=/remote/logincheck,magic=1-12345678,reqid=0,grpid=1,pid=249,is_chal_rsp=1,pass_renew=1,allow_cancel=1,chal_msg=Your password will expire in 3 days. Would you like to change it? Extract such messages and log them so user can understand what went wrong. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
1 parent c958500 commit 3fc7d6f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/http.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ int auth_log_in(struct tunnel *tunnel)
718718
ret = get_value_from_response(res, "ret=", auth_ret_text, 8);
719719
if (ret == 1) {
720720
int auth_ret = strtol(auth_ret_text, NULL, 10);
721+
char chal_msg[128];
721722

722723
switch (auth_ret) {
723724
case 0:
@@ -728,7 +729,14 @@ int auth_log_in(struct tunnel *tunnel)
728729
log_debug("Authentication succeeded\n");
729730
break;
730731
case 6:
731-
log_error("Gateway replied to authentication with a challenge that is unsupported right now\n");
732+
log_info("Gateway replied to authentication with a challenge\n");
733+
734+
ret = get_value_from_response(res, "chal_msg=", chal_msg, 128);
735+
if (ret == 1)
736+
log_info("Challenge message: \"%s\"\n", chal_msg);
737+
738+
log_error("Challenges are unsupported right now\n");
739+
732740
ret = ERR_HTTP_PERMISSION;
733741
goto end;
734742
default:

0 commit comments

Comments
 (0)