Bug 9306 - cpio 1.25.0 doesn't preserve file ownership
Summary: cpio 1.25.0 doesn't preserve file ownership
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-27 10:36 UTC by Nik Soggia
Modified: 2016-10-12 18:58 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
bugfix (629 bytes, patch)
2016-09-27 10:36 UTC, Nik Soggia
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nik Soggia 2016-09-27 10:36:49 UTC
Created attachment 6731 [details]
bugfix

# touch 1 2 3
# chown 11:111 1
# chown 22:222 2
# chown 33:333 3
# echo -e '1\n2\n3' | cpio -o -H newc | busybox cpio -v -t
1 block
-rw-r--r-- 0/0         0 2016-09-27 00:00:00 1
-rw-r--r-- 0/0         0 2016-09-27 00:00:00 2
-rw-r--r-- 0/0         0 2016-09-27 00:00:00 3
1 blocks

correct output should be:

-rw-r--r-- 11/111         0 2016-09-27 00:00:00 1
-rw-r--r-- 22/222         0 2016-09-27 00:00:00 2
-rw-r--r-- 33/333         0 2016-09-27 00:00:00 3

struct archive_handle is memset with zeroes when created.
archive_handle->cpio__owner has to be initialized explicitly otherwise any file will be extracted (or listed) with owner=0 and group=0.
here is my proposed solution:
Comment 1 Denys Vlasenko 2016-10-12 18:58:21 UTC
Fixed in git, thanks!