Skip to content

Commit

Permalink
cli-runopts.c: add PasswordAuthentication option
Browse files Browse the repository at this point in the history
  • Loading branch information
stokito committed Dec 24, 2023
1 parent 7df5009 commit e07d133
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cli-auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void recv_msg_userauth_failure() {
}
#endif
#if DROPBEAR_CLI_PASSWORD_AUTH
if (strncmp(AUTH_METHOD_PASSWORD, tok,
if (cli_opts.password_authentication && strncmp(AUTH_METHOD_PASSWORD, tok,
AUTH_METHOD_PASSWORD_LEN) == 0) {
ses.authstate.authtypes |= AUTH_TYPE_PASSWORD;
}
Expand Down Expand Up @@ -311,7 +311,7 @@ int cli_auth_try() {
#endif

#if DROPBEAR_CLI_PASSWORD_AUTH
if (!finished && (ses.authstate.authtypes & AUTH_TYPE_PASSWORD)) {
if (!finished && cli_opts.password_authentication && (ses.authstate.authtypes & AUTH_TYPE_PASSWORD)) {
if (ses.keys->trans.algo_crypt->cipherdesc == NULL) {
fprintf(stderr, "Sorry, I won't let you use password auth unencrypted.\n");
} else {
Expand Down
9 changes: 9 additions & 0 deletions src/cli-runopts.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void cli_getopts(int argc, char ** argv) {
cli_opts.exit_on_fwd_failure = 0;
#endif
cli_opts.disable_trivial_auth = 0;
cli_opts.password_authentication = 1;
#if DROPBEAR_CLI_LOCALTCPFWD
cli_opts.localfwds = list_new();
opts.listen_fwd_all = 0;
Expand Down Expand Up @@ -902,6 +903,7 @@ static void add_extendedopt(const char* origstr) {
#if DROPBEAR_CLI_PUBKEY_AUTH
"\tIdentityFile\n"
#endif
"\tPasswordAuthentication\n"
"\tPort\n"
#if DROPBEAR_CLI_PROXYCMD
"\tProxyCommand\n"
Expand Down Expand Up @@ -953,6 +955,13 @@ static void add_extendedopt(const char* origstr) {
}
#endif

#if DROPBEAR_CLI_PASSWORD_AUTH
if (match_extendedopt(&optstr, "PasswordAuthentication") == DROPBEAR_SUCCESS) {
cli_opts.password_authentication = parse_flag_value(optstr);
return;
}
#endif

if (match_extendedopt(&optstr, "Port") == DROPBEAR_SUCCESS) {
cli_opts.remoteport = optstr;
return;
Expand Down
1 change: 1 addition & 0 deletions src/runopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ typedef struct cli_runopts {
int exit_on_fwd_failure;
#endif
int disable_trivial_auth;
int password_authentication;
#if DROPBEAR_CLI_REMOTETCPFWD
m_list * remotefwds;
#endif
Expand Down

0 comments on commit e07d133

Please sign in to comment.