committed by
Keith Winstein
parent
f7be5c8cec
commit
dd941df19d
@@ -1,9 +1,3 @@
|
||||
# This must be set in Makefile.am for dependency tracking to work.
|
||||
if COND_THIRD_LIBSTDDJB
|
||||
STDDJB_LDFLAGS += $(top_builddir)/third/libstddjb/libstddjb.a
|
||||
STDDJB_CPPFLAGS += -I$(top_srcdir)/third/libstddjb
|
||||
endif
|
||||
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS)
|
||||
AM_LDFLAGS = $(HARDEN_LDFLAGS)
|
||||
|
||||
@@ -24,13 +18,13 @@ parse_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util
|
||||
parse_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a -lutil
|
||||
|
||||
termemu_SOURCES = termemu.cc
|
||||
termemu_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util -I$(srcdir)/../statesync -I../protobufs $(STDDJB_CPPFLAGS)
|
||||
termemu_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a ../statesync/libmoshstatesync.a ../protobufs/libmoshprotos.a -lutil $(STDDJB_LDFLAGS) $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
termemu_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util -I$(srcdir)/../statesync -I../protobufs
|
||||
termemu_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a ../statesync/libmoshstatesync.a ../protobufs/libmoshprotos.a -lutil $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
ntester_SOURCES = ntester.cc
|
||||
ntester_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs $(protobuf_CFLAGS)
|
||||
ntester_LDADD = ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../protobufs/libmoshprotos.a ../util/libmoshutil.a -lutil -lm $(protobuf_LIBS)
|
||||
|
||||
benchmark_SOURCES = benchmark.cc
|
||||
benchmark_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I../protobufs -I$(srcdir)/../frontend -I$(srcdir)/../crypto -I$(srcdir)/../network $(STDDJB_CPPFLAGS) $(protobuf_CFLAGS)
|
||||
benchmark_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I../protobufs -I$(srcdir)/../frontend -I$(srcdir)/../crypto -I$(srcdir)/../network $(protobuf_CFLAGS)
|
||||
benchmark_LDADD = ../frontend/terminaloverlay.o ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../protobufs/libmoshprotos.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../util/libmoshutil.a $(STDDJB_LDFLAGS) -lutil -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
@@ -44,11 +44,6 @@
|
||||
#include "locale_utils.h"
|
||||
#include "fatal_assert.h"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "benchmark";
|
||||
}
|
||||
|
||||
const int ITERATIONS = 100000;
|
||||
|
||||
using namespace Terminal;
|
||||
|
||||
@@ -51,11 +51,6 @@
|
||||
#include "locale_utils.h"
|
||||
#include "select.h"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "termemu";
|
||||
}
|
||||
|
||||
const size_t buf_size = 16384;
|
||||
|
||||
void emulate_terminal( int fd );
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
# This must be set in Makefile.am for dependency tracking to work.
|
||||
if COND_THIRD_LIBSTDDJB
|
||||
STDDJB_LDFLAGS += $(top_builddir)/third/libstddjb/libstddjb.a
|
||||
STDDJB_CPPFLAGS += -I$(top_srcdir)/third/libstddjb
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs -I$(srcdir)/../util $(STDDJB_CPPFLAGS) $(TINFO_CFLAGS) $(protobuf_CFLAGS)
|
||||
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs -I$(srcdir)/../util $(TINFO_CFLAGS) $(protobuf_CFLAGS)
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS)
|
||||
AM_LDFLAGS = $(HARDEN_LDFLAGS)
|
||||
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a $(STDDJB_LDFLAGS) -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
mosh_server_LDADD = $(LDADD) -lutil
|
||||
|
||||
|
||||
@@ -30,11 +30,6 @@
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "mosh-client";
|
||||
}
|
||||
|
||||
void usage( const char *argv0 ) {
|
||||
fprintf( stderr, "mosh-client (%s)\n", PACKAGE_STRING );
|
||||
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
||||
|
||||
@@ -67,11 +67,6 @@
|
||||
|
||||
#include "networktransport.cc"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "mosh-server";
|
||||
}
|
||||
|
||||
typedef Network::Transport< Terminal::Complete, Network::UserStream > ServerConnection;
|
||||
|
||||
void serve( int host_fd,
|
||||
|
||||
@@ -2,8 +2,4 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXF
|
||||
|
||||
noinst_LIBRARIES = libmoshutil.a
|
||||
|
||||
libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h sigfd.h select.h select.cc
|
||||
|
||||
if !USE_LIBSTDDJB
|
||||
libmoshutil_a_SOURCES += sigfd.cc
|
||||
endif
|
||||
libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h select.h select.cc
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
Mosh: the mobile shell
|
||||
Copyright 2012 Keith Winstein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
#include "fatal_assert.h"
|
||||
|
||||
static sigset_t caught;
|
||||
static int fd = -1;
|
||||
|
||||
#define SIGNALFD_FLAGS ( SFD_NONBLOCK | SFD_CLOEXEC )
|
||||
|
||||
int sigfd_init( void )
|
||||
{
|
||||
if ( fd != -1 ) {
|
||||
errno = EBUSY;
|
||||
return -1;
|
||||
}
|
||||
sigemptyset( &caught );
|
||||
fd = signalfd( -1, &caught, SIGNALFD_FLAGS );
|
||||
return fd;
|
||||
}
|
||||
|
||||
int sigfd_trap( int sig )
|
||||
{
|
||||
/* The callers all fatal_assert on error, so we can do the same here.
|
||||
We still return 'int' in order to have the same API as libstddjb. */
|
||||
fatal_assert( 0 <= fd );
|
||||
fatal_assert( 0 <= sigaddset( &caught, sig ) );
|
||||
fatal_assert( 0 <= sigprocmask( SIG_BLOCK, &caught, NULL ) );
|
||||
fatal_assert( 0 <= signalfd( fd, &caught, SIGNALFD_FLAGS ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sigfd_read( void )
|
||||
{
|
||||
int r;
|
||||
struct signalfd_siginfo si;
|
||||
|
||||
do {
|
||||
r = read( fd, &si, sizeof( si ) );
|
||||
} while ( ( r == -1 ) && ( errno == EINTR ) );
|
||||
|
||||
if ( r == -1 ) {
|
||||
if ( errno == EAGAIN || errno == EWOULDBLOCK )
|
||||
/* No signal available */
|
||||
return 0;
|
||||
return -1;
|
||||
} else if ( r != sizeof( si ) ) {
|
||||
/* Should never happen?
|
||||
Includes r = 0, i.e. end of file */
|
||||
errno = EPIPE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int) si.ssi_signo;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
Mosh: the mobile shell
|
||||
Copyright 2012 Keith Winstein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Uses either signalfd or libstddjb's selfpipe to receive signals as part of
|
||||
an event loop.
|
||||
|
||||
selfpipe already does a fine job of interfacing to signalfd. But Debian and
|
||||
Ubuntu want us to depend on the skalibs-dev package rather than build
|
||||
libstddjb ourselves. That would be fine except that skalibs-dev has static
|
||||
libraries only, and they aren't built with -fPIC. This interferes with
|
||||
building mosh-{client,server} as position-independent executables, which
|
||||
is a desirable security measure.
|
||||
|
||||
So we have our own wrapper, which invokes either signalfd or selfpipe. And
|
||||
we build it ourselves with our own flags, because it's part of the Mosh
|
||||
project proper. */
|
||||
|
||||
#ifndef SIGFD_HPP
|
||||
#define SIGFD_HPP
|
||||
|
||||
#if USE_LIBSTDDJB
|
||||
|
||||
extern "C" {
|
||||
#include "selfpipe.h"
|
||||
}
|
||||
|
||||
#define sigfd_init selfpipe_init
|
||||
#define sigfd_trap selfpipe_trap
|
||||
#define sigfd_read selfpipe_read
|
||||
|
||||
#else
|
||||
|
||||
int sigfd_init( void );
|
||||
int sigfd_trap( int sig );
|
||||
int sigfd_read( void );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user