guardianproject / lildebi

UNMAINTAINED please adopt! we can no longer maintain this
https://guardianproject.info/code
GNU General Public License v3.0
229 stars 55 forks source link

Included wget not working on android-21/5.0/Lollipop #161

Open TuningGuide opened 9 years ago

TuningGuide commented 9 years ago

I compiled lildebi on a debian, installed the apk on my phone and tried to install debian. But wget is telling me wget: bad address "http://mirrors.ece.ubc.ca/debian".

I had to move the included wget within ...lildebi/app_bin/ to somewhere else. Afterwards it took the wget from my phone which is working fine.

adamjhogan commented 9 years ago

We are going to need to build with bionic for it to work (http://stackoverflow.com/questions/26968510/wget-from-adb-shell). I'm giving it a try now.

eighthave commented 9 years ago

Most Android devices do not include wget, so relying on the ROM's wget is not an option. Lil' Debi's wget comes from the built-in busybox, and it has been working for a long while now. If it is not working for you, @TuningGuide, then most likely, there is something wrong on your setup. "Bad address" sounds like perhaps either your internet connection wasn't working, or your DNS wasn't working.

TuningGuide commented 9 years ago

I think setup is perfectly fine :) otherwise (I assume) it would not make sense that the internal wget works (I have no firewall installed).

Maybe first some infos about my setup: Android 5.0.2 Cyanogenmod 12 on a HTC One S SELinux: Strict Connected via WLAN with self build Lildebi from latest sources.

As I said it's not really a problem if I rename the included wget, so this issue has no high priority for me.

eighthave commented 9 years ago

The problem is most likely related to SELinux: strict. That needs to be dealt with somehow. I haven't looked into the SELinux issues at all yet.

TuningGuide commented 9 years ago

I'll try to disable SELinux with setenforce 0 temporarly. ... No didn't make a difference.

adamjhogan commented 9 years ago

Static busybox seems to be the issue on either platform. The included dynamic busybox from the 0.5.4 release works on 4.4.4. The static busybox from the 2015-02-18 nightly does not work. This turns out to be a design feature since NDK is not building against bionic (see http://lists.busybox.net/pipermail/busybox/2011-April/075469.html, for example). Here's what I'm getting for reference. busybox strace of static busybox:

execve("/data/local/busybox-debug-2015-02-18-static", ["/data/local/busybox-debug-2015-02-18-static", "wget", "http://google.com"], [/* 24 vars */]) = 0
gettid()                                = 18200
set_tls(0x6ed10, 0x6ecd4, 0, 0x40, 0x6ecd4) = 0
mmap2(NULL, 0, PROT_READ, MAP_SHARED, 9, 0) = -1 EINVAL (Invalid argument)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001f000
mprotect(0x4001f000, 4096, PROT_READ)   = 0
getuid32()                              = 0
brk(0)                                  = 0xd0c000
brk(0xd0c000)                           = 0xd0c000
brk(0xd0e000)                           = 0xd0e000
sigaction(SIGALRM, {0x9d25, [], SA_RESTART}, {SIG_DFL, , 0) = 0
brk(0xd12000)                           = 0xd12000
getpid()                                = 18200
gettimeofday({1424395858, 827178}, NULL) = 0
getpid()                                = 18200
uname({sys="Linux", node="localhost", ...}) = 0
mprotect(0x4001f000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x4001f000, 4096, PROT_READ)   = 0
open("/system/etc/hosts", O_RDONLY)     = 4
fstat64(4, {st_mode=S_IFREG|0644, st_size=25, ...}) = 0
brk(0xd13000)                           = 0xd13000
mprotect(0x4001f000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x4001f000, 4096, PROT_READ)   = 0
read(4, "127.0.0.1\t\t    localhost\n", 4096) = 25
read(4, "", 4096)                       = 0
close(4)                                = 0
mmap2(NULL, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4008b000
mmap2(NULL, 69632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4010d000
gettimeofday({1424395858, 836810}, NULL) = 0
getpid()                                = 18200
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
gettimeofday({1424395858, 838110}, NULL) = 0
getpid()                                = 18200
bind(4, {sa_family=AF_INET, sin_port=htons(1173), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
sendto(4, "\r\200\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, 0, NULL, 0) = 28
clock_gettime(CLOCK_REALTIME, {1424395858, 840681000}) = 0
select(5, [4], NULL, NULL, {5, 0})      = 1 (in [4], left {4, 999988})
recvfrom(4, 0x4008b008, 65536, 0, 0xbec7fb4c, 0xbec7fb48) = -1 ECONNREFUSED (Connection refused)
close(4)                                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
gettimeofday({1424395858, 844128}, NULL) = 0
getpid()                                = 18200
bind(4, {sa_family=AF_INET, sin_port=htons(11307), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
sendto(4, "\r\200\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, 0, NULL, 0) = 28
clock_gettime(CLOCK_REALTIME, {1424395858, 846205000}) = 0
select(5, [4], NULL, NULL, {5, 0})      = 1 (in [4], left {4, 999991})
recvfrom(4, 0x4008b008, 65536, 0, 0xbec7fb4c, 0xbec7fb48) = -1 ECONNREFUSED (Connection refused)
close(4)                                = 0
gettimeofday({1424395858, 849452}, NULL) = 0
getpid()                                = 18200
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
gettimeofday({1424395858, 850485}, NULL) = 0
getpid()                                = 18200
bind(4, {sa_family=AF_INET, sin_port=htons(14208), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
sendto(4, "?f\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, 0, NULL, 0) = 28
clock_gettime(CLOCK_REALTIME, {1424395858, 852630000}) = 0
select(5, [4], NULL, NULL, {5, 0})      = 1 (in [4], left {4, 999990})
recvfrom(4, 0x4008b008, 65536, 0, 0xbec7fb4c, 0xbec7fb48) = -1 ECONNREFUSED (Connection refused)
close(4)                                = 0
socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
gettimeofday({1424395858, 855544}, NULL) = 0
getpid()                                = 18200
bind(4, {sa_family=AF_INET, sin_port=htons(51379), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
sendto(4, "?f\1\0\0\1\0\0\0\0\0\0\6google\3com\0\0\1\0\1", 28, 0, NULL, 0) = 28
clock_gettime(CLOCK_REALTIME, {1424395858, 862639000}) = 0
select(5, [4], NULL, NULL, {5, 0})      = 1 (in [4], left {4, 999990})
recvfrom(4, 0x4008b008, 65536, 0, 0xbec7fb4c, 0xbec7fb48) = -1 ECONNREFUSED (Connection refused)
close(4)                                = 0
munmap(0x4008b000, 69632)               = 0
munmap(0x4010d000, 69632)               = 0
write(2, "wget: bad address 'google.com'\n", 31) = 31
mprotect(0x4001f000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x4001f000, 4096, PROT_READ)   = 0
mprotect(0x4001f000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x4001f000, 4096, PROT_READ)   = 0
munmap(0x4001f000, 4096)                = 0
exit_group(1)                           = ?
adamjhogan commented 9 years ago

I compiled a static busybox from CM12's repo with bionic instead of glibc and it works as expected on 5.0. The same binary hangs on dns lookup on 4.4.4. There is nothing trivial about compiling it to work on 5.0, it seems, and nothing trivial about compiling it so that wget works simultaneously on both 4.* and 5.*.

eighthave commented 9 years ago

any tips on how to make this build of busybox work?

adamjhogan commented 9 years ago

Static involves more work and I haven't figured out why it hangs on 4.4.4. I went back to building with PIE and that binary works on both 4.4.4 and 5.0. I don't have older Android versions to test.

For the partially functional static, I included the bionic includes from the CM repo along with the compiled libraries (compiling them involved a 20GB repo sync). I can play around with it a bit more, but I'm honestly not sure what I'm looking for.

eighthave commented 9 years ago

I think for now, it probably makes the most sense to just build busybox as PIE, and support >=4.1

diederikdehaas commented 9 years ago

I don't know if this is relevant/related, but I'm posting it anyway in case it may help: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=757941 which came forward from https://github.com/debian-pi/raspbian-ua-netinst/issues/80

ghost commented 8 years ago

Testing on CM13 Android 6.0.1

I tried to build but got stuck cos I don't have openJDK8 available on ubuntu 14.04. I can try building in a VM with a newer distro.

For now I just tested the APK from https://guardianproject.info/builds/LilDebi/2015-02-18_08-50-23/ I got the same problem with wget. It complained "bad address" for the default repo. I tried another repo. By the way, there's no way to edit what mirror is used from the GUI, and editing the install.conf file is useless because it gets overwritten when running the install. So I just hacked the create-debian-setup.sh with mirror=http://foo.com/debian Same error "bad address". I tried

mv wget wgetBusyBox
ln -s $(which wget) wget

Then it passed the step Retrieving Release.gpg But it got stuck on Validating Release

gpgv: can't open `/data/debian/var/cache/bootstrap/_dists_._Release.gpg'
gpgv: verify signatures failed: file open error

/data/debian/var/cache/bootstrap/ is totally empty I disabled SELinux. setenforce 0 I confirmed SELinux was disabled looking in Settings>About phone Selinux status changed from enforcing to Permissive.

Any ideas?

ghost commented 8 years ago

I just read through the links provided by @diederikdehaas (particularly the first one) it seems there was a libc6 bug causing all these problems with getaddrinfo(), which looks like it was fixed in October 2015!

@eighthave @godlessfather @TuningGuide can you please help? As above I'm stuck with what is likely to be this libc6 issue.

eighthave commented 8 years ago

libc6 would not affect busybox wget built for android, as far as I remember. Android does not use GNU libc, it uses bionic libc.

Jcfunk commented 8 years ago

busybox wget works if you have /etc/resolv.conf
I added file to my device, with nameserver 8.8.8.8

ghost commented 8 years ago

@godlessfather @eighthave @Jcfunk Thanks for the tip... I tried again now, using the latest apk 2015-02-18. I set nameservers in /etc/resolv.conf. (if anyone's wondering how mount -o remount,rw /) Now it managed to download the release using the bundled busybox's wget binary successfully. But it still got stuck at the same place as my 2nd last msg, above.

gpgv: can't open `/data/debian/var/cache/bootstrap/_dists_._Release.gpg'
gpgv: verify signatures failed: file open error
E: Couldn't validate Release!

/data/debian/var/cache/bootstrap/ is totally empty.

I'd appreciate if you have any further ideas/assistance :)

As a workaround I might try pull my lildebi install from my Samsung Galaxy S3 and push it to the S5, then see if it will "just start". Is there anything I would need to do to make the lildebi app realize "Debian has been installed"?

Jcfunk commented 8 years ago

@lope Same for me, also I can't seem to download debian-squeeze.img.bz2 Wish some one would post there working debian.img. I used img from LinuxOnAndroid, it's not setup the same. It seems gpgv doesn't work on Android 5+. My next choice was to find a old phone and try to make my own img.

ghost commented 8 years ago

@Jcfunk I think installing on internal storage is preferable. Your debian distro will be able to bind mount /dev and other stuff, so more stuff should work more easily. And you'll (in theory haven't tried it) be able to use stuff like openvpn and whatever, accessing /dev/tun and do whatever else you might want to do with your kernel.

Jcfunk commented 8 years ago

@lope I edited create-debian-setup.sh comment out stuff about GPG keyring

run cdebootstrap in one stage
+ echo run cdebootstrap in one stage
+ /data/debian/usr/bin/cdebootstrap-static --verbose --foreign --flavour=minimal --include=locales --configdir=/data/debian/usr/share/cdebootstrap-static --helperdir=/data/debian/usr/share/cdebootstrap-static --arch armhf stable /data/debian http://mirrors.ece.ubc.ca/debian/

everything went ok except for cdebootstrap didn't do anything.

Just had an thought, LOL
I'm adb running cdebootstrap command I ran with switch --allow-unauthenticated If I add to create-debian-setup.sh maybe it will work from app. will test and find out

ghost commented 8 years ago

@Jcfunk today I discovered you cant just run create-debian-setup.sh. It requires a bunch of parameters to work. There are no examples inside the script or in the java source that executes it. So I ended up just running it by clicking the install button in the app.

Looks like I got my S5 with CM13 Android 6.0.1 working...

Firstly I tar'd my S3's debian install

/data/exclude.txt

acct/*
cache/*
data
debian
efs
extSdCard
media/*
proc
run
sdcard
sqlite_stmt_journals
storage/*
system/*
usbdisk0
app-cache
d
dbdata
dev
factory
mnt/*
pds
shell
srv
sys
tmp/*
vendor
cd /data/debian
tar --exclude-from=/data/exclude.txt -cpvzf /data/deb.tar.gz *

then adb pull and adb push to the other phone.

Then I modified create-debian-setup.sh I commented out the debootstrap command. And replaced it with this.

cd /data/debian
tar -zxvf /data/deb.tar.gz

So the install script would run and think "hooray, we got the files". I didn't actually run it like this though. I accidentally used the wrong flag on tar (in the actual script) and I think it just LISTED the files, didn't extract them.

To clean up I had to remove 2 dodgy symlinks inside /data/debian: rm etc bin Then extracted my chroot'ed tar.

dpkg-reconfigure android-permissions


You can likely do this yourself on your x86 PC by using debootstrap and specifying the arch.

Jcfunk commented 8 years ago

@lope It worked for me, I used app after editing create-debian-setup.sh

$mnt/usr/bin/cdebootstrap-static --allow-unauthenticated --verbose --foreign\ --flavour=minimal --include=locales $KEYRING \ --configdir=$mnt/usr/share/cdebootstrap-static \ --helperdir=$mnt/usr/share/cdebootstrap-static \ --arch $arch $release $mnt $mirror || exit

ghost commented 8 years ago

Great, but --allow-unauthenticated is a little bit dodgy mate. Rather debootstrap something legit on your PC and move it over.