On Wed, Mar 3, 2021 at 1:56 AM enh <e...@google.com> wrote: > > > On Mon, Mar 1, 2021 at 5:43 PM Rob Landley <r...@landley.net> wrote: > >> On 2/28/21 12:29 PM, Yi-yo Chiang wrote: >> > (I'll try to keep it short) >> > >> > My original motivation to send this patch is that my coworker found out >> (when he >> > was working with initramfs) that "cpio -u" behaves differently on toybox >> > compared to the GNU's implementation. >> >> "What was the actual problem?" "My coworker noticed this existed." >> >> That's... not a use case? >> > > from the bugs, i think the original bug was the "File exists" -d bug from > the ramdisk cpio file, and they hit the -u behavior difference trying to > work around that before realizing that -d was the real problem? (or maybe > -u was an attempt to produce a small repro case for the -d bug. Or both!) > > i'll sync AOSP today anyway. thanks! >
It's the opposite, we have problems with "-u", and I hit the "-d" thing when I'm trying to produce minimal repro steps. I recall the original use case is that we were trying to unpack an initramfs file, where the initramfs consists of multiple cpio archives concatenated. So even if the extraction destination is empty, name conflict still happens, because name conflict is happening between two component cpio archives. e.g. initramfs consists of two cpio archives, and both archives are creating the same directory. Thanks, it's (f1be076b52ad) working now! >> } else if (S_ISLNK(mode)) { >> data = strpad(afd, size, 0); >> - if (!test) err = symlink(data, name); >> + if (!test) { >> + err = symlink(data, name); >> + // Can't get a filehandle to a symlink, so do special chown >> + if (!err && !geteuid() && !FLAG(no_preserve_owner)) >> + err = lchown(name, uid, gid); >> + } >> free(data); >> - // Can't get a filehandle to a symlink, so do special chown >> - if (!err && !geteuid() && !FLAG(no_preserve_owner)) >> - err = lchown(name, uid, gid); >> >> Following are more testcases... $ ln -s target_name a $ stat -c '%u' a 584303 $ sudo chown --no-dereference 0 a $ stat -c '%u' a 0 $ # Verify that the owner of 'a' is changed to root $ echo a | cpio -o -H newc >a.cpio $ rm a $ touch a $ stat -c '%u' a 584303 $ # Verify that the owner of 'a' is not root $ sudo ./toybox cpio -i -t <a.cpio a $ stat -c '%u' a 0 The owner of 'a' is modified, albeit the "-t" (test) flag. I expect "-t" to only show the list of files to stdout, and not modify/create any file? -- Yi-yo Chiang Software Engineer yochi...@google.com
_______________________________________________ Toybox mailing list Toybox@lists.landley.net http://lists.landley.net/listinfo.cgi/toybox-landley.net