1.25.1 cpio Extract Issue

Marc Smith marc.smith at mcc.edu
Sun Oct 30 16:33:44 UTC 2016


Hi,

I recently updated my project to use Busybox version 1.25.1. After
doing so, I noticed that archives extracted with BB's cpio were all
owned by root (when executing cpio as root). I'm not using the newish
"-R" option.

I believe this problem is caused by commit
2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a
(https://git.busybox.net/busybox/commit/?id=2735bc00e35c5fd8eec6d656f4d8a17ee2630c2a)
- "cpio: implement -R/--owner".

I quickly looked at the source this morning, and after adding a couple
monitoring lines, it looks like this is the culprit
(archival/libarchive/get_header_cpio.c lines 55-59 of 1.25.1):

--snip--
    /* "cpio -R USER:GRP" support: */
    if (archive_handle->cpio__owner.uid != (uid_t)-1L)
        uid = archive_handle->cpio__owner.uid;
    if (archive_handle->cpio__owner.gid != (gid_t)-1L)
        gid = archive_handle->cpio__owner.gid;
--snip--

When testing, archive_handle->cpio__owner.uid and
archive_handle->cpio__owner.gid have a value of 0, when I believe by
default it should have a value of -1 if the "-R" option is not used.
So, instead of using the value from the header, the UID and GID always
set to 0.

I think the proper fix would be to initialize
archive_handle->cpio__owner.uid and archive_handle->cpio__owner.gid to
-1L and then if "-R" is used it gets overridden. I'm just not sure of
the correct place to initialize these.


Thanks,

Marc


More information about the busybox mailing list