fix #1904
/dev/null permissions were modified when using sudo rights. This fixes this bug during decompression. More importantly, this patch adds a test, triggered in TravisCI, ensuring unaltered /dev/null permissions.
This commit is contained in:
parent
762a0dfc45
commit
7aaac3f69c
@ -34,7 +34,8 @@ matrix:
|
||||
|
||||
- name: make test (complete)
|
||||
script:
|
||||
- make test
|
||||
# DEVNULLRIGHTS : will request sudo rights to test permissions on /dev/null
|
||||
- DEVNULLRIGHTS=test make test
|
||||
|
||||
- name: gcc-6 + gcc-7 compilation
|
||||
script:
|
||||
|
@ -609,7 +609,10 @@ FIO_openDstFile(FIO_prefs_t* const prefs,
|
||||
{ FILE* const f = fopen( dstFileName, "wb" );
|
||||
if (f == NULL) {
|
||||
DISPLAYLEVEL(1, "zstd: %s: %s\n", dstFileName, strerror(errno));
|
||||
} else if(srcFileName != NULL && strcmp (srcFileName, stdinmark)) {
|
||||
} else if (srcFileName != NULL
|
||||
&& strcmp (srcFileName, stdinmark)
|
||||
&& strcmp(dstFileName, nulmark) ) {
|
||||
/* reduce rights on newly created dst file while compression is ongoing */
|
||||
chmod(dstFileName, 00600);
|
||||
}
|
||||
return f;
|
||||
@ -1393,7 +1396,7 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
||||
assert(ress.srcFile != NULL);
|
||||
if (ress.dstFile == NULL) {
|
||||
closeDstFile = 1;
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: opening dst: %s", dstFileName);
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: opening dst: %s \n", dstFileName);
|
||||
ress.dstFile = FIO_openDstFile(prefs, srcFileName, dstFileName);
|
||||
if (ress.dstFile==NULL) return 1; /* could not open dstFileName */
|
||||
/* Must only be added after FIO_openDstFile() succeeds.
|
||||
@ -1415,6 +1418,7 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
||||
|
||||
clearHandler();
|
||||
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: closing dst: %s \n", dstFileName);
|
||||
if (fclose(dstFile)) { /* error closing dstFile */
|
||||
DISPLAYLEVEL(1, "zstd: %s: %s \n", dstFileName, strerror(errno));
|
||||
result=1;
|
||||
@ -1427,7 +1431,10 @@ static int FIO_compressFilename_dstFile(FIO_prefs_t* const prefs,
|
||||
} else if ( strcmp(dstFileName, stdoutmark)
|
||||
&& strcmp(dstFileName, nulmark)
|
||||
&& transfer_permissions) {
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: transfering permissions into dst: %s \n", dstFileName);
|
||||
UTIL_setFileStat(dstFileName, &statbuf);
|
||||
} else {
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_dstFile: do not transfer permissions into dst: %s \n", dstFileName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1462,6 +1469,7 @@ FIO_compressFilename_srcFile(FIO_prefs_t* const prefs,
|
||||
int compressionLevel)
|
||||
{
|
||||
int result;
|
||||
DISPLAYLEVEL(6, "FIO_compressFilename_srcFile: %s \n", srcFileName);
|
||||
|
||||
/* ensure src is not a directory */
|
||||
if (UTIL_isDirectory(srcFileName)) {
|
||||
|
@ -220,13 +220,12 @@ $ZSTD tmp -c --compress-literals -19 | $ZSTD -t
|
||||
$ZSTD -b --fast=1 -i0e1 tmp --compress-literals
|
||||
$ZSTD -b --fast=1 -i0e1 tmp --no-compress-literals
|
||||
|
||||
println "test: --exclude-compressed flag"
|
||||
println "\n===> --exclude-compressed flag"
|
||||
rm -rf precompressedFilterTestDir
|
||||
mkdir -p precompressedFilterTestDir
|
||||
./datagen $size > precompressedFilterTestDir/input.5
|
||||
./datagen $size > precompressedFilterTestDir/input.6
|
||||
$ZSTD --exclude-compressed --long --rm -r precompressedFilterTestDir
|
||||
sleep 5
|
||||
./datagen $size > precompressedFilterTestDir/input.7
|
||||
./datagen $size > precompressedFilterTestDir/input.8
|
||||
$ZSTD --exclude-compressed --long --rm -r precompressedFilterTestDir
|
||||
@ -251,7 +250,7 @@ test -f precompressedFilterTestDir/input.5.zst.zst
|
||||
test -f precompressedFilterTestDir/input.6.zst.zst
|
||||
println "Test completed"
|
||||
|
||||
println "test : file removal"
|
||||
println "\n===> file removal"
|
||||
$ZSTD -f --rm tmp
|
||||
test ! -f tmp # tmp should no longer be present
|
||||
$ZSTD -f -d --rm tmp.zst
|
||||
@ -278,13 +277,16 @@ $ZSTD -f tmp && die "attempt to compress a non existing file"
|
||||
test -f tmp.zst # destination file should still be present
|
||||
rm -rf tmp* # may also erase tmp* directory from previous failed run
|
||||
|
||||
println "\n===> decompression only tests "
|
||||
dd bs=1 count=1048576 if=/dev/zero of=tmp
|
||||
println "\n===> decompression only tests "
|
||||
# the following test verifies that the decoder is compatible with RLE as first block
|
||||
# older versions of zstd cli are not able to decode such corner case.
|
||||
# As a consequence, the zstd cli do not generate them, to maintain compatibility with older versions.
|
||||
dd bs=1048576 count=1 if=/dev/zero of=tmp
|
||||
$ZSTD -d -o tmp1 "$TESTDIR/golden-decompression/rle-first-block.zst"
|
||||
$DIFF -s tmp1 tmp
|
||||
rm tmp*
|
||||
|
||||
println "test : compress multiple files"
|
||||
println "\m===> compress multiple files"
|
||||
println hello > tmp1
|
||||
println world > tmp2
|
||||
$ZSTD tmp1 tmp2 -o "$INTOVOID" -f
|
||||
@ -306,7 +308,17 @@ if [ "$?" -eq 139 ]; then
|
||||
fi
|
||||
rm tmp*
|
||||
|
||||
println "test : compress multiple files into an output directory, --output-dir-flat"
|
||||
if [ -n "$DEVNULLRIGHTS" ]
|
||||
then
|
||||
# these tests requires sudo rights, which is uncommon.
|
||||
# they are only triggered if DEVNULLRIGHTS macro is defined.
|
||||
println "\n===> checking /dev/null permissions are unaltered "
|
||||
./datagen > tmp
|
||||
sudo $ZSTD tmp -o $INTOVOID # sudo rights could modify /dev/null permissions
|
||||
ls -las $INTOVOID | grep "rw-rw-rw-"
|
||||
fi
|
||||
|
||||
println "\n===> compress multiple files into an output directory, --output-dir-flat"
|
||||
println henlo > tmp1
|
||||
mkdir tmpInputTestDir
|
||||
mkdir tmpInputTestDir/we
|
||||
@ -352,7 +364,6 @@ $ZSTD -dcf tmp1
|
||||
|
||||
|
||||
println "\n===> frame concatenation "
|
||||
|
||||
println "hello " > hello.tmp
|
||||
println "world!" > world.tmp
|
||||
cat hello.tmp world.tmp > helloworld.tmp
|
||||
|
Loading…
Reference in New Issue
Block a user