mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Make open use mode 0777 since it will already be & ~umask it will preserve the default permissions.
Don't try to copy permissions from STDIN.
This commit is contained in:
parent
e66d97ab19
commit
920ad9251d
15
lrzip.c
15
lrzip.c
|
|
@ -595,11 +595,11 @@ void decompress_file(rzip_control *control)
|
||||||
control->fd_in = fd_in;
|
control->fd_in = fd_in;
|
||||||
|
|
||||||
if (!(TEST_ONLY | STDOUT)) {
|
if (!(TEST_ONLY | STDOUT)) {
|
||||||
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0777);
|
||||||
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
||||||
if (unlikely(unlink(control->outfile)))
|
if (unlikely(unlink(control->outfile)))
|
||||||
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
||||||
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
fd_out = open(control->outfile, O_WRONLY | O_CREAT | O_EXCL, 0777);
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
@ -611,7 +611,9 @@ void decompress_file(rzip_control *control)
|
||||||
if (unlikely(fd_hist == -1))
|
if (unlikely(fd_hist == -1))
|
||||||
fatal("Failed to open history file %s\n", control->outfile);
|
fatal("Failed to open history file %s\n", control->outfile);
|
||||||
|
|
||||||
preserve_perms(control, fd_in, fd_out);
|
/* Can't copy permissions from STDIN */
|
||||||
|
if (!STDIN)
|
||||||
|
preserve_perms(control, fd_in, fd_out);
|
||||||
} else {
|
} else {
|
||||||
fd_out = open_tmpoutfile(control);
|
fd_out = open_tmpoutfile(control);
|
||||||
if (unlikely(fd_out == -1))
|
if (unlikely(fd_out == -1))
|
||||||
|
|
@ -1012,11 +1014,11 @@ void compress_file(rzip_control *control)
|
||||||
print_progress("Output filename is: %s\n", control->outfile);
|
print_progress("Output filename is: %s\n", control->outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0600);
|
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0777);
|
||||||
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
if (FORCE_REPLACE && (-1 == fd_out) && (EEXIST == errno)) {
|
||||||
if (unlikely(unlink(control->outfile)))
|
if (unlikely(unlink(control->outfile)))
|
||||||
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
fatal("Failed to unlink an existing file: %s\n", control->outfile);
|
||||||
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0600);
|
fd_out = open(control->outfile, O_RDWR | O_CREAT | O_EXCL, 0777);
|
||||||
}
|
}
|
||||||
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
|
||||||
|
|
@ -1025,7 +1027,8 @@ void compress_file(rzip_control *control)
|
||||||
fatal("Failed to create %s\n", control->outfile);
|
fatal("Failed to create %s\n", control->outfile);
|
||||||
}
|
}
|
||||||
control->fd_out = fd_out;
|
control->fd_out = fd_out;
|
||||||
preserve_perms(control, fd_in, fd_out);
|
if (!STDIN)
|
||||||
|
preserve_perms(control, fd_in, fd_out);
|
||||||
} else
|
} else
|
||||||
open_tmpoutbuf(control);
|
open_tmpoutbuf(control);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue