diff options
Diffstat (limited to 'ports/linux/xattr/pseudo_wrappers.c')
-rw-r--r-- | ports/linux/xattr/pseudo_wrappers.c | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c index c37c245..40699d6 100644 --- a/ports/linux/xattr/pseudo_wrappers.c +++ b/ports/linux/xattr/pseudo_wrappers.c @@ -112,7 +112,7 @@ posix_permissions(const acl_header *header, int entries, int *extra, int *mode) static ssize_t shared_getxattr(const char *path, int fd, const char *name, void *value, size_t size) { RC_AND_BUF - pseudo_debug(PDBGF_XATTR, "getxattr(%s/%d, %s)\n", + pseudo_debug(PDBGF_XATTR, "getxattr(%s [fd %d], %s)\n", path ? path : "<no path>", fd, name); pseudo_msg_t *result = pseudo_client_op(OP_GET_XATTR, 0, fd, -1, path, &buf, name); if (result->result != RESULT_SUCCEED) { @@ -135,31 +135,10 @@ static ssize_t shared_getxattr(const char *path, int fd, const char *name, void static int shared_setxattr(const char *path, int fd, const char *name, const void *value, size_t size, int flags) { RC_AND_BUF - - char *combined; - size_t nlen = strlen(name); - size_t combined_len = nlen + size + 1; - combined = malloc(combined_len + 1); - memcpy(combined, name, nlen); - combined[nlen] = '\0'; - memcpy(combined + nlen + 1, value, size); - combined[combined_len] = '\0'; - - pseudo_debug(PDBGF_XATTR, "setxattr(%s/%d, %s, %s => %s [%d])\n", - path ? path : "<no path>", fd, name, (char *) value, combined + nlen + 1, (int) size); - pseudo_op_t op; - switch (flags) { - case XATTR_CREATE: - op = OP_CREATE_XATTR; - break; - case XATTR_REPLACE: - op = OP_REPLACE_XATTR; - break; - default: - op = OP_SET_XATTR; - break; - } + + pseudo_debug(PDBGF_XATTR, "setxattr(%s [fd %d], %s => '%.*s')\n", + path ? path : "<no path>", fd, name, (int) size, (char *) value); /* this may be a plain chmod */ if (!strcmp(name, "system.posix_acl_access")) { @@ -170,7 +149,16 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi pseudo_debug(PDBGF_XATTR, "posix_acl_access translated to mode %04o. Remaining attribute(s): %d.\n", mode, extra); buf.st_mode = mode; - pseudo_client_op(path ? OP_CHMOD : OP_FCHMOD, 0, fd, -1, path, &buf); + /* we want to actually issue a corresponding chmod, + * as well, or else the file ends up 0600 on the + * host. Using the slightly-less-efficient wrap_chmod + * avoids possible misalignment. + */ + if (path) { + wrap_chmod(path, mode); + } else { + wrap_fchmod(fd, mode); + } /* we are sneaky, and do not actually record this using * extended attributes. */ if (!extra) { @@ -179,7 +167,19 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi } } - pseudo_msg_t *result = pseudo_client_op(op, 0, fd, -1, path, &buf, combined, combined_len); + switch (flags) { + case XATTR_CREATE: + op = OP_CREATE_XATTR; + break; + case XATTR_REPLACE: + op = OP_REPLACE_XATTR; + break; + default: + op = OP_SET_XATTR; + break; + } + + pseudo_msg_t *result = pseudo_client_op(op, 0, fd, -1, path, &buf, name, value, size); /* we automatically assume success */ if (op == OP_SET_XATTR) { |