[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in cpio involving -A and -D
From: |
David Garfield |
Subject: |
Bug in cpio involving -A and -D |
Date: |
Wed, 28 Sep 2022 11:55:07 -0400 |
When using options -A and -D, where the directory is not absolute, cpio
(usually) fails. The problem is that it tries to chdir() into the
directory *twice*. This only works if the path is absolute, or if the
directory name is appropriately symlinked.
I initially found this in the debian bullseye build of 2.13.
I then downloaded the standard source and tried that as well. (This
was made more difficult by the erroneous double definition of variable
program_name.)
My test script is below. The expected output is a listing of all four
files added to the cpio. The actual output is that file "2" does not
get added, and an error message reading "cpio: cannot change to
directory `d': No such file or directory" is output.
--David Garfield
#!/bin/bash
cpio="${1:-cpio}"
( rm -f d/1 d/2 d/3 d/4 d/d ; rmdir d ) >/dev/null 2>&1
mkdir d
echo 1 >d/1
echo 2 >d/2
echo 3 >d/3
echo 4 >d/4
echo 1 | $cpio -o -Hnewc -Fout -Dd
echo 2 | $cpio -o -Hnewc -A -Fout -Dd
echo 3 | $cpio -o -Hnewc -A -Fout -D`pwd`/d
ln -s . d/d
echo 4 | $cpio -o -Hnewc -A -Fout -Dd
$cpio -itv -Fout
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bug in cpio involving -A and -D,
David Garfield <=