Solution for "DHCP/DNS not working" on memory-constrained phones

Posted by Lexa 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
Solution for "DHCP/DNS not working" on memory-constrained phones
December 16, 2016 07:51PM
Hey!

At first thank you for developing and publishing the Android version of PirateBox! smiling smiley

So, I'd like to convert some old phones into PirateBoxes, and ran into a few problems. This is the solution I found for a problem I saw reported by others in multiple places, with no real cause or solution posted anywhere - yet.

Problem is, you install PirateBox on a memory-constrained phone. On some small device which has a full system partition. And PirateBox works just fine the very first time, but never again after a restart of PirateBox. DHCP doesn't give out a configuration anymore and DNS doesn't give you the wildcard root zone anymore, but if you configure the network on your client manually, you can see the PirateBox webserver running just fine on 192.168.43.1:45454.

What happens is: PirateBox copies /system/bin/dnsmasq to /system/bin/dnsmasq.pb.backup on start, and copies the backup back to /system/bin/dnsmasq on exit (dnsmasq provides DHCP and DNS for the hotspot). When /system is too full for a copy, dnsmasq.pb.backup gets truncated, and it seems PirateBox doesn't check for this error. Then on PirateBox exit, the original dnsmasq gets replaced with a truncated backup, and from there on, dnsmasq is broken (in my case, segfaults).

I had this happen on a tiny Samsung Galaxy Pocket, so I had to find the right /system/bin/dnsmasq for my device. The Samsung "stock firmware" (*.tar.md5 file) is /very/ hard to extract (yes, I even tried it on some Windows, following all the "HowTos", no success with my particular firmware file), so I got one of the 3rd party ROMs _based on the stock firmware_, which is much easier to extract and contains all the original system files. From there I was able to restore the original /system/bin/dnsmasq. If you follow this path, make sure you delete some "junk" from the /system partition first! There's enough to choose from, depending on what you call "junk". In my case it was /system/app/amazon*.apk, which is 4.1MB and really doesn't belong on a /system partition. Another fine choice would be /system/app/eBay*.apk for another 4.2MB, or some other 3rd party stuff in there. Make sure to also check and restore dnsmasq's owner/group and permissions.

Maybe PirateBox should check if copying dnsmasq to dnsmasq.pb.backup was successful. There are phones with a full /system out there, and it's not really easy to recover from this problem for common users. EDIT: Or rename dnsmasq instead of copying it.

EDIT: Completely forgot to mention (for all those reading this in the future, especially): All this is with PirateBox_0.5.8_beta.apk (and older versions) on Android 2.3.6. You might still run into this problem with newer PirateBox versions in the future if you ever tested an older PirateBox version.

Lexa.



Edited 2 time(s). Last edit at 12/16/2016 09:05PM by Lexa.