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

Developer Environement setup

This commit is contained in:
Nicolas Viennot 2013-06-11 17:00:30 -04:00
parent 3ee065ce52
commit def38c984a
5 changed files with 27 additions and 10 deletions

View File

@ -24,6 +24,9 @@ endif
CFLAGS += -Wno-unused-parameter -Wno-unused-variable
CFLAGS += -Ilibssh/include/ -Imsgpack/src
if IS_DEVENV
CFLAGS += -DDEVENV
endif
# Set flags for gcc. gcc4 whines abouts silly stuff so it needs slightly
# different flags.

View File

@ -40,6 +40,13 @@ AC_CHECK_HEADERS(
]
)
AC_ARG_ENABLE(
devenv,
AC_HELP_STRING(--enable-devenv, "dev env (port 2200, no random tokens)"),
found_devenv=$enable_devenv
)
AM_CONDITIONAL(IS_DEVENV, test "x$found_devenv" = xyes)
# Is this a debug build?
#found_debug=yes
AC_ARG_ENABLE(

3
log.c
View File

@ -27,6 +27,7 @@
#include <unistd.h>
#include "tmux.h"
#include "tmate.h"
/* Log file, if needed. */
FILE *log_file;
@ -84,7 +85,7 @@ log_vwrite(const char *msg, va_list ap)
if (log_file == NULL)
return;
if (asprintf(&fmt, "[%d] %s\n", getpid(), msg) == -1)
if (asprintf(&fmt, "[%s] %s\n", tmate_session_token, msg) == -1)
exit(1);
if (vfprintf(log_file, fmt, ap) == -1)
exit(1);

View File

@ -16,7 +16,7 @@
struct tmate_encoder *tmate_encoder;
int tmux_socket_fd;
const char *tmate_session_token;
const char *tmate_session_token = "main";
extern FILE *log_file;
extern int server_create_socket(void);
@ -30,7 +30,7 @@ static void usage(void)
int main(int argc, char **argv)
{
int opt;
int port = 22;
int port = TMATE_DEFAULT_PORT;
char *log_path = NULL; /* stderr */
while ((opt = getopt(argc, argv, "p:l:v")) != -1) {
@ -78,16 +78,15 @@ static char *get_random_token(void)
int i;
char *token = xmalloc(TMATE_TOKEN_LEN + 1);
#if 0
strcpy(token, "TOKENTOKENTOKENTOKENTOKEN");
return token;
#endif
ssh_get_random(token, TMATE_TOKEN_LEN, 0);
for (i = 0; i < TMATE_TOKEN_LEN; i++)
token[i] = tmate_token_digits[token[i] % NUM_DIGITS];
token[i] = 0;
#ifdef DEVENV
strcpy(token, "SUPERSECURETOKENFORDEVENV");
#endif
return token;
}
@ -209,7 +208,7 @@ static void tmate_spawn_slave_server(struct tmate_ssh_client *client)
set_session_token(token);
free(token);
tmate_debug("Spawning tmux slave server %s", tmate_session_token);
tmate_debug("Spawning tmux slave server");
tmux_socket_fd = server_create_socket();
if (tmux_socket_fd < 0)
@ -250,7 +249,7 @@ static void tmate_spawn_slave_client(struct tmate_ssh_client *client)
set_session_token(token);
tmate_debug("Spawn tmux slave client %s", tmate_session_token);
tmate_debug("Spawn tmux slave client");
tmux_socket_fd = client_connect(socket_path, 0);
if (tmux_socket_fd < 0) {

View File

@ -100,12 +100,19 @@ extern void tmate_ssh_server_main(int port);
/* tmate-slave.c */
#ifdef DEVENV
#define TMATE_DEFAULT_PORT 2200
#else
#define TMATE_DEFAULT_PORT 22
#endif
#define TMATE_TOKEN_LEN 25
#define TMATE_WORKDIR "/tmp/tmate"
#define TMATE_JAIL_USER "nobody"
extern struct tmate_encoder *tmate_encoder;
extern int tmux_socket_fd;
extern const char *tmate_session_token;
extern void tmate_spawn_slave(struct tmate_ssh_client *client);