mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
Make it happy on darwin
This commit is contained in:
parent
0f7f5a477a
commit
5f607d338c
@ -22,7 +22,7 @@ CFLAGS += -D_GNU_SOURCE
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += -Wno-unused-parameter -Wno-unused-variable
|
CFLAGS += -Wno-unused-parameter -Wno-unused-variable
|
||||||
if IS_GCC
|
if IS_LINUX
|
||||||
CFLAGS += -rdynamic # for stack traces
|
CFLAGS += -rdynamic # for stack traces
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
11
configure.ac
11
configure.ac
@ -156,7 +156,7 @@ fi
|
|||||||
|
|
||||||
PKG_CHECK_MODULES(
|
PKG_CHECK_MODULES(
|
||||||
MSGPACK,
|
MSGPACK,
|
||||||
msgpack,
|
msgpack >= 1.2.0,
|
||||||
[
|
[
|
||||||
CPPFLAGS="$MSGPACK_CFLAGS $CPPFLAGS"
|
CPPFLAGS="$MSGPACK_CFLAGS $CPPFLAGS"
|
||||||
LIBS="$MSGPACK_LIBS $LIBS"
|
LIBS="$MSGPACK_LIBS $LIBS"
|
||||||
@ -165,13 +165,13 @@ PKG_CHECK_MODULES(
|
|||||||
found_msgpack=no
|
found_msgpack=no
|
||||||
)
|
)
|
||||||
if test "x$found_msgpack" = xno; then
|
if test "x$found_msgpack" = xno; then
|
||||||
AC_MSG_ERROR("msgpack not found")
|
AC_MSG_ERROR("msgpack >= 1.2.0 not found")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES(
|
PKG_CHECK_MODULES(
|
||||||
LIBSSH,
|
LIBSSH,
|
||||||
libssh,
|
libssh >= 0.7.0,
|
||||||
[
|
[
|
||||||
CPPFLAGS="$LIBSSH_CFLAGS $CPPFLAGS"
|
CPPFLAGS="$LIBSSH_CFLAGS $CPPFLAGS"
|
||||||
LIBS="$LIBSSH_LIBS $LIBS"
|
LIBS="$LIBSSH_LIBS $LIBS"
|
||||||
@ -180,9 +180,11 @@ PKG_CHECK_MODULES(
|
|||||||
found_libssh=no
|
found_libssh=no
|
||||||
)
|
)
|
||||||
if test "x$found_libssh" = xno; then
|
if test "x$found_libssh" = xno; then
|
||||||
AC_MSG_ERROR("libssh not found")
|
AC_MSG_ERROR("libssh >= 0.7.0 not found")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([setresuid setresgid setreuid setregid])
|
||||||
|
|
||||||
# Check for b64_ntop.
|
# Check for b64_ntop.
|
||||||
AC_MSG_CHECKING(for b64_ntop)
|
AC_MSG_CHECKING(for b64_ntop)
|
||||||
AC_TRY_LINK(
|
AC_TRY_LINK(
|
||||||
@ -478,6 +480,7 @@ case "$host_os" in
|
|||||||
*linux*)
|
*linux*)
|
||||||
AC_MSG_RESULT(linux)
|
AC_MSG_RESULT(linux)
|
||||||
PLATFORM=linux
|
PLATFORM=linux
|
||||||
|
AC_DEFINE(IS_LINUX)
|
||||||
;;
|
;;
|
||||||
*freebsd*)
|
*freebsd*)
|
||||||
AC_MSG_RESULT(freebsd)
|
AC_MSG_RESULT(freebsd)
|
||||||
|
@ -210,7 +210,7 @@ static int _tmate_connect_to_master(const char *hostname, int port)
|
|||||||
memcpy(&servaddr.sin_addr, host->h_addr, host->h_length);
|
memcpy(&servaddr.sin_addr, host->h_addr, host->h_length);
|
||||||
servaddr.sin_port = htons(port);
|
servaddr.sin_port = htons(port);
|
||||||
|
|
||||||
if (connect(sockfd, &servaddr, sizeof(servaddr)) < 0)
|
if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0)
|
||||||
tmate_fatal("Cannot connect to master at %s:%d", hostname, port);
|
tmate_fatal("Cannot connect to master at %s:%d", hostname, port);
|
||||||
|
|
||||||
int flag = 1;
|
int flag = 1;
|
||||||
|
@ -9,7 +9,7 @@ static void on_encoder_buffer_ready(evutil_socket_t fd, short what, void *arg)
|
|||||||
encoder->ready_callback(encoder->userdata, encoder->buffer);
|
encoder->ready_callback(encoder->userdata, encoder->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int on_encoder_write(void *userdata, const char *buf, unsigned int len)
|
static int on_encoder_write(void *userdata, const char *buf, size_t len)
|
||||||
{
|
{
|
||||||
struct tmate_encoder *encoder = userdata;
|
struct tmate_encoder *encoder = userdata;
|
||||||
|
|
||||||
|
@ -271,17 +271,35 @@ static void jail(void)
|
|||||||
if (chdir("/") < 0)
|
if (chdir("/") < 0)
|
||||||
tmate_fatal("Cannot chdir()");
|
tmate_fatal("Cannot chdir()");
|
||||||
|
|
||||||
/* if (unshare(CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET) < 0) */
|
#if IS_LINUX
|
||||||
/* tmate_fatal("Cannot create new namespace"); */
|
if (unshare(CLONE_NEWPID | CLONE_NEWIPC | CLONE_NEWNS | CLONE_NEWNET) < 0)
|
||||||
|
tmate_fatal("Cannot create new namespace");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (setgroups(1, (gid_t[]){gid}) < 0)
|
if (setgroups(1, (gid_t[]){gid}) < 0)
|
||||||
tmate_fatal("Cannot setgroups()");
|
tmate_fatal("Cannot setgroups()");
|
||||||
|
|
||||||
|
#if HAVE_SETRESUID
|
||||||
if (setresuid(uid, uid, uid) < 0)
|
if (setresuid(uid, uid, uid) < 0)
|
||||||
tmate_fatal("Cannot setresuid()");
|
tmate_fatal("Cannot setresuid()");
|
||||||
|
#elif HAVE_SETREUID
|
||||||
|
if (setreuid(uid, uid) < 0)
|
||||||
|
tmate_fatal("Cannot setreuid()");
|
||||||
|
#else
|
||||||
|
if (setuid(uid) < 0)
|
||||||
|
tmate_fatal("Cannot setuid()");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (setresuid(gid, gid, gid) < 0)
|
#if HAVE_SETRESGID
|
||||||
|
if (setresgid(gid, gid, gid) < 0)
|
||||||
tmate_fatal("Cannot setresgid()");
|
tmate_fatal("Cannot setresgid()");
|
||||||
|
#elif HAVE_SETREGID
|
||||||
|
if (setregid(gid, gid) < 0)
|
||||||
|
tmate_fatal("Cannot setregid()");
|
||||||
|
#else
|
||||||
|
if (setgid(gid) < 0)
|
||||||
|
tmate_fatal("Cannot setgid()");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (nice(1) < 0)
|
if (nice(1) < 0)
|
||||||
tmate_fatal("Cannot nice()");
|
tmate_fatal("Cannot nice()");
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <libssh/server.h>
|
#include <libssh/server.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include "tmate.h"
|
#include "tmate.h"
|
||||||
|
|
||||||
extern void client_write_server(enum msgtype type, void *buf, size_t len);
|
extern void client_write_server(enum msgtype type, void *buf, size_t len);
|
||||||
|
@ -96,7 +96,7 @@ static void on_daemon_encoder_write(void *userdata, struct evbuffer *buffer)
|
|||||||
{
|
{
|
||||||
struct tmate_session *session = userdata;
|
struct tmate_session *session = userdata;
|
||||||
ssize_t len, written;
|
ssize_t len, written;
|
||||||
char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
len = evbuffer_get_length(buffer);
|
len = evbuffer_get_length(buffer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user