Skip to content

Commit

Permalink
mosh-server warning on unattached servers checks that device exists
Browse files Browse the repository at this point in the history
  • Loading branch information
keithw committed Nov 26, 2012
1 parent 2f8a67a commit 1c2b48a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/frontend/mosh-server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
}
}
Expand Down

0 comments on commit 1c2b48a

Please sign in to comment.