mirror of
https://github.com/m1ngsama/TNT.git
synced 2025-12-24 10:51:41 +00:00
Fix passwordless login and display alignment issues
- Allow SSH_AUTH_METHOD_NONE for passwordless authentication - Replace all \n with \r\n in TUI rendering for proper line breaks - Fixes messages appearing misaligned on terminal
This commit is contained in:
parent
a4d67be103
commit
161fc904f3
2 changed files with 14 additions and 9 deletions
|
|
@ -126,7 +126,7 @@ static int read_username(client_t *client) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client_printf(client, "\n");
|
client_printf(client, "\r\n");
|
||||||
|
|
||||||
if (username[0] == '\0') {
|
if (username[0] == '\0') {
|
||||||
strcpy(client->username, "anonymous");
|
strcpy(client->username, "anonymous");
|
||||||
|
|
@ -458,8 +458,10 @@ static int handle_auth(ssh_session session) {
|
||||||
ssh_message_free(message);
|
ssh_message_free(message);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (ssh_message_subtype(message) == SSH_AUTH_METHOD_NONE) {
|
} else if (ssh_message_subtype(message) == SSH_AUTH_METHOD_NONE) {
|
||||||
/* Deny and ask for password */
|
/* Accept passwordless authentication for open chatroom */
|
||||||
ssh_message_auth_set_methods(message, SSH_AUTH_METHOD_PASSWORD);
|
ssh_message_auth_reply_success(message, 0);
|
||||||
|
ssh_message_free(message);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
15
src/tui.c
15
src/tui.c
|
|
@ -45,7 +45,7 @@ void tui_render_screen(client_t *client) {
|
||||||
for (int i = 0; i < padding; i++) {
|
for (int i = 0; i < padding; i++) {
|
||||||
buffer[pos++] = ' ';
|
buffer[pos++] = ' ';
|
||||||
}
|
}
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\n");
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\r\n");
|
||||||
|
|
||||||
/* Messages area */
|
/* Messages area */
|
||||||
int msg_height = client->height - 3;
|
int msg_height = client->height - 3;
|
||||||
|
|
@ -74,13 +74,14 @@ void tui_render_screen(client_t *client) {
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
char msg_line[1024];
|
char msg_line[1024];
|
||||||
message_format(&g_room->messages[i], msg_line, sizeof(msg_line), client->width);
|
message_format(&g_room->messages[i], msg_line, sizeof(msg_line), client->width);
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\n", msg_line);
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\r\n", msg_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_rwlock_unlock(&g_room->lock);
|
pthread_rwlock_unlock(&g_room->lock);
|
||||||
|
|
||||||
/* Fill empty lines */
|
/* Fill empty lines */
|
||||||
for (int i = end - start; i < msg_height; i++) {
|
for (int i = end - start; i < msg_height; i++) {
|
||||||
|
buffer[pos++] = '\r';
|
||||||
buffer[pos++] = '\n';
|
buffer[pos++] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,6 +92,7 @@ void tui_render_screen(client_t *client) {
|
||||||
memcpy(buffer + pos, line_char, len);
|
memcpy(buffer + pos, line_char, len);
|
||||||
pos += len;
|
pos += len;
|
||||||
}
|
}
|
||||||
|
buffer[pos++] = '\r';
|
||||||
buffer[pos++] = '\n';
|
buffer[pos++] = '\n';
|
||||||
|
|
||||||
/* Status/Input line */
|
/* Status/Input line */
|
||||||
|
|
@ -165,7 +167,7 @@ void tui_render_command_output(client_t *client) {
|
||||||
for (int i = 0; i < padding; i++) {
|
for (int i = 0; i < padding; i++) {
|
||||||
buffer[pos++] = ' ';
|
buffer[pos++] = ' ';
|
||||||
}
|
}
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\n");
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\r\n");
|
||||||
|
|
||||||
/* Command output */
|
/* Command output */
|
||||||
char *line = strtok(client->command_output, "\n");
|
char *line = strtok(client->command_output, "\n");
|
||||||
|
|
@ -181,7 +183,7 @@ void tui_render_command_output(client_t *client) {
|
||||||
utf8_truncate(truncated, client->width);
|
utf8_truncate(truncated, client->width);
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\n", truncated);
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\r\n", truncated);
|
||||||
line = strtok(NULL, "\n");
|
line = strtok(NULL, "\n");
|
||||||
line_count++;
|
line_count++;
|
||||||
}
|
}
|
||||||
|
|
@ -298,7 +300,7 @@ void tui_render_help(client_t *client) {
|
||||||
for (int i = 0; i < padding; i++) {
|
for (int i = 0; i < padding; i++) {
|
||||||
buffer[pos++] = ' ';
|
buffer[pos++] = ' ';
|
||||||
}
|
}
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\n");
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, ANSI_RESET "\r\n");
|
||||||
|
|
||||||
/* Help content */
|
/* Help content */
|
||||||
const char *help_text = tui_get_help_text(client->help_lang);
|
const char *help_text = tui_get_help_text(client->help_lang);
|
||||||
|
|
@ -321,11 +323,12 @@ void tui_render_help(client_t *client) {
|
||||||
if (end > line_count) end = line_count;
|
if (end > line_count) end = line_count;
|
||||||
|
|
||||||
for (int i = start; i < end && (i - start) < content_height - 1; i++) {
|
for (int i = start; i < end && (i - start) < content_height - 1; i++) {
|
||||||
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\n", lines[i]);
|
pos += snprintf(buffer + pos, sizeof(buffer) - pos, "%s\r\n", lines[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill remaining lines */
|
/* Fill remaining lines */
|
||||||
for (int i = end - start; i < content_height - 1; i++) {
|
for (int i = end - start; i < content_height - 1; i++) {
|
||||||
|
buffer[pos++] = '\r';
|
||||||
buffer[pos++] = '\n';
|
buffer[pos++] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue