aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-12-05 13:08:22 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-12-05 13:54:21 +0200
commitc0f279c469c87a010fda19647c5453baa5ba97ee (patch)
tree6882abf38ac3998cda87fce550e0bfef0e283c7a /src
parentb27b6e75af556b7a07a156eef670e1086c063685 (diff)
downloadpostgresql-c0f279c469c87a010fda19647c5453baa5ba97ee.tar.gz
postgresql-c0f279c469c87a010fda19647c5453baa5ba97ee.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/port/tar.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/port/tar.c b/src/port/tar.c
index 09fd6c10d34..8ef4f9c3883 100644
--- a/src/port/tar.c
+++ b/src/port/tar.c
@@ -77,8 +77,8 @@ tarCreateHeader(char *h, const char *filename, const char *linktarget,
h[flen + 1] = '\0';
}
- /* Mode 8 */
- sprintf(&h[100], "%07o ", (int) mode);
+ /* Mode 8 - this doesn't include the file type bits (S_IFMT) */
+ sprintf(&h[100], "%07o ", (int) (mode & 07777));
/* User ID 8 */
sprintf(&h[108], "%07o ", (int) uid);