CtsSecurityTestCases ListeningPortsTest定位tcp埠與pid 【問題描述】 cts失敗項 armeabi v7a CtsSecurityTestCases android.security.cts.ListeningPortsTest testNoListen ...
CtsSecurityTestCases#ListeningPortsTest定位tcp埠與pid
【問題描述】
cts失敗項
armeabi-v7a CtsSecurityTestCases
android.security.cts.ListeningPortsTest#testNoListeningLoopbackTcpPorts
工具:9.0_r11
05-06 17:11:28.649 17375 17391 E TestRunner: android.security.cts.ListeningPortsTest$ListeningPortsAssertionError:
05-06 17:11:28.649 17375 17391 E TestRunner: Found port listening on addr=127.0.0.1, port=10100, UID=1000 [com.android.keychain, com.itv.android.iptv, com.android.location.fused, com.android.providers.settings,com.launcher.idn, android, com.itv.android.iptv.tvclient,com.droidlogic, com.android.wallpaperbackup, com.droidlogic.BluetoothRemote, ] in /proc/net/tcp
05-06 17:11:28.649 17375 17391 E TestRunner: at android.security.cts.ListeningPortsTest.assertNoAccessibleListeningPorts(ListeningPortsTest.java:250)
05-06 17:11:28.649 17375 17391 E TestRunner: at android.security.cts.ListeningPortsTest.testNoListeningLoopbackTcpPorts(ListeningPortsTest.java:138)
【問題結論】
定位到subtitle埠監聽某次提交,回退後測試pass
AuthBlog:秋城https://www.cnblogs.com/houser0323
【分析詳細】
1.定位節點inode
port=10100是十進位,/proc/net/tcp中port是十六進位,做一下轉換10110-->2774,見下麵2:處,對應inode為32905。
console:/ # cat proc/net/tcp
sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode
0: 7632A8C0:EA60 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 58215 1 00000000 100 0 0 10 0
1: 00000000:1A85 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 33635 1 00000000 100 0 0 10 0
2: 0100007F:2774 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 32905 1 00000000 100 0 0 10 0
2.根據inode查找pid
進入/proc/[pid]/fd/目錄下ls -l 查看socket埠號,由於我們不知道在哪個pid目錄下,所以遍歷一下
sh腳本或者終端輸入shell命令for迴圈遍歷查找32905節點的pid:
# for dir in `find /proc -name "fd" 2>/dev/null`
> do
> ls -l $dir | grep "socket\:\[32905\]" && echo $dir
> done
結果查找到pid為4085
lrwx------ 1 root root 64 2020-05-07 11:03 46 -> socket:[32905]
/proc/4085/task/4085/fd
lrwx------ 1 root root 64 2020-05-07 11:03 46 -> socket:[32905]
/proc/4085/task/4094/fd
......
lrwx------ 1 root root 64 2020-05-07 10:47 46 -> socket:[32905]
/proc/4085/fd
3.查看pid對應的程式
console:/ # ps 4085
USER PID PPID VSZ RSS WCHAN ADDR S NAME
system 4085 3024 1124392 82892 SyS_epoll_wait 0 S com.droidlogic.SubTitleService
至此定位結束,反饋給相應模塊處理
【參考資料】
1.嵌入式設備上如何通過埠號定位到進程
https://blog.csdn.net/daizhongyin/article/details/90031132
2.獲取tcp/udp埠對應的進程pid
https://blog.csdn.net/ChrisNiu1984/article/details/7022745