[Toybox] Tilde expansion test on android?

Rob Landley rob at landley.net
Sat Jan 11 16:54:05 PST 2020


On 1/11/20 12:18 AM, enh wrote:
>> It's not so much an OS test I want as a libc test. "Bionic is not checking
>> /etc/passwd to get this data, it's synthesizing it internally..."
>>
>> Although... would [ ! -e /etc/passwd ] be a better test maybe? I vaguely recall
>> sometimes there was one for some reason?
> 
> yeah, on recent releases there's an /etc/passwd (but it's often empty,
> and should never contain root, though i don't think there's actually
> anything to prevent an OEM from uselessly putting root in there).
>
>> Ok, how about:
>>
>>   if grep -q :root: /etc/passwd 2>/dev/null
>>   then
>>     $ANDROID
>>   fi
> 
> yeah, that should be fine on every device i'm aware of.

I don't trust mac not to break this.

>> (It's not science if you can't reproduce it. "Works in this guy's lab but not
>> that guy's lab" is alchemy, not science. WAY too much computer science isn't.)
> 
> one of these days i'll look into this whole docker thing. my main
> interest in that is actually working out how to get the github CI
> working for toybox, but maybe you don't even need to know docker for
> that? https://help.github.com/en/actions/automating-your-workflow-with-github-actions/setting-up-continuous-integration-using-github-actions

Docker's kind of overengineered to me. I did a 6 month contract for parallels
back in 2011 helping them get container support into Vanilla Linux (hence
http://landley.net/lxc/ and https://landley.livejournal.com/47761.html and so
on), and I've been _meaning_ to create a proper "container" command ever since,
but it's way down on the todo list with rsync and screen and such.

>>> `getprop ro.build.fingerprint`, or even just checking
>>> whether there's a getprop on the path?
>>
>> I can "which getprop", sure.
>>
>>> it looks like debian says /nonexistent for ~nobody, and macOS says
>>> /var/empty. so that's probably good enough for non-Android? oh, but
>>> ~root works on macOS too anyway --- /var/root.
>>
>> The problem is not knowing what to compare the string against. And yes, I'll
>> need to test for macos here too so it knows to expect /var/root, but according
>> to tests/du.test that's just "$(uname) == Darwin"... except the above test for
>> not having an /etc/passwd with :root: in it may also trigger on MacOSX (dunno),
>> so I should probably go back to the previous test.
>>
>> Hmmm... Do you think it would be a good idea for "uname -o" to say "Android"?
>> Right now -o is a synonym for -s but it doesn't _have_ to be..
> 
> keep it as Linux and Darwin for the others, but #if __ANDROID__ output
> Android? that's not a bad idea, but like you i tend to prefer the more
> specific "here's what i actually need" tests rather than "tell me who
> you are, and i'll guess what you're like" that something like this
> would lead to. so wait until we actually need it?

It already says "Linux" instread of
"GNU/GNU/GNU/I_CLAIM_THIS_CODEBASE_IN_THE_NAME_OF_RICHARD_STALLMAN_LONG_MAY_HE_FONDLE"
so you can already distinguish toybox vs non-toybox, but in terms of "toybox on
linux" vs "toybox on android" it's just passing on what the syscall says. You
could just as easily patch the Android kernel (or the bionic wrapper) to change
what the syscall returns... except that would change _both_ -s and -o.

The fact there's already an -s (and that's the posix option) implies that yeah,
making -o say "Android" when linked against Bionic is probably the right thing
on general principles...

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uname.patch
Type: text/x-patch
Size: 686 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200111/42990ac4/attachment-0003.bin>


More information about the Toybox mailing list