Skip to content

Commit 4f9e442

Browse files
author
roman
committed
session server ssh BUGFIX add null checks to auth
Fixes #469
1 parent 29f2f02 commit 4f9e442

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/session_server_ssh.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,11 @@ nc_sshcb_auth_password(struct nc_session *session, struct nc_auth_client *auth_c
449449
{
450450
int auth_ret = 1;
451451

452-
auth_ret = auth_password_compare_pwd(auth_client->password, ssh_message_auth_password(msg));
452+
if (!auth_client->password) {
453+
VRB(session, "User \"%s\" does not have password method configured, but a request was received.", auth_client->username);
454+
} else {
455+
auth_ret = auth_password_compare_pwd(auth_client->password, ssh_message_auth_password(msg));
456+
}
453457

454458
if (auth_ret) {
455459
++session->opts.server.ssh_auth_attempts;
@@ -897,7 +901,9 @@ nc_sshcb_auth_kbdint(struct nc_session *session, struct nc_auth_client *client,
897901
{
898902
int auth_ret = 1;
899903

900-
if (server_opts.interactive_auth_clb) {
904+
if (!client->kb_int_enabled) {
905+
VRB(session, "User \"%s\" does not have Keyboard-interactive method configured, but a request was received.", client->username);
906+
} else if (server_opts.interactive_auth_clb) {
901907
auth_ret = server_opts.interactive_auth_clb(session, session->ti.libssh.session, msg, server_opts.interactive_auth_data);
902908
} else {
903909
#ifdef HAVE_LIBPAM
@@ -1504,6 +1510,10 @@ nc_session_ssh_msg(struct nc_session *session, struct nc_server_ssh_opts *opts,
15041510
ret = nc_sshcb_auth_pubkey(session, auth_client, msg);
15051511
} else if (subtype == SSH_AUTH_METHOD_INTERACTIVE) {
15061512
ret = nc_sshcb_auth_kbdint(session, auth_client, msg);
1513+
} else {
1514+
VRB(session, "Authentication method \"%s\" not supported.", str_subtype);
1515+
ssh_message_reply_default(msg);
1516+
return 0;
15071517
}
15081518

15091519
if (!ret) {

0 commit comments

Comments
 (0)