evilsocket / evilsocket/pwnagotchi
Bettercap does not release GPS port after disconnect[BUG]
- Dominant language
- Python
- Stars
- 9.2k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Ive been messing around with gps, both thru USB and bluetooth (a serial gps module +hc05+lipo) and been having a lot of trouble reconnecting if the gps device becomes disconnected. What ive found is that a usb gps module that was ttyAMC0 before will become AMC1 after being plugged back in. The BT gps module that is communicating on rfcomm0 cannot be released (even manually) or reconnected because it is already in use:
`Can't bind RFCOMM socket: Address already in use`
It takes a reboot to get it working again.
After some digging Ive discovered that bettercap is hanging onto the port after it has been lost and this(i believe) is preventing it from being released... and available to be reused.
`pi@FeFe:~ $ sudo lsof | grep /dev/rfcomm0
bettercap 396 root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 417 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 418 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 421 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 430 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 439 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 458 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 548 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 553 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 560 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 564 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
bettercap 396 4575 bettercap root 8u CHR 216,0 0t0 12323 /dev/rfcomm0
pi@FeFe:~ $
`
With usb devices, it only seems to happen after the gps has started sending 'good' data...with rfcomm, it is anytime the bt connection is broken . and it never reconnects.
**To Reproduce**
Steps to reproduce the behavior:
1. plug in GPS (usb on ttyAMC0)
2. wait for signal then disconnect, reconnect
3. ls /dev/tty* shows the usb device is now connected as ttyAMC1
**Expected behavior**
I would expect the port to be released after it was disconnected
**Environment (please complete the following information):**
- Pwnagotchi version 1.3.0 w/ waveshare v2
various usb gps modules,
serial gps + HC05 bt
Contributor guide
Assessment
This issue has not been assessed yet.