The archive generated with git-tar-tree had 0755 and 0644 mode bits.
This inconvenienced the extractor with umask 002 by robbing g+w bit
unconditionally. Just write it out with loose permissions bits and
let the umask of the extractor do its job.
Signed-off-by: Junio C Hamano <redacted>
---
Junio C Hamano [off-list ref] writes:
Unrelated to the topic at hand, but related to the mode bits --
tar-tree generates archives with 0644/0755 permission bits. It
might not be a bad idea to just let the tar command honor umask
of the extracter, by storing 0666 and 0777 in the archive.
I always work in an environment where umask 002 is the norm, and
get irritated when upstream tarballs of other peoples' projects
create directories with mode 0755, making me do chmod 2775 on
them.
diff --git a/tar-tree.c b/tar-tree.c
--- a/tar-tree.c
+++ b/tar-tree.c
@@ -353,6 +353,7 @@ static void traverse_tree(void *buffer,
if (size < namelen + 20 || sscanf(buffer, "%o", &mode) != 1)
die("corrupt 'tree' file");
+ mode |= (mode & 0100) ? 0777 : 0666;
buffer = sha1 + 20;
size -= namelen + 20;
Junio C Hamano wrote:
The archive generated with git-tar-tree had 0755 and 0644 mode bits.
This inconvenienced the extractor with umask 002 by robbing g+w bit
unconditionally. Just write it out with loose permissions bits and
let the umask of the extractor do its job.
I've thought that it would be nice if the files/directories were written
into the archive with 0666/0777 permissions by default, and then
extracted with the umask honoured. A special option then could be used
to add files with special permissions, like files in .ssh, which *have*
to be g-w or sshd will reject them.
-hpa
Hi, H. Peter Anvin wrote:
I've thought that it would be nice if the files/directories were written
into the archive with 0666/0777 permissions by default, and then
extracted with the umask honoured.
The git archive oesn't *have* permissions, just one "execute" bit.
A special option then could be used
to add files with special permissions, like files in .ssh, which *have*
to be g-w or sshd will reject them.
I'd include a script in the archive which you'd run afterwards to fix
problems like this. IMHO, in most situations you'll need it anyway
(for instance, to re-start services).
--
Matthias Urlichs | {M:U} IT Design @ m-u-it.de | smurf@smurf.noris.de
Disclaimer: The quote was selected randomly. Really. | http://smurf.noris.de
- -
As I approached the intersection a sign suddenly appeared in a place
where no stop sign had ever appeared before. I was unable to stop in
time to avoid the accident. To avoid hitting the bumper of the car in
front, I struck the pedestrian.
Matthias Urlichs wrote:
Hi, H. Peter Anvin wrote:
quoted
I've thought that it would be nice if the files/directories were written
into the archive with 0666/0777 permissions by default, and then
extracted with the umask honoured.
The git archive oesn't *have* permissions, just one "execute" bit.
My point is that I believe it should. It has the bitfield for it, it
just doesn't use it at the moment.
quoted
A special option then could be used
to add files with special permissions, like files in .ssh, which *have*
to be g-w or sshd will reject them.
I'd include a script in the archive which you'd run afterwards to fix
problems like this. IMHO, in most situations you'll need it anyway
(for instance, to re-start services).
That is true in some cases, but I highly disagree with the statement "most".
-hpa