Make libutempter optional
This commit is contained in:
committed by
Keith Winstein
parent
1b0686a7ea
commit
b03d53d421
+4
-1
@@ -41,7 +41,10 @@ AC_SUBST([WARNING_CXXFLAGS])
|
|||||||
AC_SUBST([PICKY_CXXFLAGS])
|
AC_SUBST([PICKY_CXXFLAGS])
|
||||||
|
|
||||||
# Checks for libraries.
|
# Checks for libraries.
|
||||||
AC_SEARCH_LIBS([utempter_remove_added_record], [utempter], , [AC_MSG_ERROR([Unable to find libutempter.])])
|
AC_SEARCH_LIBS([utempter_remove_added_record], [utempter],
|
||||||
|
[AC_DEFINE([HAVE_UTEMPTER], [1],
|
||||||
|
[Define if libutempter is available.])],
|
||||||
|
[AC_MSG_WARN([Unable to find libutempter; utmp entries will not be made.])])
|
||||||
AC_SEARCH_LIBS([compress], [z], , [AC_MSG_ERROR([Unable to find zlib.])])
|
AC_SEARCH_LIBS([compress], [z], , [AC_MSG_ERROR([Unable to find zlib.])])
|
||||||
AX_BOOST_BASE(, , [AC_MSG_ERROR([Unable to find boost libraries.])])
|
AX_BOOST_BASE(, , [AC_MSG_ERROR([Unable to find boost libraries.])])
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I$(builddir)/../protobufs -I$(srcdir)/../util
|
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I$(builddir)/../protobufs -I$(srcdir)/../util
|
||||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) -fno-default-inline -pipe
|
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) -fno-default-inline -pipe
|
||||||
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a -lutil -lrt -lm -lutempter $(protobuf_LIBS)
|
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a -lutil -lrt -lm $(protobuf_LIBS)
|
||||||
|
|
||||||
bin_PROGRAMS = mosh-client mosh-server
|
bin_PROGRAMS = mosh-client mosh-server
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
@@ -31,7 +33,9 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/signalfd.h>
|
#include <sys/signalfd.h>
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
#include <utempter.h>
|
#include <utempter.h>
|
||||||
|
#endif
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
@@ -182,10 +186,13 @@ int main( int argc, char *argv[] )
|
|||||||
exit( 0 );
|
exit( 0 );
|
||||||
} else {
|
} else {
|
||||||
/* parent */
|
/* parent */
|
||||||
|
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
/* make utmp entry */
|
/* make utmp entry */
|
||||||
char tmp[ 64 ];
|
char tmp[ 64 ];
|
||||||
snprintf( tmp, 64, "mosh [%d]", getpid() );
|
snprintf( tmp, 64, "mosh [%d]", getpid() );
|
||||||
utempter_add_record( master, tmp );
|
utempter_add_record( master, tmp );
|
||||||
|
#endif
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serve( master, terminal, network );
|
serve( master, terminal, network );
|
||||||
@@ -202,7 +209,9 @@ int main( int argc, char *argv[] )
|
|||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
utempter_remove_added_record();
|
utempter_remove_added_record();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "\n[mosh-server is exiting.]\n" );
|
printf( "\n[mosh-server is exiting.]\n" );
|
||||||
@@ -239,7 +248,10 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
|||||||
|
|
||||||
uint64_t last_remote_num = network.get_remote_state_num();
|
uint64_t last_remote_num = network.get_remote_state_num();
|
||||||
|
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
bool connected_utmp = false;
|
bool connected_utmp = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct in_addr saved_addr;
|
struct in_addr saved_addr;
|
||||||
saved_addr.s_addr = 0;
|
saved_addr.s_addr = 0;
|
||||||
|
|
||||||
@@ -305,6 +317,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
/* update utmp entry if we have become "connected" */
|
/* update utmp entry if we have become "connected" */
|
||||||
if ( (!connected_utmp)
|
if ( (!connected_utmp)
|
||||||
|| ( saved_addr.s_addr != network.get_remote_ip().s_addr ) ) {
|
|| ( saved_addr.s_addr != network.get_remote_ip().s_addr ) ) {
|
||||||
@@ -318,6 +331,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
|||||||
|
|
||||||
connected_utmp = true;
|
connected_utmp = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,6 +411,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_UTEMPTER
|
||||||
/* update utmp if has been more than 10 seconds since heard from client */
|
/* update utmp if has been more than 10 seconds since heard from client */
|
||||||
if ( connected_utmp ) {
|
if ( connected_utmp ) {
|
||||||
if ( time_since_remote_state > 10000 ) {
|
if ( time_since_remote_state > 10000 ) {
|
||||||
@@ -409,6 +424,7 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
|
|||||||
connected_utmp = false;
|
connected_utmp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( terminal.set_echo_ack( now ) ) {
|
if ( terminal.set_echo_ack( now ) ) {
|
||||||
/* update client with new echo ack */
|
/* update client with new echo ack */
|
||||||
|
|||||||
Reference in New Issue
Block a user