[PATCH 2/2] Added support for compiling against Android bionic

Tito farmatito at tiscali.it
Tue May 31 06:01:53 UTC 2011



On Tuesday 31 May 2011 01:48:05 Rich Felker wrote:
> On Mon, May 30, 2011 at 02:05:13PM -0700, Dan Fandrich wrote:
> > It's not easy compiling something against bionic using the
> > Android compiler outside the Android build system, but it can
> > at least now happen.
> > 
> > Signed-off-by: Dan Fandrich <dan at coneharvesters.com>
> > ---
> > Conditionally compiling xmalloc_ttyname() is a bit ugly, but necessary
> > since bionic doesn't have ttyname_r.
> 
> Plain ttyname could be used, I think. The only reason ttyname_r is
> used is to avoid enlarging bss for the nasty static buffer; it's not
> for reentrancy. This could also be done via HAVE_TTYNAME_R in
> platform.h rather than #ifndef ANDROID (see below)...
> 
> >  /* Try to pull in PAGE_SIZE */
> >  #ifdef __linux__
> > -# include <sys/user.h>
> > +# ifdef ANDROID
> > +#  include <sys/mman.h>
> > +# else
> > +#  include <sys/user.h>
> > +# endif
> 
> Why not get it from the correct place, limits.h? In case broken libs
> (glibc?) are missing it, you could do something like:
> 
> #include <limits.h>
> #ifndef PAGE_SIZE
> #include <sys/user.h>
> #endif
> 
> > --- a/libbb/obscure.c
> > +++ b/libbb/obscure.c
> > @@ -109,10 +109,12 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc
> >  	if (string_checker(new_p, pw->pw_name)) {
> >  		return "similar to username";
> >  	}
> > +#ifndef ANDROID
> >  	/* no gecos as-is, as sub-string, reversed, capitalized, doubled */
> >  	if (pw->pw_gecos[0] && string_checker(new_p, pw->pw_gecos)) {
> >  		return "similar to gecos";
> >  	}
> > +#endif

Hi,
passwd management and user management due to the
somewhat exotic security model choosen is from my point
of view broken. Main example is the missing of a pw->passwd
field which could lead to very unexpected results
if you compile binaries that are for real linux systems.
It would be by far better for the android people to compile
android statically linked to uclibc rather than trying to link
against android bionic libc. I would suggest to disable
all applets involving user/group/passwd/auth management
when ANDROID is defined. This saves us from spaghetti code.
Just my 2 cents.

Ciao,
Tito

> This is a really ugly legacy approach to "portability" and leads to
> spaghetti #ifdefs. Instead you should add HAVE_PW_GECOS or something
> and #undef it in platform.h for ANDROID. Basically, #ifdef SYSNAME or
> #ifndef SYSNAME should *never* appear outside of platform.h. Currently
> it does in many places, but this should be treated as a bug to be
> fixed, not a practice to be followed.
> 
> Rich
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 



More information about the busybox mailing list