Commit c0f279c4 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Don't include file type bits in tar archive's mode field.

The "file mode" bits in the tar file header is not supposed to include the
file type bits, e.g. S_IFREG or S_IFDIR. The file type is stored in a
separate field. This isn't a problem in practice, all tar programs ignore
the extra bits, but let's be tidy.

This came up in a discussion around bug #11949, reported by Hendrik Grewe,
although this doesn't fix the issue with tar --append. That turned out to be
a bug in GNU tar. Schilly's tartest program revealed this defect in the tar
created by pg_basebackup.

This problem goes as far as we we've had pg_basebackup, but since this
hasn't caused any problems in practice, let's be conservative and fix in
master only.
parent b27b6e75
...@@ -77,8 +77,8 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget, ...@@ -77,8 +77,8 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
h[flen + 1] = '\0'; h[flen + 1] = '\0';
} }
/* Mode 8 */ /* Mode 8 - this doesn't include the file type bits (S_IFMT) */
sprintf(&h[100], "%07o ", (int) mode); sprintf(&h[100], "%07o ", (int) (mode & 07777));
/* User ID 8 */ /* User ID 8 */
sprintf(&h[108], "%07o ", (int) uid); sprintf(&h[108], "%07o ", (int) uid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment