[patch] tar -c messing file/device mode
Timo Teräs
timo.teras at iki.fi
Fri Jan 16 09:01:42 UTC 2009
Hi,
I had on some systems very mysterious changes of /dev/null mode to
"crw-r--r--" that will cause all kind of bad things to happen.
After some tedious debugging, I was able to isolate it to one
script that did:
tar -c -v -I includelist -X excludelist somefiles > /dev/null
to get a hold of file names that would be included in the archive.
But this single command managed to mess the /dev/null mode.
It appears that tar.c uses fchmod to change the file permissions
when creating the archive. But that's the completely wrong thing
to do for directions when outputting to stdout. And in any case
you should be relying on umask and not some fixed mode.
So please apply:
--- archival/tar.c (revision 24864)
+++ archival/tar.c (working copy)
@@ -592,8 +592,6 @@
struct TarBallInfo tbInfo;
tbInfo.hlInfoHead = NULL;
-
- fchmod(tar_fd, 0644);
tbInfo.tarFd = tar_fd;
tbInfo.verboseFlag = verboseFlag;
If you absolutely think that group/other write bit should
never be set on tar created archives (which is also wrong;
GNU tar relies on umask!) you might, but I'd recommend NOT
to, apply:
--- archival/tar.c (revision 24864)
+++ archival/tar.c (working copy)
@@ -943,7 +941,7 @@
if (tar_handle->src_fd < 0)
bb_perror_msg_and_die("can't open '%s'", tar_filename);
} else {
- tar_handle->src_fd = xopen(tar_filename, flags);
+ tar_handle->src_fd = xopen3(tar_filename, flags, 0644);
}
}
}
Cheers,
Timo
More information about the busybox
mailing list