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

Rename: tmate-slave -> tmate-ssh-server

This commit is contained in:
Nicolas Viennot 2019-04-10 08:56:37 -04:00
parent 55ffd5b64b
commit 9c45f61585
9 changed files with 47 additions and 46 deletions

2
.gitignore vendored
View File

@ -17,7 +17,7 @@ Makefile
Makefile.in Makefile.in
configure configure
keys/ keys/
tmate-slave tmate-ssh-server
cscope.* cscope.*
tags tags
tmux.1.* tmux.1.*

View File

@ -1,12 +1,12 @@
# tmate-slave, see https://tmate.io/ # tmate-ssh-server, see https://tmate.io/
# #
# Example usage: # Example usage:
# #
# docker run --privileged --rm -i -p 22:22 \ # docker run --privileged --rm -i -p 22:22 \
# -v /etc/tmate/keys:/daemon-keys \ # -v /etc/tmate/keys:/daemon-keys \
# -v /etc/tmate/authorized_keys:/authorized-keys \ # -v /etc/tmate/authorized_keys:/authorized-keys \
# varac/tmate-slave \ # varac/tmate-ssh-server \
# /bin/sh -c "/sbin/tmate-slave -k /daemon-keys -a /authorized-keys -b 0.0.0.0 -p 22 -v -v -v -h SERVER_FQDN" # /bin/sh -c "/sbin/tmate-ssh-server -k /daemon-keys -a /authorized-keys -b 0.0.0.0 -p 22 -v -v -v -h SERVER_FQDN"
FROM debian:jessie-slim FROM debian:jessie-slim
@ -24,17 +24,17 @@ RUN mkdir /src && cd /src/ &&\
# jessie-backports provides 3.6.2 but this pulls too many dependencies in. # jessie-backports provides 3.6.2 but this pulls too many dependencies in.
git clone -b libssh-0.7.6 git://git.libssh.org/projects/libssh.git &&\ git clone -b libssh-0.7.6 git://git.libssh.org/projects/libssh.git &&\
git clone https://github.com/msgpack/msgpack-c.git &&\ git clone https://github.com/msgpack/msgpack-c.git &&\
git clone https://github.com/tmate-io/tmate-slave.git git clone https://github.com/tmate-io/tmate-ssh-server.git
RUN cd /src/libssh &&\ RUN cd /src/libssh &&\
mkdir build && cd build && cmake .. && make install mkdir build && cd build && cmake .. && make install
RUN cd /src/msgpack-c &&\ RUN cd /src/msgpack-c &&\
mkdir build && cd build && cmake .. && make install mkdir build && cd build && cmake .. && make install
RUN cd /src/tmate-slave &&\ RUN cd /src/tmate-ssh-server &&\
sh autogen.sh && PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure && make sh autogen.sh && PKG_CONFIG_PATH=/usr/local/lib/pkgconfig ./configure && make
RUN cp /src/tmate-slave/tmate-slave /sbin/ RUN cp /src/tmate-ssh-server/tmate-ssh-server /sbin/
# Clean up # Clean up
RUN rm -rf /src RUN rm -rf /src

View File

@ -1,7 +1,7 @@
# Makefile.am # Makefile.am
# Obvious program stuff. # Obvious program stuff.
bin_PROGRAMS = tmate-slave bin_PROGRAMS = tmate-ssh-server
CLEANFILES = tmate.1.mdoc tmate.1.man CLEANFILES = tmate.1.mdoc tmate.1.man
# Distribution tarball options. # Distribution tarball options.
@ -72,7 +72,7 @@ DEFS += -D_LINUX_SOURCE_COMPAT=1
endif endif
# List of sources. # List of sources.
dist_tmate_slave_SOURCES = \ dist_tmate_ssh_server_SOURCES = \
alerts.c \ alerts.c \
arguments.c \ arguments.c \
attributes.c \ attributes.c \
@ -185,7 +185,7 @@ dist_tmate_slave_SOURCES = \
tmate-daemon-legacy.c \ tmate-daemon-legacy.c \
tmate-msgpack.c \ tmate-msgpack.c \
tmate-proxy.c \ tmate-proxy.c \
tmate-slave.c \ tmate-main.c \
tmate-ssh-client-pty.c \ tmate-ssh-client-pty.c \
tmate-ssh-daemon.c \ tmate-ssh-daemon.c \
tmate-ssh-exec.c \ tmate-ssh-exec.c \
@ -203,63 +203,63 @@ dist_tmate_slave_SOURCES = \
window.c \ window.c \
xmalloc.c \ xmalloc.c \
xterm-keys.c xterm-keys.c
nodist_tmate_slave_SOURCES = osdep-@PLATFORM@.c nodist_tmate_ssh_server_SOURCES = osdep-@PLATFORM@.c
# Pile in all the compat/ stuff that is needed. # Pile in all the compat/ stuff that is needed.
if NO_FORKPTY if NO_FORKPTY
nodist_tmate_slave_SOURCES += compat/forkpty-@PLATFORM@.c nodist_tmate_ssh_server_SOURCES += compat/forkpty-@PLATFORM@.c
endif endif
if NO_IMSG if NO_IMSG
nodist_tmate_slave_SOURCES += compat/imsg.c compat/imsg-buffer.c nodist_tmate_ssh_server_SOURCES += compat/imsg.c compat/imsg-buffer.c
endif endif
if NO_CLOSEFROM if NO_CLOSEFROM
nodist_tmate_slave_SOURCES += compat/closefrom.c nodist_tmate_ssh_server_SOURCES += compat/closefrom.c
endif endif
if NO_DAEMON if NO_DAEMON
nodist_tmate_slave_SOURCES += compat/daemon.c nodist_tmate_ssh_server_SOURCES += compat/daemon.c
endif endif
if NO_SETENV if NO_SETENV
nodist_tmate_slave_SOURCES += compat/setenv.c nodist_tmate_ssh_server_SOURCES += compat/setenv.c
endif endif
if NO_STRLCAT if NO_STRLCAT
nodist_tmate_slave_SOURCES += compat/strlcat.c nodist_tmate_ssh_server_SOURCES += compat/strlcat.c
endif endif
if NO_STRLCPY if NO_STRLCPY
nodist_tmate_slave_SOURCES += compat/strlcpy.c nodist_tmate_ssh_server_SOURCES += compat/strlcpy.c
endif endif
if NO_ASPRINTF if NO_ASPRINTF
nodist_tmate_slave_SOURCES += compat/asprintf.c nodist_tmate_ssh_server_SOURCES += compat/asprintf.c
endif endif
if NO_FGETLN if NO_FGETLN
nodist_tmate_slave_SOURCES += compat/fgetln.c nodist_tmate_ssh_server_SOURCES += compat/fgetln.c
endif endif
if NO_FPARSELN if NO_FPARSELN
nodist_tmate_slave_SOURCES += compat/fparseln.c nodist_tmate_ssh_server_SOURCES += compat/fparseln.c
endif endif
if NO_GETOPT if NO_GETOPT
nodist_tmate_slave_SOURCES += compat/getopt.c nodist_tmate_ssh_server_SOURCES += compat/getopt.c
endif endif
if NO_STRCASESTR if NO_STRCASESTR
nodist_tmate_slave_SOURCES += compat/strcasestr.c nodist_tmate_ssh_server_SOURCES += compat/strcasestr.c
endif endif
if NO_STRSEP if NO_STRSEP
nodist_tmate_slave_SOURCES += compat/strsep.c nodist_tmate_ssh_server_SOURCES += compat/strsep.c
endif endif
if NO_VIS if NO_VIS
nodist_tmate_slave_SOURCES += compat/vis.c compat/unvis.c nodist_tmate_ssh_server_SOURCES += compat/vis.c compat/unvis.c
endif endif
if NO_STRTONUM if NO_STRTONUM
nodist_tmate_slave_SOURCES += compat/strtonum.c nodist_tmate_ssh_server_SOURCES += compat/strtonum.c
endif endif
if NO_B64_NTOP if NO_B64_NTOP
nodist_tmate_slave_SOURCES += compat/b64_ntop.c nodist_tmate_ssh_server_SOURCES += compat/b64_ntop.c
endif endif
if NO_CFMAKERAW if NO_CFMAKERAW
nodist_tmate_slave_SOURCES += compat/cfmakeraw.c nodist_tmate_ssh_server_SOURCES += compat/cfmakeraw.c
endif endif
if NO_OPENAT if NO_OPENAT
nodist_tmate_slave_SOURCES += compat/openat.c nodist_tmate_ssh_server_SOURCES += compat/openat.c
endif endif
if NO_REALLOCARRAY if NO_REALLOCARRAY
nodist_tmate_slave_SOURCES += compat/reallocarray.c nodist_tmate_ssh_server_SOURCES += compat/reallocarray.c
endif endif

View File

@ -1,7 +1,7 @@
tmate server side tmate server side
================== ==================
tmate-slave is the server side part of [tmate.io](http://tmate.io/). tmate-ssh-server is the server side part of [tmate.io](http://tmate.io/).
Usage Usage
----- -----

View File

@ -27,7 +27,7 @@ loop do
Dir['/proc/*/cmdline'].map do |f| Dir['/proc/*/cmdline'].map do |f|
if File.read(f) =~ /^tmate-slave \[(.+)\] \((.+)\) (.+)$/ if File.read(f) =~ /^tmate-ssh-server \[(.+)\] \((.+)\) (.+)$/
token = $1 token = $1
role = $2 role = $2
ip = $3 ip = $3

View File

@ -103,7 +103,7 @@ void request_server_termination(void)
static void usage(void) static void usage(void)
{ {
fprintf(stderr, "usage: tmate-slave [-b ip] [-h hostname] [-k keys_dir] [-a authorized_keys_path] [-p port] [-x proxy_hostname] [-q proxy_port] [-s] [-v]\n"); fprintf(stderr, "usage: tmate-ssh-server [-b ip] [-h hostname] [-k keys_dir] [-a authorized_keys_path] [-p port] [-x proxy_hostname] [-q proxy_port] [-s] [-v]\n");
} }
static char* get_full_hostname(void) static char* get_full_hostname(void)
@ -259,7 +259,7 @@ void set_session_token(struct tmate_session *session,
socket_path = path; socket_path = path;
memset(cmdline, 0, cmdline_end - cmdline); memset(cmdline, 0, cmdline_end - cmdline);
sprintf(cmdline, "tmate-slave [%s] %s %s", sprintf(cmdline, "tmate-ssh-server [%s] %s %s",
session->session_token, session->session_token,
session->ssh_client.role == TMATE_ROLE_DAEMON ? "(daemon)" : "(pty client)", session->ssh_client.role == TMATE_ROLE_DAEMON ? "(daemon)" : "(pty client)",
session->ssh_client.ip_address); session->ssh_client.ip_address);
@ -415,7 +415,7 @@ static void handle_sigterm(__unused int sig)
request_server_termination(); request_server_termination();
} }
static void tmate_spawn_slave_daemon(struct tmate_session *session) static void tmate_spawn_daemon(struct tmate_session *session)
{ {
struct tmate_ssh_client *client = &session->ssh_client; struct tmate_ssh_client *client = &session->ssh_client;
char *token; char *token;
@ -429,7 +429,7 @@ static void tmate_spawn_slave_daemon(struct tmate_session *session)
set_session_token(session, token); set_session_token(session, token);
free(token); free(token);
tmate_notice("Spawning slave server for %s at %s (%s)", tmate_notice("Spawning daemon for %s at %s (%s)",
client->username, client->ip_address, client->pubkey); client->username, client->ip_address, client->pubkey);
session->tmux_socket_fd = server_create_socket(); session->tmux_socket_fd = server_create_socket();
@ -460,7 +460,7 @@ static void tmate_spawn_slave_daemon(struct tmate_session *session)
/* never reached */ /* never reached */
} }
static void tmate_spawn_slave_pty_client(struct tmate_session *session) static void tmate_spawn_pty_client(struct tmate_session *session)
{ {
struct tmate_ssh_client *client = &session->ssh_client; struct tmate_ssh_client *client = &session->ssh_client;
char *argv_rw[] = {(char *)"attach", NULL}; char *argv_rw[] = {(char *)"attach", NULL};
@ -479,7 +479,7 @@ static void tmate_spawn_slave_pty_client(struct tmate_session *session)
set_session_token(session, token); set_session_token(session, token);
tmate_notice("Spawning slave client for %s (%s)", tmate_notice("Spawning pty client for %s (%s)",
client->ip_address, client->pubkey); client->ip_address, client->pubkey);
session->tmux_socket_fd = client_connect(session->ev_base, socket_path, 0); session->tmux_socket_fd = client_connect(session->ev_base, socket_path, 0);
@ -531,7 +531,7 @@ static void tmate_spawn_slave_pty_client(struct tmate_session *session)
exit(ret); exit(ret);
} }
static void tmate_spawn_slave_exec(struct tmate_session *session) static void tmate_spawn_exec(struct tmate_session *session)
{ {
close_fds_except((int[]){ssh_get_fd(session->ssh_client.session), close_fds_except((int[]){ssh_get_fd(session->ssh_client.session),
log_file ? fileno(log_file) : -1, log_file ? fileno(log_file) : -1,
@ -546,11 +546,11 @@ static void tmate_spawn_slave_exec(struct tmate_session *session)
exit(0); exit(0);
} }
void tmate_spawn_slave(struct tmate_session *session) void tmate_spawn(struct tmate_session *session)
{ {
switch (session->ssh_client.role) { switch (session->ssh_client.role) {
case TMATE_ROLE_DAEMON: tmate_spawn_slave_daemon(session); break; case TMATE_ROLE_DAEMON: tmate_spawn_daemon(session); break;
case TMATE_ROLE_PTY_CLIENT: tmate_spawn_slave_pty_client(session); break; case TMATE_ROLE_PTY_CLIENT: tmate_spawn_pty_client(session); break;
case TMATE_ROLE_EXEC: tmate_spawn_slave_exec(session); break; case TMATE_ROLE_EXEC: tmate_spawn_exec(session); break;
} }
} }

1
tmate-slave Symbolic link
View File

@ -0,0 +1 @@
tmate-ssh-server

View File

@ -277,7 +277,7 @@ static void client_bootstrap(struct tmate_session *_session)
tmate_start_ssh_latency_probes(client, &ssh_server_cb, TMATE_SSH_KEEPALIVE * 1000); tmate_start_ssh_latency_probes(client, &ssh_server_cb, TMATE_SSH_KEEPALIVE * 1000);
register_on_ssh_read(client); register_on_ssh_read(client);
tmate_spawn_slave(_session); tmate_spawn(_session);
/* never reached */ /* never reached */
} }

View File

@ -189,7 +189,7 @@ struct tmate_ssh_client {
extern void tmate_ssh_server_main(struct tmate_session *session, extern void tmate_ssh_server_main(struct tmate_session *session,
const char *keys_dir, const char *bind_addr, int port); const char *keys_dir, const char *bind_addr, int port);
/* tmate-slave.c */ /* tmate-main.c */
#ifdef DEVENV #ifdef DEVENV
#define TMATE_SSH_DEFAULT_PORT 2200 #define TMATE_SSH_DEFAULT_PORT 2200
@ -259,7 +259,7 @@ extern struct tmate_session *tmate_session;
extern void tmate_get_random_bytes(void *buffer, ssize_t len); extern void tmate_get_random_bytes(void *buffer, ssize_t len);
extern long tmate_get_random_long(void); extern long tmate_get_random_long(void);
extern void request_server_termination(void); extern void request_server_termination(void);
extern void tmate_spawn_slave(struct tmate_session *session); extern void tmate_spawn(struct tmate_session *session);
extern void set_session_token(struct tmate_session *session, const char *token); extern void set_session_token(struct tmate_session *session, const char *token);
/* tmate-proxy.c */ /* tmate-proxy.c */