[Toybox] [PATCH] cpio: fix -it

Isaac Dunham ibid.ag at gmail.com
Fri Mar 28 22:46:05 PDT 2014


On Thu, Mar 27, 2014 at 07:10:45AM -0500, Rob Landley wrote:
> On 03/26/14 12:13, Isaac Dunham wrote:
> > Fix cpio -it: don't close(fd) unless we opened it.
> 
> Ooh, good catch. (Applied.)
> 
> It's hard to get the code right without a good test case, and with
> aboriginal in pieces at the moment (ccwrap rewrite, switching over to
> musl) I haven't got a convenient chroot set up and am reluctant to test
> stuff as root on my work system (without which it can't create /dev
> nodes, fifos, and so on).

Yes...
All the stuff I've found has been by way of testing with
<generate list of files> |cpio -o |cpio -it
and compare the results to the original list of files.
While that doesn't necessarily test the format compatability, it's much
more likely to fail when either writing or reading invalid archives than
no test cases.

Now, as far as files to look at...
We want a list of files with names that are 1, 2, 3, and no bytes longer
than n*4 bytes to check padding; at least one unopenable device, socket,
symlink, or directory; and ideally, a selection of file sizes.
Without root access, /dev/console counts as unopenable.


> Also, I still have todo items. It should probably use the uid/gid fields
> when running as root, for example. (Create preserves 'em, but extract
> doesn't set them.)

Which will be roughly:

  if (!(toys.optflags & FLAG_no_preserve_owner) && (!geteuid())
    chown(name, x8u(toybuf+22), x8u(toybuf+30));
  errno = 0;

Not tested yet, but trivial.

Anyhow, I've got some bits of cleanup for openvt and deallocvt, and 
help updates for find, since I've had no net for a couple of rainy days.

Speaking of help... I notice that www/help.html did not actually get added;
the reference was all that showed up.

Thanks,
Isaac Dunham

 1396071965.0


More information about the Toybox mailing list