svn commit: trunk/busybox/archival
landley at busybox.net
landley at busybox.net
Tue Jun 13 14:54:43 UTC 2006
Author: landley
Date: 2006-06-13 07:54:42 -0700 (Tue, 13 Jun 2006)
New Revision: 15367
Log:
Patch from Denis Vlasenko: unlzma was make files with mode 777. Tweak
everything to do stat() and use xopen3().
Modified:
trunk/busybox/archival/bunzip2.c
trunk/busybox/archival/gunzip.c
trunk/busybox/archival/unlzma.c
Changeset:
Modified: trunk/busybox/archival/bunzip2.c
===================================================================
--- trunk/busybox/archival/bunzip2.c 2006-06-13 14:37:14 UTC (rev 15366)
+++ trunk/busybox/archival/bunzip2.c 2006-06-13 14:54:42 UTC (rev 15367)
@@ -41,16 +41,21 @@
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
- bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
+ bb_error_msg_and_die("Compressed data not read from terminal. Use -f to force it.");
}
if (filename) {
+ struct stat stat_buf;
char *extension=filename+strlen(filename)-4;
if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
+ /* TODO: xstat */
+ if (stat(filename, &stat_buf) < 0) {
+ bb_error_msg_and_die("Couldn't stat file %s", filename);
+ }
*extension=0;
- dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
+ dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if(filename) {
Modified: trunk/busybox/archival/gunzip.c
===================================================================
--- trunk/busybox/archival/gunzip.c 2006-06-13 14:37:14 UTC (rev 15366)
+++ trunk/busybox/archival/gunzip.c 2006-06-13 14:54:42 UTC (rev 15367)
@@ -137,12 +137,9 @@
bb_error_msg_and_die("Invalid extension");
}
- /* Open output file */
- dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
+ /* Open output file (with correct permissions) */
+ dst_fd = bb_xopen3(new_path, O_WRONLY | O_CREAT, stat_buf.st_mode);
- /* Set permissions on the file */
- chmod(new_path, stat_buf.st_mode);
-
/* If unzip succeeds remove the old file */
delete_path = old_path;
}
Modified: trunk/busybox/archival/unlzma.c
===================================================================
--- trunk/busybox/archival/unlzma.c 2006-06-13 14:37:14 UTC (rev 15366)
+++ trunk/busybox/archival/unlzma.c 2006-06-13 14:54:42 UTC (rev 15367)
@@ -41,13 +41,18 @@
filename = 0;
if (filename) {
+ struct stat stat_buf;
char *extension = filename + strlen(filename) - 5;
if (strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("Invalid extension");
}
+ /* TODO: xstat? */
+ if (stat(filename, &stat_buf) < 0) {
+ bb_error_msg_and_die("Couldn't stat file %s", filename);
+ }
*extension = 0;
- dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
+ dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
More information about the busybox-cvs
mailing list