diff options
| author | Anton Gerasimov <anton@advancedtelematic.com> | 2017-10-30 15:34:14 +0100 |
|---|---|---|
| committer | Anton Gerasimov <anton@advancedtelematic.com> | 2017-10-30 15:34:14 +0100 |
| commit | 6f11d78e73e33b06a8ceb64757fa3e267d95f7e5 (patch) | |
| tree | 4de05b54c8a915aa25a0e32bd86fa4365feaa252 | |
| parent | 9cf14ec8d924a5f88a3441ee2896a04f74188024 (diff) | |
| download | meta-updater-6f11d78e73e33b06a8ceb64757fa3e267d95f7e5.tar.gz | |
Backport bugfix for POSIX ACL from pyro
| -rw-r--r-- | recipes-devtools/pseudo/files/fix-posix-acl.patch | 72 | ||||
| -rw-r--r-- | recipes-devtools/pseudo/pseudo_1.8.1.bbappend | 5 |
2 files changed, 77 insertions, 0 deletions
diff --git a/recipes-devtools/pseudo/files/fix-posix-acl.patch b/recipes-devtools/pseudo/files/fix-posix-acl.patch new file mode 100644 index 0000000..e2cc2e4 --- /dev/null +++ b/recipes-devtools/pseudo/files/fix-posix-acl.patch | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c | ||
| 2 | index 46bc053..d69d53e 100644 | ||
| 3 | --- a/ports/linux/xattr/pseudo_wrappers.c | ||
| 4 | +++ b/ports/linux/xattr/pseudo_wrappers.c | ||
| 5 | @@ -62,9 +62,9 @@ static int | ||
| 6 | posix_permissions(const acl_header *header, int entries, int *extra, int *mode) { | ||
| 7 | int acl_seen = 0; | ||
| 8 | if (le32(header->version) != 2) { | ||
| 9 | - pseudo_diag("Fatal: ACL support no available for header version %d.\n", | ||
| 10 | + pseudo_diag("Fatal: ACL support not available for header version %d.\n", | ||
| 11 | le32(header->version)); | ||
| 12 | - return 1; | ||
| 13 | + return -1; | ||
| 14 | } | ||
| 15 | *mode = 0; | ||
| 16 | *extra = 0; | ||
| 17 | @@ -140,12 +140,38 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi | ||
| 18 | pseudo_debug(PDBGF_XATTR, "setxattr(%s [fd %d], %s => '%.*s')\n", | ||
| 19 | path ? path : "<no path>", fd, name, (int) size, (char *) value); | ||
| 20 | |||
| 21 | + /* Filter out erroneous sizes for POSIX ACL | ||
| 22 | + * see posix_acl_xattr_count in include/linux/posix_acl_xattr.h of Linux source code */ | ||
| 23 | + /* I don't think there's any posix_acl_* values that aren't in this format */ | ||
| 24 | + if (!strncmp(name, "system.posix_acl_", 17)) { | ||
| 25 | + // ACL is corrupt, issue an error | ||
| 26 | + if(size < sizeof(acl_header) || (size - sizeof(acl_header)) % sizeof(acl_entry) != 0) { | ||
| 27 | + pseudo_debug(PDBGF_XATTR, "invalid data size for %s: %d\n", | ||
| 28 | + name, (int) size); | ||
| 29 | + errno = EINVAL; | ||
| 30 | + return -1; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + // ACL is empty, do nothing | ||
| 34 | + if((size - sizeof(acl_header)) / sizeof(acl_entry) == 0) { | ||
| 35 | + /* on some systems, "cp -a" will attempt to clone the | ||
| 36 | + * posix_acl_default entry for a directory (which would specify | ||
| 37 | + * default ACLs for new files in that directory), but if the | ||
| 38 | + * original was empty, we get a header but no entries. With | ||
| 39 | + * real xattr, that ends up being silently discarded, apparently, | ||
| 40 | + * so we discard it too. | ||
| 41 | + */ | ||
| 42 | + pseudo_debug(PDBGF_XATTR, "0-length ACL entry %s.\n", name); | ||
| 43 | + return 0; | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | /* this may be a plain chmod */ | ||
| 47 | if (!strcmp(name, "system.posix_acl_access")) { | ||
| 48 | int extra; | ||
| 49 | int mode; | ||
| 50 | int entries = (size - sizeof(acl_header)) / sizeof(acl_entry); | ||
| 51 | - if (!posix_permissions(value, entries, &extra, &mode)) { | ||
| 52 | + int res = posix_permissions(value, entries, &extra, &mode); | ||
| 53 | + if (res == 0) { | ||
| 54 | pseudo_debug(PDBGF_XATTR, "posix_acl_access translated to mode %04o. Remaining attribute(s): %d.\n", | ||
| 55 | mode, extra); | ||
| 56 | buf.st_mode = mode; | ||
| 57 | @@ -164,8 +190,12 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi | ||
| 58 | if (!extra) { | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | + } else if (res == -1) { | ||
| 62 | + errno = EOPNOTSUPP; | ||
| 63 | + return -1; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | + | ||
| 67 | if (!strcmp(name, "user.pseudo_data")) { | ||
| 68 | pseudo_debug(PDBGF_XATTR | PDBGF_XATTRDB, "user.pseudo_data xattribute does not get to go in database.\n"); | ||
| 69 | return -1; | ||
| 70 | -- | ||
| 71 | cgit v0.10.2 | ||
| 72 | |||
diff --git a/recipes-devtools/pseudo/pseudo_1.8.1.bbappend b/recipes-devtools/pseudo/pseudo_1.8.1.bbappend new file mode 100644 index 0000000..1ee3c37 --- /dev/null +++ b/recipes-devtools/pseudo/pseudo_1.8.1.bbappend | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/files:" | ||
| 2 | |||
| 3 | SRC_URI_append = " \ | ||
| 4 | file://fix-posix-acl.patch \ | ||
| 5 | " | ||
