[Toybox] cpio -d patch...

Rob Landley rob at landley.net
Sun Mar 16 08:40:31 PDT 2014


Catching up on backscroll...

On 03/11/14 10:46, Isaac Dunham wrote:
>> By the way, if you notice those games with 0777&~toys.umask, that's
>> because mkdir has TOYFLAG_UMASK in its NEWTOY() flags, which tells
>> main() to set the umask to 0 (and save the old umask in toys.umask).
>> That way when we create things, we get the permission we actually
>> request rather than a filtered subset, allowing things like mkdir -m
>> to work properly. I note that toys/pending/cpio.c is _not_ doing
>> that, nor is it calling umask(0) itself, meaning it's allowing umask
>> to filter the permissions of everything it creates rather than
>> producing output with the actual modes recorded in the archive. Is
>> this intentional?
> 
> I wasn't sure what to do, so I tested GNU cpio, and that's what it
> _seemed_ to  be doing.
> Not that it's necessarily the right thing to do.
> I guess if someone sets umask to 0477, it will break. 
> But then, a _lot_ of things would break then...

I haven't extensively tested cpio (yet) but I _have_ tested mkdir, and
the "-m only applies to leaf nodes" thing came from there. Factoring out
the code required keeping that behavior.

The behavior of cpio is... inconsistent. And not many people seem
familiar with it. To be honest, I'm less concerned about toybox cpio
being inconsistent with gnu and more with A) not explicitly violating
what little information susv2 provides, B) working the same way as tar
and zip, C) working with initramfs and RPM. Being consistent with
existing cpio implementations comes in fourth.

Rob

 1394984431.0


More information about the Toybox mailing list