check_ethernet.hook: Fix the ambiguious matching of ssh connections

As the ARC++ is introduced on Chromebook, the sshd port 22 is also
used for adb connection for simplicity and the real sshd is then
running on port 2222 instead. However, this also introduces
a bug in check_ethernet.hook to include the 127.0.0.1 in the results
of listing ssh connections. The patch addresses this issue by fixing
the regular expression to retrieve the ssh connections only.

BUG=chromium:695366
TEST=only DUT in lab

=== original regular expression on DUT ====
localhost ~ # find_ssh_client() {   netstat -lanp | awk '/tcp.*:22.*ESTABLISHED.*/ {split($5,a,":"); print a[1]}'; }
localhost ~ # find_ssh_client
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
172.25.75.19
172.30.210.13
172.25.75.19
=== with the fix ===
 find_ssh_client() {
>   netstat -lanp | awk '/tcp.*:22 .*ESTABLISHED.*/ {split($5,a,":"); print a[1]}'
> }
localhost ~ # find_ssh_client
172.25.75.19
172.30.210.13
172.25.75.19

Change-Id: If3163ab80a06e0e6b5596fe1ae8454504be8cfd2
Signed-off-by: Chung-yih Wang <cywang@google.com>
Reviewed-on: https://chromium-review.googlesource.com/452057
Reviewed-by: Richard Barnette <jrbarnette@google.com>
1 file changed