mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Рысь <lynx@sibserver.ru>
To: musl@lists.openwall.com
Subject: Re: musl and android
Date: Sun, 18 Jan 2015 15:01:19 +0700	[thread overview]
Message-ID: <20150118150119.1a80a4ba@sibserver.ru> (raw)
In-Reply-To: <20150118064440.GA4574@brightrain.aerifal.cx>

В Sun, 18 Jan 2015 01:44:40 -0500
Rich Felker <dalias@libc.org> пишет:

> On Sun, Jan 18, 2015 at 01:32:37PM +0700, Рысь wrote:
> > В Thu, 15 Jan 2015 16:13:22 +0700
> > Рысь <lynx@sibserver.ru> пишет:
> > 
> > > Hello all!
> > > 
> > > Are there any efforts or even a project which aims to port musl to
> > > android platform?
> > > 
> > > For a year I slowly had built and running a couple of C tty only
> > > programs such as iptables, tcpdump and of course busybox and many
> > > others including my own with musl libc linked statically. They
> > > work perfectly (no much differences between an ARM phone and, for
> > > example, raspberry pi SoC) but a few items I missed:
> > > 
> > > + Proper DNS resolving is not available
> > > + Translation of android special user names is not done
> > > 
> > > As an advanced Linux user I know that android is not friendly
> > > enough to plain C stuff and it's libc is even not finished now so
> > > I aimed to port at least listed things to musl.
> > > 
> > > Because I am not going beyond listed items, a patch can be
> > > developed just to support these inside musl-linked binaries.
> > > 
> > > I am first here or there is already someone who done this before?
> > 
> > I made a patch to implement all three things for musl on android.
> > 
> > I do not post it here as attachment to this mail because it normally
> > should not be integrated with musl. The patch itself is here:
> > http://lynxlynx.tk/prg/patches/musl-1.1.4_android.patch, notes about
> > it: http://lynxlynx.tk/eng/musl_android/.
> > 
> > Patch is invasive enough I think and not optimized and I agree with
> > Rich that it must go as a special treat. I tried however move away
> > all translating code to src/android and headers to include/android.
> > 
> > Patch is still in it's alpha stage, and probably will be changed
> > often.
> > 
> > Modifications made for musl 1.1.4.
> > 
> > If anyone interested to audit it - welcome!
> 
> Thanks. If nothing else, this is very informative as to how Android
> does things. I noticed a couple things that could be a lot less
> invasive, I think, particularly the builtin users/groups. Couldn't you
> just fmemopen() a constant string inside libc in place of /etc/passwd
> or /etc/group and use the existing code to parse it?

This sounds more interesting idea, I forgot that get*ent() open fd and
there is fmemopen() function. But app_/ux_ax names still need a
dedicated translation function, probably the same code which will form
a passwd-like string and feed it into get*ent().

> 
> One thing I noticed -- you seem to have some memory leaks in the code
> that produces the passwd/group output -- it's malloc'ing space for
> names each time and I don't see anywhere it gets freed. Maybe I'm
> missing something though; I just read it briefly.

Yes the patch is alpha and the reason why there is so much code is that
I did not know how get*ent() were implemented in musl from beginning,
and learned them only when translation code was ready. This patch is
just to show how a translation layer can be implemented on musl to
(completely) port it to android, and I am probably going to completely
rewrite uid/name translation code based on your suggestion in next days
(or at least try to). Memory leaks are expected now :(

> 
> Another general question I have is why can't the /system issue be
> fixed? Is there any good reason Android doesn't have symlinks like
> /bin->/system/bin, /etc->/system/etc, /lib->/system/lib,
> /tmp->/data/tmp, etc.? The gratuitous incompatibility is really
> disgusting.

First, android has /etc -> /system/etc in place, but, unfortunately, no
more :(

I made /etc -> /system/etc change just because I distrust symlinks when
doing security things. It is usually stable across devices, but it's
just symlink.

It even does not have usual Unix /tmp directory or it's surrogate
somewhere in filesystem. /data/tmp is my adoption, though it's
non-standard on android.

Second, android has a very different bootup process, and all those
links in / are created during bootup (on a tmpfs?). Sadly only /etc is
defined by android developers to be symlink to /system/etc.

Third, there are probably many differences between many android device
vendors, android OS types (different android versions including ancient
ones, different android forks that exist today, vendor customisations
of fs layout and in future many others). In fact, android is _very_
fragmented OS.

All this is based on my experience with some android devices I working
(and worked) with.

> 
> Rich

Your additional input on this will be welcome, thanks!


  reply	other threads:[~2015-01-18  8:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-15  9:13 Рысь
2015-01-15 11:01 ` Rich Felker
2015-01-15 12:00   ` dynamic linking (Re: [musl] musl and android) u-wsnj
2015-01-15 12:15     ` Rich Felker
2015-01-15 13:04       ` u-wsnj
2015-01-15 13:34         ` Rich Felker
2015-01-15 15:56           ` OT: " u-wsnj
2015-01-15 13:53   ` musl and android Рысь
2015-01-18  6:32 ` Рысь
2015-01-18  6:44   ` Rich Felker
2015-01-18  8:01     ` Рысь [this message]
2015-01-18 16:40       ` Rich Felker
2015-01-19 18:00         ` Рысь
2015-01-21 10:34         ` Рысь
2015-01-21 18:36           ` Rich Felker
2015-01-22  2:37             ` Рысь
2015-01-31 15:08               ` Рысь
2015-02-03  5:52                 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150118150119.1a80a4ba@sibserver.ru \
    --to=lynx@sibserver.ru \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).