From 1c2b48abc6f2ad45e949fa0476089c3add07bbce Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Mon, 26 Nov 2012 03:00:12 -0500 Subject: [PATCH] mosh-server warning on unattached servers checks that device exists --- src/frontend/mosh-server.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 7613104..e3bed29 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -773,6 +773,13 @@ bool motd_hushed( void ) return (0 == lstat( ".hushlogin", &buf )); } +bool device_exists( const char *ut_line ) +{ + string device_name = string( "/dev/" ) + string( ut_line ); + struct stat buf; + return (0 == lstat( device_name.c_str(), &buf )); +} + string mosh_read_line( FILE *file ) { string ret; @@ -808,7 +815,8 @@ void warn_unattached( const string & ignore_entry ) /* does line show unattached mosh session */ string text( entry->ut_host ); if ( (text.substr( 0, 5 ) == "mosh ") - && (text != ignore_entry) ) { + && (text != ignore_entry) + && device_exists( entry->ut_line ) ) { unattached_mosh_servers.push_back( text ); } }