From 6f11d78e73e33b06a8ceb64757fa3e267d95f7e5 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Mon, 30 Oct 2017 15:34:14 +0100 Subject: Backport bugfix for POSIX ACL from pyro --- recipes-devtools/pseudo/files/fix-posix-acl.patch | 72 +++++++++++++++++++++++ recipes-devtools/pseudo/pseudo_1.8.1.bbappend | 5 ++ 2 files changed, 77 insertions(+) create mode 100644 recipes-devtools/pseudo/files/fix-posix-acl.patch create mode 100644 recipes-devtools/pseudo/pseudo_1.8.1.bbappend 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 @@ +diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c +index 46bc053..d69d53e 100644 +--- a/ports/linux/xattr/pseudo_wrappers.c ++++ b/ports/linux/xattr/pseudo_wrappers.c +@@ -62,9 +62,9 @@ static int + posix_permissions(const acl_header *header, int entries, int *extra, int *mode) { + int acl_seen = 0; + if (le32(header->version) != 2) { +- pseudo_diag("Fatal: ACL support no available for header version %d.\n", ++ pseudo_diag("Fatal: ACL support not available for header version %d.\n", + le32(header->version)); +- return 1; ++ return -1; + } + *mode = 0; + *extra = 0; +@@ -140,12 +140,38 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi + pseudo_debug(PDBGF_XATTR, "setxattr(%s [fd %d], %s => '%.*s')\n", + path ? path : "", fd, name, (int) size, (char *) value); + ++ /* Filter out erroneous sizes for POSIX ACL ++ * see posix_acl_xattr_count in include/linux/posix_acl_xattr.h of Linux source code */ ++ /* I don't think there's any posix_acl_* values that aren't in this format */ ++ if (!strncmp(name, "system.posix_acl_", 17)) { ++ // ACL is corrupt, issue an error ++ if(size < sizeof(acl_header) || (size - sizeof(acl_header)) % sizeof(acl_entry) != 0) { ++ pseudo_debug(PDBGF_XATTR, "invalid data size for %s: %d\n", ++ name, (int) size); ++ errno = EINVAL; ++ return -1; ++ } ++ ++ // ACL is empty, do nothing ++ if((size - sizeof(acl_header)) / sizeof(acl_entry) == 0) { ++ /* on some systems, "cp -a" will attempt to clone the ++ * posix_acl_default entry for a directory (which would specify ++ * default ACLs for new files in that directory), but if the ++ * original was empty, we get a header but no entries. With ++ * real xattr, that ends up being silently discarded, apparently, ++ * so we discard it too. ++ */ ++ pseudo_debug(PDBGF_XATTR, "0-length ACL entry %s.\n", name); ++ return 0; ++ } ++ } + /* this may be a plain chmod */ + if (!strcmp(name, "system.posix_acl_access")) { + int extra; + int mode; + int entries = (size - sizeof(acl_header)) / sizeof(acl_entry); +- if (!posix_permissions(value, entries, &extra, &mode)) { ++ int res = posix_permissions(value, entries, &extra, &mode); ++ if (res == 0) { + pseudo_debug(PDBGF_XATTR, "posix_acl_access translated to mode %04o. Remaining attribute(s): %d.\n", + mode, extra); + buf.st_mode = mode; +@@ -164,8 +190,12 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi + if (!extra) { + return 0; + } ++ } else if (res == -1) { ++ errno = EOPNOTSUPP; ++ return -1; + } + } ++ + if (!strcmp(name, "user.pseudo_data")) { + pseudo_debug(PDBGF_XATTR | PDBGF_XATTRDB, "user.pseudo_data xattribute does not get to go in database.\n"); + return -1; +-- +cgit v0.10.2 + 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 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI_append = " \ + file://fix-posix-acl.patch \ + " -- cgit v1.2.3-54-g00ecf