Change SSH_CONNECTION fallback to allow IPv6

This commit is contained in:
John Hood
2015-07-30 00:14:31 -04:00
parent 448f9f1bab
commit 7fb542c874
+4 -2
View File
@@ -131,14 +131,14 @@ static string get_SSH_IP( void )
const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" ); const char *SSH_CONNECTION = getenv( "SSH_CONNECTION" );
if ( !SSH_CONNECTION ) { /* Older sshds don't set this */ if ( !SSH_CONNECTION ) { /* Older sshds don't set this */
fprintf( stderr, "Warning: SSH_CONNECTION not found; binding to any interface.\n" ); fprintf( stderr, "Warning: SSH_CONNECTION not found; binding to any interface.\n" );
return string( "0.0.0.0" ); return string( "" );
} }
istringstream ss( SSH_CONNECTION ); istringstream ss( SSH_CONNECTION );
string dummy, local_interface_IP; string dummy, local_interface_IP;
ss >> dummy >> dummy >> local_interface_IP; ss >> dummy >> dummy >> local_interface_IP;
if ( !ss ) { if ( !ss ) {
fprintf( stderr, "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n" ); fprintf( stderr, "Warning: Could not parse SSH_CONNECTION; binding to any interface.\n" );
return string( "0.0.0.0" ); return string( "" );
} }
/* Strip IPv6 prefix. */ /* Strip IPv6 prefix. */
@@ -196,8 +196,10 @@ int main( int argc, char *argv[] )
break; break;
case 's': case 's':
desired_ip_str = get_SSH_IP(); desired_ip_str = get_SSH_IP();
if ( !desired_ip_str.empty() ) {
desired_ip = desired_ip_str.c_str(); desired_ip = desired_ip_str.c_str();
fatal_assert( desired_ip ); fatal_assert( desired_ip );
}
break; break;
case 'c': case 'c':
try { try {