mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Cope with trying to force when write bit is disabled and use mode 0600 instead of 0666.
Patch by Serge Belyshev.
This commit is contained in:
parent
70e7866271
commit
74f7b3deb6
20
lrzip.c
20
lrzip.c
|
|
@ -597,10 +597,12 @@ void decompress_file(rzip_control *control)
|
||||||
control->fd_in = fd_in;
|
control->fd_in = fd_in;
|
||||||
|
|
||||||
if (!(TEST_ONLY | STDOUT)) {
|
if (!(TEST_ONLY | STDOUT)) {
|
||||||
if (FORCE_REPLACE)
|
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
||||||
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
||||||
else
|
if (unlikely(unlink(control->outfile)))
|
||||||
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
||||||
|
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
||||||
|
}
|
||||||
if (unlikely(fd_out == -1)) {
|
if (unlikely(fd_out == -1)) {
|
||||||
/* We must ensure we don't delete a file that already
|
/* We must ensure we don't delete a file that already
|
||||||
* exists just because we tried to create a new one */
|
* exists just because we tried to create a new one */
|
||||||
|
|
@ -1016,10 +1018,12 @@ void compress_file(rzip_control *control)
|
||||||
print_progress("Output filename is: %s\n", control->outfile);
|
print_progress("Output filename is: %s\n", control->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FORCE_REPLACE)
|
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_TRUNC, 0666);
|
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
||||||
else
|
if (unlikely(unlink(control->outfile)))
|
||||||
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0666);
|
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
||||||
|
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||||
|
}
|
||||||
if (unlikely(fd_out == -1)) {
|
if (unlikely(fd_out == -1)) {
|
||||||
/* We must ensure we don't delete a file that already
|
/* We must ensure we don't delete a file that already
|
||||||
* exists just because we tried to create a new one */
|
* exists just because we tried to create a new one */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue