diff --git a/fhem/FHEM/93_FHEM2FHEM.pm b/fhem/FHEM/93_FHEM2FHEM.pm index 48c08bf04..d9c785f38 100755 --- a/fhem/FHEM/93_FHEM2FHEM.pm +++ b/fhem/FHEM/93_FHEM2FHEM.pm @@ -70,7 +70,6 @@ FHEM2FHEM_Define($$) $hash->{Host} = $dev; $hash->{portpassword} = $a[4] if(@a == 5); - FHEM2FHEM_CloseDev($hash); # Modify... return FHEM2FHEM_OpenDev($hash, 0); } @@ -94,6 +93,8 @@ FHEM2FHEM_Write($$) my $conn = IO::Socket::INET->new(PeerAddr => $dev); return if(!$conn); # Hopefuly it is reported elsewhere $hash->{TCPDev2} = $conn; + syswrite($hash->{TCPDev2}, $hash->{portpassword} . "\n") + if($hash->{portpassword}); } my $rdev = $hash->{rawDevice}; syswrite($hash->{TCPDev2}, "iowrite $rdev $fn $msg\n"); diff --git a/fhem/docs/commandref.html b/fhem/docs/commandref.html index 813d38ee0..cd7301dad 100644 --- a/fhem/docs/commandref.html +++ b/fhem/docs/commandref.html @@ -1339,8 +1339,7 @@ A line ending with \ will be concatenated with the next one, so long lines
  • portpassword
    Specify a port password, which has to be entered as the very first - string after the connection is established. Note: the password will be - visible when you are typing it in a the telnet connection. + string after the connection is established.

  • diff --git a/fhem/fhem.pl b/fhem/fhem.pl index e0da70954..83c98379b 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -463,6 +463,9 @@ while (1) { $client{$fd}{addr} = "$caddr:$port"; $client{$fd}{buffer} = ""; Log 4, "Connection accepted from $client{$fd}{addr}"; + # Telnet is strange: tell "Will echo" to supress password + syswrite($fd, sprintf("%c%c%cPassword: ", 255, 251, 1)) + if($attr{global}{portpassword}); } foreach my $c (keys %client) { @@ -480,6 +483,12 @@ while (1) { next; } $buf =~ s/\r//g; + if($attr{global}{portpassword}) { + $buf =~ s/\xff..//g; # Telnet IAC stuff + $buf =~ s/\xfd(.)//; # Telnet Do ? + syswrite($client{$c}{fd}, sprintf("%c%c%c", 0xff, 0xfc, ord($1))) + if(defined($1)) # Wont / ^C handling + } $client{$c}{buffer} .= $buf; AnalyzeInput($c); } @@ -640,11 +649,11 @@ AnalyzeInput($) $client{$c}{buffer} = $rest; if($attr{global}{portpassword} && !$client{$c}{pwEntered}) { + syswrite($client{$c}{fd}, sprintf("%c%c%c\n", 255, 252, 1)); # Wont echo. if($attr{global}{portpassword} eq $cmd) { $client{$c}{pwEntered} = 1; next; } else { - syswrite($client{$c}{fd}, "Password required\r\n"); DoClose($c); return; }