1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Display warnings when trying to use named sessions without the websocket server

This commit is contained in:
Nicolas Viennot 2019-11-07 08:26:24 -05:00
parent 6c41248dad
commit 4b79571357
3 changed files with 27 additions and 2 deletions

View File

@ -80,7 +80,7 @@ static void tmate_set(char *key, char *value)
append_authorized_key(value); append_authorized_key(value);
} }
void tmate_hook_set_option(const char *name, const char *val) void tmate_hook_set_option_auth(const char *name, const char *val)
{ {
if (!strcmp(name, "tmate-authorized-keys")) { if (!strcmp(name, "tmate-authorized-keys")) {
reset_and_enable_authorized_keys(); reset_and_enable_authorized_keys();

View File

@ -185,3 +185,27 @@ void tmate_spawn_daemon(struct tmate_session *session)
server_start(session->ev_base, -1, NULL); server_start(session->ev_base, -1, NULL);
/* never reached */ /* never reached */
} }
static void handle_session_name_options(const char *name, __unused const char *val)
{
if (tmate_has_websocket())
return;
if (!strcmp(name, "tmate-account-key") ||
!strcmp(name, "tmate-session-name") ||
!strcmp(name, "tmate-session-name-ro")) {
static bool warned;
if (!warned) {
tmate_warn("/!\\ Named sessions are not supported without the websocket server");
tmate_notify("/!\\ Named sessions are not supported without the websocket server");
}
warned = true;
}
}
void tmate_hook_set_option(const char *name, const char *val)
{
tmate_hook_set_option_auth(name, val);
handle_session_name_options(name, val);
}

View File

@ -34,7 +34,7 @@ extern void printflike(2, 3) tmate_log(int level, const char *msg, ...);
}) })
/* tmate-auth-keys.c */ /* tmate-auth-keys.c */
extern void tmate_hook_set_option(const char *name, const char *val); extern void tmate_hook_set_option_auth(const char *name, const char *val);
extern bool tmate_allow_auth(const char *pubkey); extern bool tmate_allow_auth(const char *pubkey);
extern bool would_tmate_session_allow_auth(const char *token, const char *pubkey); extern bool would_tmate_session_allow_auth(const char *token, const char *pubkey);
extern int get_num_authorized_keys(ssh_key *keys); extern int get_num_authorized_keys(ssh_key *keys);
@ -134,6 +134,7 @@ extern void tmate_dispatch_daemon_message(struct tmate_session *session,
#define TMATE_KEYFRAME_MAX_SIZE 1024*1024 #define TMATE_KEYFRAME_MAX_SIZE 1024*1024
extern void tmate_spawn_daemon(struct tmate_session *session); extern void tmate_spawn_daemon(struct tmate_session *session);
extern void tmate_hook_set_option(const char *name, const char *val);
/* tmate-ssh-exec.c */ /* tmate-ssh-exec.c */
extern void tmate_spawn_exec(struct tmate_session *session); extern void tmate_spawn_exec(struct tmate_session *session);