/**************************************************************************** Callback for Connect button. ****************************************************************************/ void connectdlg_connect_callback(Widget w, XtPointer client_data, XtPointer call_data) { XtPointer pxp; char errbuf[512]; struct packet_authentication_reply reply; switch (connection_status) { case LOGIN_TYPE: XtVaGetValues(connectdlg_host_text, XtNstring, &pxp, NULL); sz_strlcpy(server_host, (char *)pxp); XtVaGetValues(connectdlg_port_text, XtNstring, &pxp, NULL); sscanf((char *)pxp, "%d", &server_port); XtVaGetValues(connectdlg_login_text, XtNstring, &pxp, NULL); sz_strlcpy(user_name, (char *)pxp); if (connect_to_server(user_name, server_host, server_port, errbuf, sizeof(errbuf)) != -1) { popup_start_page(); connectdlg_destroy(); XtSetSensitive(toplevel, True); return; } else { XtVaSetValues(connectdlg_message_label, XtNlabel, errbuf, NULL); output_window_append(ftc_client, errbuf); } break; case NEW_PASSWORD_TYPE: XtVaGetValues(connectdlg_password_text, XtNstring, &pxp, NULL); sz_strlcpy(password, (char *)pxp); XtVaGetValues(connectdlg_verify_text, XtNstring, &pxp, NULL); sz_strlcpy(reply.password, (char *)pxp); if (strncmp(reply.password, password, MAX_LEN_NAME) == 0) { password[0] = '\0'; send_packet_authentication_reply(&client.conn, &reply); XtVaSetValues(connectdlg_message_label, XtNlabel, "", NULL); XtVaSetValues(connectdlg_password_text, XtNsensitive, False, NULL); XtVaSetValues(connectdlg_verify_text, XtNsensitive, False, NULL); } else { XtVaSetValues(connectdlg_password_text, XtNstring, "", NULL); XtVaSetValues(connectdlg_verify_text, XtNstring, "", NULL); XtVaSetValues(connectdlg_message_label, XtNlabel, _("Passwords don't match, enter password."), NULL); output_window_append(ftc_client, _("Passwords don't match, enter password.")); } break; case ENTER_PASSWORD_TYPE: XtVaGetValues(connectdlg_verify_text, XtNstring, &pxp, NULL); sz_strlcpy(reply.password, (char *)pxp); send_packet_authentication_reply(&client.conn, &reply); XtVaSetValues(connectdlg_message_label, XtNlabel, "", NULL); XtVaSetValues(connectdlg_password_text, XtNsensitive, False, NULL); XtVaSetValues(connectdlg_verify_text, XtNsensitive, False, NULL); break; case WAITING_TYPE: break; } }
/************************************************************************** Configure the dialog depending on what type of authentication request the server is making. **************************************************************************/ void handle_authentication_req(enum authentication_type type, const char *message) { switch (type) { case AUTH_NEWUSER_FIRST: /* PORTME: switch configs if need be */ return; case AUTH_NEWUSER_RETRY: /* PORTME: switch configs if need be */ return; case AUTH_LOGIN_FIRST: /* if we magically have a password already present in 'password' * then, use that and skip the password entry dialog */ if (password[0] != '\0') { struct packet_authentication_reply reply; sz_strlcpy(reply.password, password); send_packet_authentication_reply(&client.conn, &reply); return; } else { /* PORTME: switch configs if need be */ } return; case AUTH_LOGIN_RETRY: /* PORTME: switch configs if need be */ return; } log_error("Unsupported authentication type %d: %s.", type, message); }
/************************************************************************** configure the dialog depending on what type of authentication request the server is making. **************************************************************************/ void handle_authentication_req(enum authentication_type type, const char *message) { XtVaSetValues(connectdlg_message_label, XtNlabel, message, NULL); switch (type) { case AUTH_NEWUSER_FIRST: case AUTH_NEWUSER_RETRY: XtVaSetValues(connectdlg_password_text, XtNsensitive, True, NULL); XtVaSetValues(connectdlg_verify_text, XtNsensitive, True, NULL); connection_status = NEW_PASSWORD_TYPE; break; case AUTH_LOGIN_FIRST: /* if we magically have a password already present in 'password' * then, use that and skip the password entry dialog */ if (password[0] != '\0') { struct packet_authentication_reply reply; sz_strlcpy(reply.password, password); send_packet_authentication_reply(&client.conn, &reply); return; } else { XtVaSetValues(connectdlg_password_text, XtNsensitive, True, NULL); XtVaSetValues(connectdlg_verify_text, XtNsensitive, False, NULL); connection_status = ENTER_PASSWORD_TYPE; } break; case AUTH_LOGIN_RETRY: XtVaSetValues(connectdlg_password_text, XtNsensitive, True, NULL); XtVaSetValues(connectdlg_verify_text, XtNsensitive, False, NULL); connection_status = ENTER_PASSWORD_TYPE; break; default: log_error("Unsupported authentication type %d: %s.", type, message); break; } }
void authenticate(const char* password) { struct packet_authentication_reply reply; sz_strlcpy(reply.password, password); send_packet_authentication_reply(&client.conn, &reply); }